Reputation: 96
I've a problem with my SOAP Client in PHP, I think my request is correct.
My PHP Client 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();
}
My SOAP Request :
<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>
The 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>
I'm getting this error :
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}
Can you say me where is my problem and explain me ?
I'm a beginner with SOAP
Thanks in advance
Upvotes: 0
Views: 2086
Reputation: 1743
Always look for Port type in wsdl if you want to know, what are the operations supported by your wsdl.
portType in wsdl is just like class in java which can have multiple "operations" or in world of java "methods".
Your wsdl has one port type i.e. PoiWS but i can't see any operation added in it. While your binding referring to PoiWS porttype which should have operation createPOI,
<wsdl:binding name="POISoapBinding" type="impl:PoiWS">
<wsdl:operation name="createPOI">
Please correct your wsdl.. For example portType should look like this,
<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>
Upvotes: 0
Reputation: 1075
Looking at the WSDL, your request should be something like this:
$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
)
);
Upvotes: 0