So I'm trying to consume a WSDL generated by C# .NET application using PHP. I've ran into multiple issues and have worked my way up to this point where I cannot seem to find the next thing to do.
I'm using SOAP 1.2 to prevent the text/xml
error from happening ( expected type application/soap+xml
), whereas SOAP 1.2 is accepted by the application as text/xml
.
The error I receive now is:
[message:protected] => The SOAP action specified on the message, '', does not match the HTTP SOAP Action, 'http://tempuri.org/IMembership/AcquireSecurityToken'.
I'm a little worried why it is not detected any action from my end ( ''
) but I have no clue what I'm doing wrong or what I should be approaching differently.
Underneath you'll find most of the relevant code involved in trying to get this to work for now.
$params = array("soap_version"=> SOAP_1_2,
"trace"=>1,
"exceptions"=>1,
);
$client = new SoapClient("http://removed.for.now/Membership.svc?wsdl", $params);
$actionHeader = new SoapHeader('http://www.w3.org/2005/08/addressing','AcquireSecurityToken', 'http://tempuri.org/IMembership/AcquireSecurityToken',true);
$client->__setSoapHeaders($actionHeader);
$args = array("username"=>"user", "password"=>"goodpw");
try {
$result = $client->AcquireSecurityToken($args);
} catch(Exception $e) {
echo "<h1>Last request</h1>";
// print_r the error report. Omitted for clarity.
}
Any tips or suggestions? Things I'm not doing right or should be trying differently?
I figured it out with the help of some lovely people on IRC.
The ActionHeader that I tried to add using $actionHeader
was close, but not correct.
$actionHeader = new SoapHeader('http://www.w3.org/2005/08/addressing', 'Action', 'http://tempuri.org/IMembership/AcquireSecurityToken');
$client->__setSoapHeaders($actionHeader);
Did the trick.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.