Can someone help me to connect .net web services with nusoap,

Here are the sample .net code to access the web services,

public partial class WebServiceTest : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.cmdExecuteAction.ServerClick += new System.EventHandler(this.cmdExecuteAction_ServerClick);
}

private void cmdExecuteAction_ServerClick(object sender, System.EventArgs e)
{
    localhost.TestService TestService = new localhost.TestService();
    ExecuteActionRequest request = new ExecuteActionRequest();
    ExecuteActionResponse response = new ExecuteActionResponse();

    /**** add person ****/
    request.Action = Actions.Add;
    Person person = new Person();
    person.FirstName = "Johnny";
    person.LastName = "Roberts Jr";
    person.UserTypeCode = "MEM";
    person.HomePhone = "555-555-5555";
    person.HomePhone = "555-555-5555";
    person.CellPhone = "555-555-5555";
    person.PasswordHash = "dsfadsfasdfasdfasfzxcvcx";
    person.PasswordSalt = "jrob";

    request.Person = person;

    response = TestService.ExecuteAction(request);
}

}

Anyone please help me how to write the coding in php to access .net web services with using nusoap.

Thanks in advance.

    In my limited .net web services integrated with nusoap experience, I always liked that visual studio had the notion of a web services project and built out the wsdl file for you (passing ?wsdl to the end of the asmx file url.) Can you post your wsdl file, that will go a long way. Just an observation, your code snippet looks like it extends Page UI. Aren't those webpage controls etc? Seems strange, soap service definitely doesn't need them. Then again, been a few years since I dabbled in .net.)

      Using nusoap is pretty easy once you see how it works.

      The webservice should request an XML formatted document:

      <xml>
      <request>
      <field1>some data</field1>
      <field2>some data</field2>
      <field3>some data</field3>
      </request>
      </xml>

      Yours will be:
      $XMLSTR = "<xml>
      <person>
      <FistName></FirstName>
      <LastName ></LastName >
      <UserTypeCode ></UserTypeCode >
      <HomePhone ></HomePhone >
      <CellPhone ></CellPhone >
      <PasswordHash ></PasswordHash >
      <PasswordSalt ></PasswordSalt >
      </person>
      </xml>";

      Then you need to instantiate the nusoap

      $oClient = new soapclient('this is the webservice url?wsdl','wsdl'); // DO NOT FORGET TO ADD THE ?wsdl TO THE END OF THE URL

      Then, you need to create an array of parameters, this is where you send the XML string and any other data that's required. From what is provided, I can not tell, but if you go to the webservice URL, you will be able to see the examples. .NET webservices usually highlite the parameter names in a dark blue

      $PARAMS = array(
      'XML_STRING_VAR_NAME'=>$XMLSTR
      );

      Then you send your webservice call:

      $RESPONSE = $oClient->call('Add',$PARAMS );

      I'm using the 'Add' as the function your are calling.

      Hope this helps!

        Hi nanoc,

        Thanks for your reply,

        I did the same what you said, but in the .net coding "request.Action = Actions.Add" here we can assigning the action to the request. in nusoap we can call only functions through call method.

        Here my problem is, how can i assign the action to my request.

        PHP code here,

        $person = array('FirstName' => 'Johnny',
        'LastName' => 'Roberts Jr',
        'UserTypeCode' => 'MEM',
        'HomePhone' => '555-555-5555',
        'CellPhone' => '555-555-5555',
        'PasswordHash' => 'dsfadsfasdfasdfasfzxcvcx',
        'PasswordSalt' => 'jrob');

        $params = array('Person' => $person);
        $result = $client->call("ExecuteAction", array($params));

        Thanks in advance.

          what's the actual URL to the webservice?

            you do not need to wrap $params with an array!
            $result = $client->call("ExecuteAction", array($params));
            should be
            $result = $client->call("ExecuteAction", $params);

            Also, you can try wrapping the request around the person:

            <xml>
            <request action="Add">
            <person>
            </person>
            </request>
            </xml>

            OR

            $REQUEST = array("Action=>"Add","Person"=>$person);

              Thanks nanoc.

               I tried as you mention but i found the following error,

              Array
              (
              [faultcode] => soap:Server
              [faultstring] => System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.NullReferenceException: Object reference not set to an instance of an object.
              at TestService.ExecuteAction(ExecuteActionRequest request)
              --- End of inner exception stack trace ---
              [detail] =>
              )

              My code here,

              $person = array('FirstName' => 'Johnny',
              'LastName' => 'Roberts Jr',
              'UserTypeCode' => 'MEM',
              'HomePhone' => '555-555-5555',
              'CellPhone' => '555-555-5555',
              'PasswordHash' => 'dsfadsfasdfasdfasfzxcvcx',
              'PasswordSalt' => 'jrob');

              $REQUEST = array('Action'=>'Add','Person'=>$person);

              $result = $client->call("ExecuteAction", $REQUEST);

              Thanks.

                Sorry I can be of more help. If you go to the webservice, without the ?wsdl, you should see a list of the functions available. If you click on the function name, you should be taken to a page that allows you to test the webservice. If you can copy the information from that page into a text file like you did for the WSDL, i may be able to discern more.

                  Write a Reply...