所以我正在尝试使用由 C# .NET 应用程序使用 PHP 生成的 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);
做到了。