繁体   English   中英

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

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

所以我试图使用由 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);

做到了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM