passing parameters to webservice in ASP.NET

Help
2006-01-24
2013-06-06
  • Fix the problem that nuSOAP in PHP can not pass parameters to Webservices in ASP.NET 

    I have been fighting this problem for a couple
    of hours, and finally we found out what the
    problem was.

    We have a WEB service built on a ASP.NET
    platform and when I called a helloworld
    example (no arguments) the other side would
    reply as it should.
    But when I tried to access getTime( year,
    month., day ), i.e. with arguments, then it
    failed.

    The reason I am not sure of but the solution
    was to put the methods with arguments in RPC
    format (encoding).

    Hope this will help someone.
    Tobias

    ***********How exactly did you do that?

    I was also facing the same problem. Finally
    figured out the work around which works.

    $s = new soapclient
    ('http://localhost/xService/CustomerData.asmx?
    WSDL', 'wsdl');
    $s->setDefaultRpcParams(true);  // This fixed
    the problem
    $parameters['id'] = 100;
    $soap_proxy = $s->getProxy();

    $result = $soap_proxy->GetCustomer
    ($parameters);
    if (!$err = $soap_proxy->getError()){
        echo 'Result: ' . $result . "\n";
    }
    else{
        echo 'Error: ' . $err . "\n";
    }

    Hope this helps.

     
    • Cenk Uysal
      Cenk Uysal
      2006-01-25

      The problem occurs because .Net constructs a WSDL where all parameters are ComplexType.

      So you have to use Proxy for method calls:

      <?
      require_once('nusoap.php');
         
      $wsdl_url = 'http://localhost/TIM/authUser.asmx?WSDL';
         
      $parameters = array('user' => 'myuser',
                              'pass' => 'mypass');

      $soap_client = new soapclient($wsdl_url,"wsdl");

      $proxy = $soap_client->getProxy();

      $results = $proxy->getUserData($parameters);       
      print_r($results);   

      ?>

       
      • Emin Kuscu
        Emin Kuscu
        2008-08-14

        Thanks Cenk,
        Your post helped me , at least gave me some idea.
        as a result it should be this way. i mean it worked for me.

        my php code is in apache server,
        my server is in asp.net server,
        the project was provided by www.phdcc.com.

        <?php
        require_once('lib/nusoap.php');
        $wsdl_url = 'http://www.myaspdotnetserver.com/findinsite_2/SearchService.asmx?WSDL';
        $soap_client = new nusoap_client($wsdl_url, 'wsdl');
        $req = array( 'SearchRequest' => array(
            'UserParam' => null,
            'HitsFrom' => 0,
            'HitsTo' => 0,
            'HitElems' => "All",
            'SearchFields' => null,
            'Text' => "your search keys"
            ));
        $results = $soap_client->call('Search', $req, 'http://www.phdcc.com/findinsite/', 'http://www.phdcc.com/findinsite/Search', false);
        //the name space and soapaction should not be my domain or any other sub, it should be the domain whoever provides namespace and so
        print_r($results); 
        ?>

         
    • Neelesh
      Neelesh
      2006-05-09

      Hi all,

      I have a similar problem accessing .NET webservices using nusoap, but the solution above also does not work.
      It displays an error when executed:

      <br />
      <b>Parse error</b>:  parse error, unexpected T_STRING in <b>/var/www/html/phpProjects/test/includes/nusoap.php(6983) : eval()'d code</b> on line <b>1</b><br />
      <br />
      <b>Fatal error</b>:  Cannot instantiate non-existent class:  soap_proxy_1720798404 in <b>/var/www/html/phpProjects/test/includes/nusoap.php(6985) : eval()'d code</b> on line <b>1</b><br />

      thanks

       
      • Neelesh
        Neelesh
        2006-05-09

        -- to add above

        can any one help me where i am going wrong?

        thanks

        The error more clear here is:
        Parse error: parse error, unexpected T_STRING in /var/www/html/phpProjects/test/includes/nusoap.php(6983) : eval()'d code on line 1

        Fatal error: Cannot instantiate non-existent class: soap_proxy_1720798404 in /var/www/html/phpProjects/test/includes/nusoap.php(6985) : eval()'d code on line 1

         
        • ctrlaltdl
          ctrlaltdl
          2006-06-22

          Neeleshmb,
          I'm having the same exact error as you.

          If I put "echo $evalStr;" in line 6981 in the getProxy() function it tells me:
          "A proxy can only be created for a WSDL client"

          I haven't figured out a solution to this problem, but I'll be sure to share it if I do.

          Anyone else have this problem or know a solution to it???

           
          • ctrlaltdl
            ctrlaltdl
            2006-06-26

            Ok, I figured it out.  I had to add some parameters to the soapclient->call:

            $objSoapClient->call('HelloWorld', array('myName' => 'Joe'), 'http://tempuri.org', '', true, null, 'rpc', 'literal');