PHP SoapClient 尝试使用 C# 生成的 WSDL 并给出错误

PHP SoapClient trying to consume a C# generated WSDL giving errors

所以我正在尝试使用 PHP 使用 C# .NET 应用程序生成的 WSDL。我已经 运行 遇到了多个问题,并且一直努力到现在,我似乎找不到下一步要做的事情。

我正在使用 SOAP 1.2 来防止发生 text/xml 错误 (expected type application/soap+xml),而 SOAP 1.2 被应用程序接受为 text/xml

我现在收到的错误是:

[message:protected] => The SOAP action specified on the message, '', does not match the HTTP SOAP Action, 'http://tempuri.org/IMembership/AcquireSecurityToken'.

我有点担心为什么它没有检测到我的任何动作 ('') 但我不知道我做错了什么或者我应该采取什么不同的方法。

您会在下面找到大部分相关代码,这些代码是为了让这个现在正常工作而涉及的。

$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.
}

有什么提示或建议吗?我做的不对或应该尝试不同的事情?

我在 IRC 上一些可爱的人的帮助下弄明白了。

我尝试使用 $actionHeader 添加的 ActionHeader 接近,但不正确。

$actionHeader = new SoapHeader('http://www.w3.org/2005/08/addressing', 'Action', 'http://tempuri.org/IMembership/AcquireSecurityToken');
$client->__setSoapHeaders($actionHeader);

成功了。