给定wsdl的php webservices服务器客户端

时间:2019-03-26 10:45:12

标签: php soap wsdl

我正在尝试从给定的wsdl文件开发Web服务。

我已经编写了服务器和客户端代码。请有人能帮我说说我是否正确吗?

从客户那里我不知道我是否收到正确答案。

Thx 这是服务器代码

<?php
    ini_set("soap.wsdl_cache_enabled","0");
    class getTryPing
    {
        public $arg0;

    }

    $server=new SoapServer("WSDL/TryPingService.xml");
    $server->addFunction('getTryPing');
    $server->handle();
    function getTryPing()
    {
        $esito=new getTryPing();
        $esito ->esito= 1;
        return $esito;
    }
?>

客户

<?php
    ini_set('soap.wsdl_cache_enabled',0);
    ini_set('soap.wsdl_cache_ttl',0);
    $client = new SoapClient(
        dirname(__FILE__) . '/WSDL/TryPingService.xml');
        //$response = $client->getTryPing(1);
        $response = $client->getTryPing();
        var_dump($response);
?>

这是wsdl

<definitions name='TryPingService' targetNamespace='http://tryPing.integrazione.laitspa.it/' xmlns='http://schemas.xmlsoap.org/wsdl/' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:tns='http://tryPing.integrazione.laitspa.it/' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
 <types>
  <xs:schema targetNamespace='http://tryPing.integrazione.laitspa.it/' version='1.0' xmlns:tns='http://tryPing.integrazione.laitspa.it/' xmlns:xs='http://www.w3.org/2001/XMLSchema'>
   <xs:element name='getTryPing' type='tns:getTryPing'/>
   <xs:element name='getTryPingResponse' type='tns:getTryPingResponse'/>
   <xs:complexType name='getTryPing'>
    <xs:sequence>
     <xs:element minOccurs='0' name='arg0' type='tns:tryPingRequest'/>
    </xs:sequence>
   </xs:complexType>
   <xs:complexType name='tryPingRequest'>
    <xs:sequence/>
   </xs:complexType>
   <xs:complexType name='getTryPingResponse'>
    <xs:sequence>
     <xs:element minOccurs='0' name='return' type='tns:tryPingResponse'/>
    </xs:sequence>
   </xs:complexType>
   <xs:complexType name='tryPingResponse'>
    <xs:sequence>
     <xs:element name='esito' type='xs:boolean'/>
    </xs:sequence>
   </xs:complexType>
  </xs:schema>
 </types>
 <message name='TryPingService_getTryPing'>
  <part element='tns:getTryPing' name='getTryPing'></part>
 </message>
 <message name='TryPingService_getTryPingResponse'>
  <part element='tns:getTryPingResponse' name='getTryPingResponse'></part>
 </message>
 <portType name='TryPingService'>
  <operation name='getTryPing' parameterOrder='getTryPing'>
   <input message='tns:TryPingService_getTryPing'></input>
   <output message='tns:TryPingService_getTryPingResponse'></output>
  </operation>
 </portType>
 <binding name='TryPingServiceBinding' type='tns:TryPingService'>
  <soap:binding style='document' transport='http://schemas.xmlsoap.org/soap/http'/>
  <operation name='getTryPing'>
   <soap:operation soapAction=''/>
   <input>
    <soap:body use='literal'/>
   </input>
   <output>
    <soap:body use='literal'/>
   </output>
  </operation>
 </binding>
 <service name='TryPingService'>
  <port binding='tns:TryPingServiceBinding' name='TryPingServicePort'>
   <soap:address location='http://127.0.0.1/ReCup/server.php'/>
  </port>
 </service>
</definitions>

我得到的响应是object(stdClass)#2(0){}

0 个答案:

没有答案