Jump to content

Consuming a WSDL .NET webservice using and datasets in PHP


bossakungen

Recommended Posts

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’t 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:

 

$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:

$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:

$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:

DataSet dsCKDB = ws.GetNew("DATASET_IDENTIFIER");

 

The above code I try to recreate by doing this:

$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:

//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:

//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

 

  • 2 months later...

if you can help me with my question then I can help you.

public BoProgram.Program ProgramService()

    {

       

        BoProgram.Program oProg = null;

 

        BoProgram.ProgramCollection cProg = new BoProgram.ProgramCollection();

        try

        {

         

            cProg.InitCollection(dsn);

            cProg.Clear();

 

            oProg = new BoProgram.Program();

            oProg.start_date = new DateTime(2007, 05, 24);

            oProg.end_date = new DateTime(2008, 05, 24);

            oProg.program_name = "CIBC Frequent Flyer";

            oProg.source_description = "Ceci est un test pour le fun";

            oProg.comm_id = 55;

 

            cProg.New(oProg);

 

            cProg.CloseConnection(true);

 

            // update

            cProg.InitProgramme(dsn, oProg.program_id);

            if (cProg.Count > 0)

            {

                oProg = new BoProgram.Program();

                oProg.start_date = cProg[0].start_date;

                oProg.end_date = cProg[0].end_date;

                oProg.program_name = cProg[0].program_name;

                oProg.source_description = cProg[0].source_description;

                cProg.New(oProg);

                cProg.CloseConnection(true);

            }

 

            cProg = null;

 

        }

 

        catch (Exception ex)

        {

            this.sErrorMsg = ex.Message;

            cProg = null;

        }

 

        return oProg; // return program object

 

    }

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.