How to get this soap header and syntax in php -
i need achieve following
<soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ret="http://retailexpress.com.au/"> <soapenv:header> <ret:clientheader> <!--optional:--> <ret:clientid>9bf6dd42-35b9-46dd-948a-1c3c91906caa</ret:clientid> <!--optional:--> <ret:username>wsi</ret:username> <!--optional:--> <ret:password>wsipass</ret:password> </ret:clientheader>
what get:
<soap-env:envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://retailexpress.com.au/" xmlns:ns2="namespace"> <soap-env:header> <ns2:clientheader> <ns1:username>wsi</ns1:username> <ns1:password>wsipass</ns1:password> <ns1:clientid>9bf6dd42-35b9-46dd-948a-1c3c91906caa</ns1:clientid> </ns2:clientheader> </soap-env:header>
if change 2 instances of "ns2:clientheader" ns1:clientheader, code works , necessary output. not sure how avoid adding ns2 instead of ns1 in there.
here php code:
<?php $client_id='9bf6dd42-35b9-46dd-948a-1c3c91906caa'; $wsdl_url="http://v2wsisandbox.retailexpress.com.au/dotnet/admin/webservices/v2/webstore/service.asmx?wsdl"; $user='wsi'; $pass='wsipass'; $options_arr=array('trace' => true); $client = new soapclient($wsdl_url, $options_arr); $headerparams = array('ns1:username' => $user, 'ns1:password' => $pass, 'ns1:clientid' => $client_id); $soapstruct = new soapvar($headerparams, soap_enc_object); $header = new soapheader('namespace', 'clientheader', $soapstruct, false); $client->__setsoapheaders($header);
i can't figure out. been trying past few days, searching many posts before here finally. hope guys me do.
thank you.
see comment:
http://www.php.net/manual/en/soapclient.setsoapheaders.php#93460
so like:
$headerbody = array('usernamekey'=>array('username'=>$userid, 'password'=>$pwd)); $header = new soapheader($ns, 'requestorcredentials', $headerbody); //set headers of soap client. $soap_client->__setsoapheaders($header);
Comments
Post a Comment