У меня проблема с моим клиентом SOAP на PHP, я думаю, что мой запрос правильный.
Мой 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
заранее спасибо
Глядя на 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
)
);
Всегда ищите тип порта в wsdl, если вы хотите знать, какие операции поддерживает ваш wsdl.
portType в wsdl подобен классу в java, который может иметь несколько «операций» или в мире java «методов».
Ваш wsdl имеет один тип порта, то есть PoiWS, но я не вижу никакой операции, добавленной в него. Пока ваша привязка ссылается на тип порта PoiWS, который должен иметь операцию 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>