SOAP

PHP SOAP is much easier after one simple example …

no wsdl …

  • try it (click me) — running on Yips IBM i machine
    • view client.php (click me) — client generic soap call __soapCall() try it (click me)
      $client = new SoapClient(null, array(
        'location' => "http://174.79.32.155/Samples/SOAP_demo/server.php",
        'uri'      => "urn:urn://174.79.32.155",
        'trace'    => 1 ));
      $return = $client->__soapCall("findLength",array("hi soap me"));
      
    • view clientmethod.php (click me) — client method name soap call findLength() try it (click me)
      $client = new SoapClient(null, array(
        'location' => "http://174.79.32.155/Samples/SOAP_demo/server.php",
        'uri'      => "urn:urn://174.79.32.155",
        'trace'    => 1 ));
      $return = $client->findLength("hi soap me");
      
    • view server.php (click me)
      function findLength($string) {
        return strlen($string);
      }
      $server = new SoapServer(null, array('uri' => "urn://174.79.32.155"));
      $server->addFunction("findLength"); 
      $server->handle();
      

with wsdl …

  • try it (click me) — running on Yips IBM i machine
    • view clientwsdl.php (click me) — using wsdl file ohmy.wsdl try it (click me)
      ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache 
      $client = new SoapClient("http://174.79.32.155/Samples/SOAP_demo/ohmy.wsdl",array('trace' => 1));
      $return = $client->__soapCall("findLength",array("hi soap me"));
      
    • view serverwsdl.php (click me)
      function findLength($string) {
        return strlen($string);
      }
      ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache 
      $server = new SoapServer("http://174.79.32.155/Samples/SOAP_demo/ohmy.wsdl");
      $server->addFunction("findLength"); 
      $server->handle();
      
    • view ohmy.wsdl (click me)
      <message name='findLengthRq'>
        <part name='string' type='xsd:string'/>
      </message>
      <message name='findLengthRs'>
        <part name='count' type='xsd:integer'/>
      </message>
      
      <portType name='serverwsdlPortType'>
        <operation name='findLength'>
          <input message='tns:findLengthRq'/>
          <output message='tns:findLengthRs'/>
        </operation>
      </portType>