【问题标题】:Sending a Soap Header with a WSDL Soap Request with PHP使用 PHP 发送带有 WSDL Soap 请求的 Soap 标头
【发布时间】:2009-02-26 05:31:31
【问题描述】:

我对 SOAP 非常陌生,我正在尝试在 PHP 中实现一个使用 ASP.NET Web 服务的快速测试客户端。 Web 服务依赖于包含授权参数的 Soap Header。

在使用 WSDL 时是否可以将 auth 标头与soap 请求一起发送?

我的代码:

php

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

网络服务

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

在这种情况下如何传递 auth 标头?还是我需要做一个低杠杆 __soapCall() 来传递标题?另外,我是否在 PHP 中调用了正确的肥皂调用?

【问题讨论】:

    标签: php asp.net web-services soap


    【解决方案1】:

    您应该能够创建一个标头,然后将其添加到客户端,以便为所有后续请求发送它。您可能需要更改命名空间参数。

    $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

    【讨论】:

      【解决方案2】:
      $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));
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-01-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多