Search code examples
phpsoapwsdlsoap-client

Php SoapClient Soap-Env has 'item' and 'key' nodes


I have a problem calling a partner-soap service with the php SoapClient. His wsdl is https://motrada.net/accounts/test.wsdl

When I send the following data to the php SoapClient

    array (
  'Expert_Status' => 
  array (
    'ChassisNo' => '9998886NZ12345678',
    'MotradaIntVehicleNo' => '757169',
    'MotradaSalesId' => '209448',
    'MotradaWorkflowStatus' => '5-offer_preperation',
    'GrossPriceInclVATAutoi' => '20000',
    'DamageAmountInclVAT' => '1000',
    'MileageExpertise' => '234234',
    'Timestamp' => '2016-05-23T10:14:58+02:00',
  ),
)

The php-SoapClient sends the following request:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Body>
        <Expert-Request>
            <item>
                <key>Expert_Status</key>
                <value>
                    <item>
                        <key>ChassisNo</key>
                        <value>9998886NZ12345678</value>
                    </item>
                    <item>
                        <key>MotradaIntVehicleNo</key>
                        <value>757169</value>
                    </item>
                    ...   
                </value>
            </item>
        </Expert-Request>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

The request should look like this

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Body>
        <Expert_Status>
            <ChassisNo>9998886NZ12345678</ChassisNo>
            <MotradaIntVehicleNo>757169</MotradaIntVehicleNo>
            ...

The options I send to the php SoapClient are:

array (
  'encoding' => 'UTF-8',
  'verifypeer' => false,
  'verifyhost' => false,
  'soap_version' => 'SOAP_1_1',
  'trace' => true,
  'exceptions' => true,
  'connection_timeout' => 10,
  'login' => 'MOTR_ALE',
  'password' => 'XXXXXXXX',
)

can anyone help me to find where the problem is?


Solution

  • Have a close look at the given WSDL file, where it says:

    <wsdl:message name="xmln.Bestand-Request">
        <wsdl:documentation/>
        <wsdl:part xmlns="" name="Bestand-Request" element="Bestand-Request"/>
    </wsdl:message>
    <wsdl:message name="xmln.Bestand-Response">
        <wsdl:documentation/>
        <wsdl:part xmlns="" name="Bestand-Response" element="Bestand-Response"/>
    </wsdl:message>
    <wsdl:message name="xmln.Expert-Request">
        <wsdl:part name="Expert-Request" element="Expert-Request"/>
    </wsdl:message>
    <wsdl:message name="xmln.Expert-Response">
        <wsdl:part name="Expert-Response" element="Expert-Response"/>
    </wsdl:message>
    

    Do you see the difference? In the first two part definitions, there is an empty attribute "xmlns", which is missing in the other part definitions. Extend these parts by this attribute and you should be good to go ;)