I'm having some trouble creating a connection from a PHP app to a .NET web service. I've read on quite a few websites what to do but I cannot seem to make it work.
The web service requires a username and password and all I am trying to do is to get some user profile data in a user data management system by sending the user's ID.
This is what the provider says the SOAP request should look like:
POST /feed30/clientdataservice.asmx HTTP/1.1
Host: ws-ic-pilot.acme.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "GetUser"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetUser xmlns="urn:Acme:ClientDataService">
<strUserId>string</strUserId>
</GetUser>
</soap:Body>
</soap:Envelope>
Here's the code I have written based on what I found on various sites on the internet:
$client = new SoapClient('https://ws-ic-pilot.acme.com/feed30/clientdataservice.asmx
WSDL',Array("trace" => 1));
$header = new SoapHeader(
array(
'UserName' => 'myusername',
'Password' => 'mypassword',
'strUserID' => '12345'
) );
$client->__setSoapHeaders($header);
$client->GetUser();
When I used __getLastRequestHeaders and __getLastRequest the SOAP message that I am creating looks like this:
POST /feed30/clientdataservice.asmx HTTP/1.1
Host: ws-pilot.acme.com
Connection: Keep-Alive
User-Agent: PHP-SOAP/5.3.21
Content-Type: text/xml; charset=utf-8
SOAPAction: "GetUser"
Content-Length: 247
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="urn:Acme:ClientDataService"><SOAP-ENV:Header/>
<SOAP-ENV:Body><ns1:GetUser/>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
When I post the SOAP message to the .NET server I get the following response:
<ExceptionInfo>Exception Message: Security requirements are not satisfied because the
security header is not present in the incoming message.;Exception Target Method:
ValidateMessageSecurity</ExceptionInfo></detail>
</soap:Body></soap:Envelope>
Can anyone provide a suggestion/recommendation as to how I fix this issue?
Thanks in advance for your assistance!