我的PHP中的SOAP客户端存在问题,我认为我的请求是正确的。
我的PHP客户端SOAP:
$soapURL = "http://mylink.fr/mywsdl?wsdl";
$soapParameters = Array('login' => "MyLogin", 'password' => "MyPassword", 'trace' => 1);
try {
$service=new SoapClient($soapURL, $soapParameters);
$request = array(
'address' => array(
'city' => '',
'country' => '',
'department' => '',
'district' => '',
'houseNumber' => '',
'region' => '',
'road' => '',
'roadNumber' => '',
'zipCode' => ''
),
'category' => array(
'logo' => '',
'name' => '',
'reference' => ''
),
'companyName' => '',
'contactMail' => '',
'contactName' => '',
'contactPhone' => '',
'endTemporary' => '2015-02-15T13:00:10',
'latitude' => 12.0,
'longitude' => 12.0,
'name' => '',
'radius' => 520,
'reference' => '',
'startTemporary' => '2015-02-15T13:00:11',
'temporary' => 0
);
$result = $service->createPOI($request);
} catch(SoapFault $e) {
echo $service->__getLastRequest();
echo $e->__toString();
}
我的SOAP请求:
<soap-env:envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://ws.webservices.masternaut.fr/MasterWS/services/POI" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns2="urn:POI" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" soap-env:encodingstyle="http://schemas.xmlsoap.org/soap/encoding/">
<soap-env:body>
<ns1:createpoi>
<poi xsi:type="ns2:POI">
<address xsi:type="ns2:Address">
<city xsi:type="xsd:string"></city>
<country xsi:type="xsd:string"></country>
<department xsi:type="xsd:string"></department>
<district xsi:type="xsd:string"></district>
<housenumber xsi:type="xsd:string"></housenumber>
<region xsi:type="xsd:string"></region>
<road xsi:type="xsd:string"></road>
<roadnumber xsi:type="xsd:string"></roadnumber>
<zipcode xsi:type="xsd:string"></zipcode>
</address>
<category xsi:type="ns2:PoiCategory">
<logo xsi:type="xsd:string"></logo>
<name xsi:type="xsd:string"></name>
<reference xsi:type="xsd:string"></reference>
</category>
<companyname xsi:type="xsd:string"></companyname>
<contactmail xsi:type="xsd:string"></contactmail>
<contactname xsi:type="xsd:string"></contactname>
<contactphone xsi:type="xsd:string"></contactphone>
<endtemporary xsi:type="xsd:dateTime">2015-02-15T13:00:10</endtemporary>
<latitude xsi:type="xsd:double">12</latitude>
<longitude xsi:type="xsd:double">12</longitude>
<name xsi:type="xsd:string"></name>
<radius xsi:type="xsd:int">520</radius>
<reference xsi:type="xsd:string"></reference>
<starttemporary xsi:type="xsd:dateTime">2015-02-15T13:00:11</starttemporary>
<temporary xsi:type="xsd:boolean">false</temporary>
</poi>
<overwrite xsi:nil="true"></overwrite>
</ns1:createpoi>
</soap-env:body>
</soap-env:envelope>
WSDL:
<complexType name="PoiCategory">
<sequence>
<element name="logo" nillable="true" type="xsd:string"/>
<element name="name" nillable="true" type="xsd:string"/>
<element name="reference" nillable="true" type="xsd:string"/>
</sequence>
</complexType>
<complexType name="Address">
<sequence>
<element name="city" nillable="true" type="xsd:string"/>
<element name="country" nillable="true" type="xsd:string"/>
<element name="department" nillable="true" type="xsd:string"/>
<element name="district" nillable="true" type="xsd:string"/>
<element name="houseNumber" nillable="true" type="xsd:string"/>
<element name="region" nillable="true" type="xsd:string"/>
<element name="road" nillable="true" type="xsd:string"/>
<element name="roadNumber" nillable="true" type="xsd:string"/>
<element name="zipCode" nillable="true" type="xsd:string"/>
</sequence>
</complexType>
<complexType name="POI">
<sequence>
<element name="address" nillable="true" type="tns1:Address"/>
<element name="category" nillable="true" type="tns1:PoiCategory"/>
<element name="companyName" nillable="true" type="xsd:string"/>
<element name="contactMail" nillable="true" type="xsd:string"/>
<element name="contactName" nillable="true" type="xsd:string"/>
<element name="contactPhone" nillable="true" type="xsd:string"/>
<element name="endTemporary" nillable="true" type="xsd:dateTime"/>
<element name="latitude" type="xsd:double"/>
<element name="longitude" type="xsd:double"/>
<element name="name" nillable="true" type="xsd:string"/>
<element name="radius" type="xsd:int"/>
<element name="reference" nillable="true" type="xsd:string"/>
<element name="startTemporary" nillable="true" type="xsd:dateTime"/>
<element name="temporary" type="xsd:boolean"/>
</sequence>
</complexType>
<wsdl:portType name="PoiWS">
<wsdl:message name="createPOIRequest">
<wsdl:part name="poi" type="tns1:POI"></wsdl:part>
<wsdl:part name="overwrite" type="xsd:boolean"></wsdl:part>
</wsdl:message>
<wsdl:message name="createPOIResponse">
<wsdl:part name="createPOIReturn" type="xsd:int"></wsdl:part>
</wsdl:message>
</wsdl:portType>
<wsdl:binding name="POISoapBinding" type="impl:PoiWS">
<wsdl:operation name="createPOI">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="createPOIRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://mylink.fr/wsdl" use="encoded"/>
</wsdl:input>
<wsdl:output name="createPOIResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://mylink.fr/wsdl" use="encoded"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="PoiWSService">
<wsdl:port binding="impl:POISoapBinding" name="POI">
<wsdlsoap:address location="http://mylink.fr/wsdl"/>
</wsdl:port>
</wsdl:service>
我收到此错误:
SoapFault exception: [Server.userException] No such operation 'createPOI' in /var/www/devt/cronJobs/test.php:58
Stack trace: #0 /var/www/devt/cronJobs/test.php(58): SoapClient->__call('createPOI', Array)
#1 /var/www/devt/cronJobs/test.php(58): SoapClient->createPOI(Array)
#2 {main}
你能告诉我我的问题在哪里解释一下吗?
我是SOAP的初学者
提前致谢
答案 0 :(得分:0)
查看WSDL,您的请求应该是这样的:
$request = array(
'address' => array(
'city' => '',
'country' => '',
'department' => '',
'district' => '',
'houseNumber' => '',
'region' => '',
'road' => '',
'roadNumber' => '',
'zipCode' => ''
),
'category' => array(
'logo' => '',
'name' => '',
'reference' => ''
),
'POI' => array(
'companyName' => '',
'contactMail' => '',
'contactName' => '',
'contactPhone' => '',
'endTemporary' => '2015-02-15T13:00:10',
'latitude' => 12.0,
'longitude' => 12.0,
'name' => '',
'radius' => 520,
'reference' => '',
'startTemporary' => '2015-02-15T13:00:11',
'temporary' => 0
)
);
答案 1 :(得分:0)
如果您想了解wsdl支持的操作,请始终在wsdl中查找端口类型。
wsdl中的portType就像java中的类一样,可以有多个&#34;操作&#34;或者在java&#34;方法&#34;。
的世界您的wsdl有一种端口类型,即PoiWS,但我无法看到其中添加的任何操作。虽然你的绑定引用了PoiWS porttype,它应该具有操作createPOI,
<wsdl:binding name="POISoapBinding" type="impl:PoiWS">
<wsdl:operation name="createPOI">
请更正你的wsdl .. 例如,portType应该如下所示,
<wsdl:portType name="TestPortType">
<wsdl:operation name="operationName">
<wsdl:input name="input" message="tns:input"/>
<wsdl:output name="output" message="tns:output"/>
</wsdl:operation>
</wsdl:portType>