Consuming a .NET WSDL Webservice Using Datasets in PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Fredrik Olof
Forum Newbie
Posts: 2
Joined: Fri Mar 16, 2007 8:20 am

Consuming a .NET WSDL Webservice Using Datasets in PHP

Post by Fredrik Olof »

Hello all!

First let me say that I have searched the net all over but I cannot find an answer, that is why I am trying here hoping some of you PHP gurus might know something :)

I work as a PHP programmer and recently I got the task of connecting (using PHP5) to a .NET webservice using wsdl and datasets. Now, after a week of frustration and hard work I am really stuck.

Here is my problem. My task is to save user variables in the webservice using a method called ‘Save’. I can connect fine and also generate the required ID for the operation, the problem comes when I try to save the variables, I can create the dataset via a method called GetNew but how can I access it after creating it? If I assign a variable to the GetNew call I get a fairly large array, but populating it and sending it into the webservice won’ work.

I guess what I am trying to ask is if it is possible to use, in PHP, a remote .NET webservice using datasets to save rows in its database.

Here is my code:

I connect to the webservice using NuSOAP:

Code: Select all

$url = 'http://webservice.address.here.com/WebService/folder/Main.asmx?wsdl';
$client  = new soapclient($url, true);
This works fine, next step is to authenticate myself, this also works fine:

Code: Select all

$headers  = '<SoapAuthenticator xmlns="'http://webservice.address.here.com/WebService/folder/"><UserId>xxxx</UserId><Password>xxxxx</Password></SoapAuthenticator>';

$client->setHeaders($headers);
Next step is to generate a unique id using a method called GenerateSFDDBGID, again this works fine:

Code: Select all

$GetID = array('strGIDPrefix'=>$adr);
$GID = $client->call('GenerateSFDDBGID', array('parameters'=>$GetID));
Now we come to the tricky part, creating, populating and saving the dataset, here is the code in .NET:

Code: Select all

DataSet dsCKDB = ws.GetNew("DATASET_IDENTIFIER");
The above code I try to recreate by doing this:

Code: Select all

$param_init= ' DATASET_IDENTIFIER';
$GetNew  = array('strTransactionId'=>$param_init);
$ds = $client->call('GetNew', array('parameters'=>$GetNew));
This give me a large array filled with values… the next line is what is driving me crazy:

Code: Select all

//New row
DataRow drLogCKDB = dsCKDB.Tables["Log"].NewRow();
Is this possible in any way to do in php? Can I somehow recreate the NewRow() call?



rest of the .NET code here:

Code: Select all

//Add extern source values
drLogCKDB["AdrGID"] = "XXXXXXXXXXXXXXXXXXXXX";
drLogCKDB["Datum"] = DateTime.Now;
drLogCKDB["Text"] = "CKDB WS Devnet - " + DateTime.Now.ToString();
drLogCKDB["ClassGID"] = "CLS_LOG_FRITEXT"; 

//Add Row
dsCKDB.Tables["Log"].Rows.Add(drLogCKDB);

//Save
dsCKDB = ws.Save("DATASET_IDENTIFIER ", intDBSpace, dsCKDB);
Anyhow, thanks for reading this post and If you know anything about .NET datasets and PHP please reply. I would like to know if it is even possible, been wasting a lot of time on this :/

Have a nice day

Best regards
/Fredrik
Post Reply