Passing attribute to soap Header

Viewed 81

i am trying to re-create below soap request

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:data="http://test.gbd.chdb.test.net">
       <soapenv:Header>
          <userId>5647775-b7d7-4a45-9570-654116547654</userId>
       </soapenv:Header>
       <soapenv:Body>
          <data:getPerson>
             <!--Optional:-->
             <iin>700521700054</iin>
             <!--Optional:-->
             <consentConfirmed>true</consentConfirmed>
          </data:getPerson>
       </soapenv:Body>
    </soapenv:Envelope>

using below php scrip

$opts = array(some attributes);

        $soap_client = new \SoapClient(null,
                                array(
                                    'location' => 'https://test.test.net/testServices/PersonDetailsImplService',
                                    'uri' => 'http://test.gbd.chdb.test.net',
                                    'login'    => 'XXXXXXX',
                                    'password' => 'YYYYYYY',
                                    'cache_wsdl' => WSDL_CACHE_NONE,
                                    'soap_version'=> SOAP_1_1,
                                    'style' => SOAP_RPC,
                                    'use' => SOAP_ENCODED,
                                    'trace'          => true,
                                    'exceptions'     => true,
                                    'stream_context' => stream_context_create($opts)
                                )
                            );
        $auth = new \stdClass();
            $auth->userId = '5647775-b7d7-4a45-9570-654116547654';
        $header = new \SoapHeader('http://test.gbd.chdb.test.net', 'Header', $auth);

        $soap_client->__setSoapHeaders($header);
        $result = $soap_client->getPerson();

Every time i am executing this i am getting response "userId field is missing". Not sure what am i doing wrong as i am setting Header attribute in my script below and setting headers to my SoapClient via __setSoapHeaders.

Been working on it for few days now and went through tons of articles online - still no go. Any help will be hightly appriciated.

0 Answers
Related