Sam Luther
Sam Luther

Reputation: 1190

php SoapClient : param not showing up in request

Why would my param p_oRSMasterFields not be present in the request? Is this request sent back from the soap server, could it be that the server rejects the data for that particular param and just blanks it out?

$client = new SoapClient($wsdl, $options);     

$client->UpdateCustMaster(array('p_iCompanyID' => 100, 
                               'p_lAccountNum' => 18087,   
                               'p_sSysUser' => 'WebTest',     
                               'p_oRSMasterFields' => 'THIS IS A TEST',
                               'p_lErrorCode' => 0
                                ));  

echo "REQUEST:\n" . $client->__getLastRequest() . "\n";  



REQUEST:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.acme.com/">
<SOAP-ENV:Body>
    <ns1:UpdateCustMaster>
        <ns1:p_iCompanyID>100</ns1:p_iCompanyID>
        <ns1:p_lAccountNum>18087</ns1:p_lAccountNum>
        <ns1:p_sSysUser>WebTest</ns1:p_sSysUser>
        <ns1:p_oRSMasterFields/>
        <ns1:p_lErrorCode>0</ns1:p_lErrorCode>
    </ns1:UpdateCustMaster>
</SOAP-ENV:Body>

Upvotes: 0

Views: 2108

Answers (1)

hakre
hakre

Reputation: 197767

Your WSDL goes like that for that item:

<s:complexType>
  <s:sequence>
    <s:any namespace="acme.com/EnergyAPI/CustomerMaint/DSCustomerFields.xsd"/>
  </s:sequence>
</s:complexType>

So you need to give at least one any element in there:

$client->UpdateCustMaster(array('p_iCompanyID' => 100, 
                               'p_lAccountNum' => 18087,   
                               'p_sSysUser' => 'WebTest',     
                               'p_oRSMasterFields' => array('any' => 'THIS IS A TEST'),
                                                      ################################
                               'p_lErrorCode' => 0
                                ));

What happens behind the scene is that the PHP SoapClient class maps the information you pass in form of an array to the types specified in the WSDL. As your original one did not have any any elements/members, it was empty.

Upvotes: 1

Related Questions