簡體   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