2009-02-26 41 views
3

私はSOAPについて非常に新しいので、PHPでASP.NET Webサービスを使用するクイックテストクライアントを実装しようとしています。 Webサービスは、承認パラメータを含むSoapヘッダーに依存しています。SOAPでSOAP SOAPリクエストを使用してSOAPを送信する

WSDLを使用しているときにSOAPヘッダーとともにauthヘッダーを送信することはできますか?

マイコード:

PHP

$service = new SoapClient("http://localhost:16840/CTI.ConfigStack.WS/ATeamService.asmx?WSDL"); 
$service->AddPendingUsers($users, 3); // Example 

Webサービス認証ヘッダは、この文脈で渡される方法

[SoapHeader("AuthorisationHeader")] 
[WebMethod] 
public void AddPendingUsers(List<PendingUser> users, int templateUserId) 
{ 
    ateamService.AddPendingUsers(users, templateUserId, AuthorisationHeader.UserId); 
} 

?または、ヘッダーを渡すために低いレバー__soapCall()を行う必要がありますか?また、私はPHP内で正しい石鹸呼び出しを呼びますか?

答えて

6

ヘッダーを作成してクライアントに追加して、以降のすべての要求に対して送信できるようにする必要があります。おそらく名前空間パラメータを変更する必要があります。

$service = new SoapClient("http://localhost:16840/CTI.ConfigStack.WS/ATeamService.asmx?WSDL"); 
//      Namespace    Header Name   value must-understand 
$header = new SoapHeader('http://tempuri.org/', 'AuthorisationHeader', $value, false); 
$service->__setSoapHeaders(array($header)); 

$service->AddPendingUsers($users, 3); // Example 

詳しい情報here

3
$client = new SoapClient(PassportWebService); 
$apiauth =array('userName'=>HeaderName,'password'=>HeaderPassport,'ip'=>$onlineip); 

$authvalues = new SoapVar($apiauth, SOAP_ENC_OBJECT,'ReqHeader',"SoapBaseNameSpace"); 
$header = new SoapHeader("SoapBaseNameSpace","ReqHeader", $authvalues, true); 
$client->__setSoapHeaders(array($header)); 
関連する問題