Search code examples
phpsoapsoap-client

How to remove attribute from envelope in SoapClient


Trying to use PHP-s own SoapClient, but I have come across an obstacle.

I'm using __soapCall for making requests, but the query fails, because encodingStyle attribute is set:

$client = new SoapClient(NULL, array(
    'location' => 'http://myUri.com', 
    'uri' => 'http://namespace.com/producer'
));

$result = $client->__soapCall('GET_ALL');

Now doing $client->__getLastRequest(); shows Envolope node like this:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"     
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> 

How to remove SOAP-ENV:encodingStyle attribute and still use __soapCall(); ?


Solution

  • Apperantly I was missing "use" parameter in SoapClient construct. Solution:

    $client = new SoapClient(NULL, array(
        'location' => 'http://myUri.com', 
        'uri' => 'http://namespace.com/producer',
        'use' => SOAP_LITERAL,
    ));