所以我试图使用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.
}
任何提示或建议?我做得不对或应该尝试不同的事情?提前谢谢!
答案 0 :(得分:0)
我在IRC的一些可爱的人的帮助下想出来了。
我尝试使用$actionHeader
添加的ActionHeader很接近,但不正确。
$actionHeader = new SoapHeader('http://www.w3.org/2005/08/addressing', 'Action', 'http://tempuri.org/IMembership/AcquireSecurityToken');
$client->__setSoapHeaders($actionHeader);
诀窍。