I try to call a webservice provided by SAP to update customer data. I used SoapUI for testing the connection and the actual request that is needed. Everything worked fine, this is how the SoapUI request for changing an email address looks like:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:sap-com:document:sap:soap:functions:mc-style">
<soapenv:Header/>
<soapenv:Body>
<urn:Ze12RfcMaintainCustomer>
<!--Optional:-->
<PiTEmail>
<!--Zero or more repetitions:-->
<item>
<StdNo>X</StdNo>
<EMail>me@example.com</EMail>
</item>
</PiTEmail>
<!--Optional:-->
<PiTEmailX>
<!--Zero or more repetitions:-->
<item>
<StdNo>X</StdNo>
<EMail>X</EMail>
</item>
</PiTEmailX>
<PieKunnr>4711</PieKunnr>
</urn:Ze12RfcMaintainCustomer>
</soapenv:Body>
</soapenv:Envelope>
The webservice accepts a whole lot more parameters, but all of them are optional and not needed for this task.
Now if I try to do the same request in PHP with a SoapClient in WSDL mode, I get an error for every optional parameter that is not included in the request, e.g.:
SOAP-ERROR: Encoding: object hasn't 'EmailSrch' property
This is my code (simplified):
$params = array(
'PieKunnr' => 4711,
'PiTEmail' => array(
'item' => array(
'StdNo' => 'X',
'EMail' => 'me@example.com',
),
),
'PiTEmailX' => array(
'item' => array(
'StdNo' => 'X',
'EMail' => 'X',
),
),
);
$result = $service->Ze12RfcMaintainCustomer($params);
If I put all the optional parameters into the request, it works.
Why can optional parameters not be omitted in SoapClient requests?