phpNusoap client -> php5 Server

Help
Dimas
2009-07-20
2013-06-06
  • Dimas

    Dimas - 2009-07-20

    Hello!

    I've created a WS Linux server with php5 native libraries, and I tried it with a native php5 WS client and it works ok. Now I've to consume it with a Windows php 4.x server, so I've created a WS client using the phpNusoap library. There is no apparent error, but no parameters are arriving to the server I paste the code, someone can help me?

    Server | WSDL

    Code:

    <?xml version='1.0' encoding='UTF-8' ?>
    <definitions name='FormularisCDR'
      targetNamespace='urn:FormularisCDR'
      xmlns:tns='urn:FormularisCDR'
      xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
      xmlns:xsd='http://www.w3.org/2001/XMLSchema'
      xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/'
      xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
      xmlns='http://schemas.xmlsoap.org/wsdl/'>

    <message name='novaPeticioAlergiaRequest'>
      <part name='numcolegiat' type='xsd:string'/>
    </message>
    <message name='novaPeticioAlergiaResponse'>
      <part name='Result' type='xsd:boolean'/>
    </message>

    <portType name='FormularisCDRPortType'>
      <operation name='novaPeticioAlergia'>
        <input message='tns:novaPeticioAlergiaRequest'/>
        <output message='tns:novaPeticioAlergiaResponse'/>
      </operation>
    </portType>

    <binding name='FormularisCDRBinding' type='tns:FormularisCDRPortType'>
      <soap:binding style='rpc'
        transport='http://schemas.xmlsoap.org/soap/http'/>
      <operation name='novaPeticioAlergia'>
        <soap:operation soapAction='urn:xmethods-delayed-quotes#novaPeticioAlergia'/>
        <input>
          <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes'
            encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
        </input>
        <output>
          <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes'
            encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
        </output>
      </operation>
    </binding>

    <service name='FormularisCDRService'>
      <port name='FormularisCDRPort' binding='FormularisCDRBinding'>
        <soap:address location='http://zeus.trueta.intranet/soap/formularisCDR/formularisCDR.php'/>
      </port>
    </service>
    </definitions>

    Server | Class

    Code:

    require 'formularisCDR_classe.php';

    ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache

    $server = new SoapServer("http://zeus.trueta.intranet/soap/formularisCDR/formularisCDR.wsdl");
    $server->setClass("formularisCDR_classe");
    $server->handle();

    class formularisCDR_classe {
       function novaPeticioAlergia($numcolegiat) {
          throw new SoapFault("Server",$numcolegiat); // $numcolegiat is empty with phpNusoap client
          /*
                       code not working because $numcolegiat is empty with the phpNusoap client
                    */
       }
    }

    Client | phpNusoap (not working)

    Code:

    $client = new nusoap_client('http://zeus.trueta.intranet/soap/formularisCDR/formularisCDR.wsdl', 'wsdl');
    $err = $client->getError();
    if ($err)
    echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
    $param = array('numcolegiat' => 'test');
    $result = $client->call('novaPeticioAlergia', array($param));

    Client | php5 (working)

    Code:

    ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache

    $client = new SoapClient("http://zeus.trueta.intranet/soap/formularisCDR/formularisCDR.wsdl");

    try {
       echo "<pre>\n";
       $return = $client->novaPeticioAlergia("example");
       echo utf8_decode($return);
       echo "\n";
       echo "\n</pre>\n";
    }
    catch (SoapFault $exception) {
       echo $exception;    
    }

     
  • Anonymous

    Anonymous - 2009-11-13

    I know the thread's old but, here's my .20

    after declaring:

        $client = new SoapClient(……)
        try{
            echo "<pre>\n";
       
    You should instead, use:

        $client = new nusoap_client('WSDL_URL_GOES_HERE', "true");
        try{
            echo "<pre>\n";

    oh and before you call a method, you should also be aware that you have to call the proxy, like this:

        $proxy = $client->getProxy();
        $yourResult = $proxy->RegisteredWSMethodGoesHere("Some_Argument_If_Needed");

    Hope this helps somene…

    Carlos

     

Log in to post a comment.