web services - PHP SoapClient Generating Different Formatted SOAP Request -
so tring connect third party service , having issues in php. when try service request in webservice studio works fine , sent request looks this:
<?xml version="1.0" encoding="utf-16"?> <soap:envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema"> <soap:body> <createuser xmlns="http://ws.example.com"> <arg0 xmlns="">test@test.com</arg0> <arg1 xmlns="">123</arg1> <arg2 xmlns="">1234</arg2> <arg3 xmlns="">1234567890abcdef</arg3> <arg4 xmlns="">test</arg4> <arg5 xmlns="">user</arg5> <arg6 xmlns="">02472</arg6> <arg7 xmlns="">test@test.com</arg7> <arg8 xmlns="">a</arg8> <arg9 xmlns="">0</arg9> <arg10 xmlns="">true</arg10> </createuser> </soap:body> </soap:envelope>
now when try call service php following command:
$this->web_service->createaccount('test@test.com', 123, 1234, '1234567890abcdef', 'test', 'user', '12345', 'test@test.com', 'a', 0, true)
and debugging request, this:
<?xml version="1.0" encoding="utf-8"?> <soap-env:envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://ws.example.com"> <soap-env:body> <ns1:createuser/> <param1>123</param1> <param2>1234</param2> <param3>1234567890abdcef</param3> <param4>test</param4> <param5>user</param5> <param6>12345</param6> <param7>test@test.com</param7> <param8>a</param8> <param9>0</param9> <param10>true</param10> </soap-env:body> </soap-env:envelope>
a few things jump out @ me right away request generated soapclient in php. first thing first parameter (the first time pass test@test.com) not being passed in param1, second parameter is. next thing the request createuser self closing tag not including parameters being pass. whole structure little different tag being used.
i have tried using array (which doesn't go point of throwing request), wrapping params in soapparam, using __call(), , using __soapcall() none of fix issue.
anyone know might fix issue request generated soapclient in php matches 1 generated webservice studio short of manually generate soap request hand?
i having similar problem (with self closing operation tag)
turns out, problem how passing params. definition wsdl of expected parameters follows:
<s:element name="validatestudent"> <s:complextype> <s:sequence> <s:element minoccurs="0" maxoccurs="1" name="studentnumber" type="s:string" /> <s:element minoccurs="0" maxoccurs="1" name="surname" type="s:string" /> <s:element minoccurs="0" maxoccurs="1" name="dob" type="s:string" /> <s:element minoccurs="0" maxoccurs="1" name="clientip" type="s:string" /> <s:element minoccurs="0" maxoccurs="1" name="clientuseragent" type="s:string" /> <s:element minoccurs="0" maxoccurs="1" name="clientreferrer" type="s:string" /> </s:sequence> </s:complextype> </s:element> <wsdl:message name="validatestudentsoapin"> <wsdl:part name="parameters" element="tns:validatestudent" /> </wsdl:message> <wsdl:operation name="validatestudent"> <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">validation of user credentials student portal</wsdl:documentation> <wsdl:input message="tns:validatestudentsoapin" /> <wsdl:output message="tns:validatestudentsoapout" /> </wsdl:operation> <wsdl:operation name="validatestudent"> <soap:operation soapaction="http://test.example.com/validatestudent" style="document" /> <wsdl:input> <soap:body use="literal" /> </wsdl:input> <wsdl:output> <soap:body use="literal" /> </wsdl:output> </wsdl:operation>
so, method, validatestudent() expects 1 parameter (also called validatestudent -- defined in second section) complex type defined in first section.
in case, had pass params follows (as single element, keyed 'validatestudent', sub-elements named defined within wsdl):
$soapparams = array('validatestudent' => array( 'studentnumber' => $stucode, 'surname' => $lastname, 'dob' => $dob, 'clientip' => $ip, 'clientuseragent' => $uagent, 'clientreferrer' => $referer )); $response = $soapclient->__soapcall('validatestudent', $soapparams);
so, basically, make sure understand definition laid out in wsdl you're working with, , follow structure t.
Comments
Post a Comment