Hi All,
I need to call some webservice functions, I need my request will have format:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://SureClose.com/Services/v1" xmlns:ns2="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<SOAP-ENV:Header>
<wsse:Security SOAP-ENV:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>username</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">password</wsse:Password>
<wsse:Nonce>E0IYJ2Y=</wsse:Nonce>
<wsu:Created xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2009-11-04T17:00:57Z</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<v1:FunctionName>
<v1:request>
<sur:param1>value1</sur:param1>
<sur:param2>true</sur:param2>
</v1:request>
</v1:FunctionName>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
So i coded:
$url = 'https://staging.sclintegrations.com/services.wsdl';
$client = new SoapClient($url);
$username = 'username';
$password = 'pass';
$timestamp = gmdate('Y-m-d\TH:i:s\Z');
$nonce = mt_rand(); //A random word. The use of rand() may repeat the word if the server is very loaded.
$passdigest = base64_encode(pack('H*',sha1(pack('H*',$nonce).pack('a*',$timestamp).pack('a*',$password))));
$auth = '<wsse:Security SOAP-ENV:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>'.$username.'</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">'.$password.'</wsse:Password>
<wsse:Nonce>'.base64_encode(pack('H*',$nonce)).'</wsse:Nonce>
<wsu:Created xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">'.$timestamp.'</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>';
$authvalues = new SoapVar($auth, XSD_ANYXML);
$header = new SoapHeader("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "Security", $authvalues, true);
$client->__setSoapHeaders($header);
//call functions
$param= array('param1'=>'value1','param2'=>'value2');
$resObj= $client->FunctionName($param);
but server always return null value and server error code, otherwise I try to use testing tool it return value with the same parameter and value.
Could you please give me some idea.
Thanks for your supporting.