PHP SoapClient Creating a Different Formatted SOAP Request

So, I'm trying to connect to a third-party service and have some problems with it in PHP. When I try to execute a service request in WebService Studio, it works fine, and the sent request looks like 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 I try to call a service from PHP with the following command:

$this->web_service->createAccount('test@test.com', 123, 1234, '1234567890abcdef', 'test', 'user', '12345', 'test@test.com', 'A', 0, true)

and debugging the request, I get the following:

<?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 moments will jump at me with a request created by SoapClient in PHP. Firstly, the first parameter (the first time I pass test@test.com ) is not passed to param1, the second parameter. The next thing is the createUser request - this is a self-closing tag that does not contain any passed parameters. Then, obviously, the whole structure is slightly different from the tag used.

( ), params SoapParam, __call() __soapCall(), .

- , , , SoapClient PHP, , WebService Studio, ?

+3
2

( )

, , . wsdl :

<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 to 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>

, ValidateStudent() ( ValidateStudent - ), , .

( , "ValidateStudent", , wsdl):

$soapParams = array('ValidateStudent' => array(
    'studentNumber'     => $stuCode,
    'surname'           => $lastName,
    'dob'               => $dob,
    'clientIP'          => $ip,
    'clientUserAgent'   => $uAgent,
    'clientReferrer'    => $referer
));

$response = $soapClient->__soapCall('ValidateStudent', $soapParams);

, , , , wsdl, , T.

+6

,

$this->webService->createAccount(array('arg0'=>'test@test.com')...);

__ soapCall

0

Source: https://habr.com/ru/post/1794183/


All Articles