[英]How to pass authentication header for WSDL XML with PHP soap?
我有以下身份驗證 header 要從 php soap 客戶端傳遞
<soap:Header>
<AuthNASoapHeader xmlns="http://example.com/Wholesale">
<ClientName>string</ClientName>
<Password>string</Password>
</AuthNASoapHeader>
</soap:Header> 如何在 PHP soap header 中傳遞這個? 在 WSDL 文件中,我喜歡
<s:element name="AuthNASoapHeader" type="tns:AuthNASoapHeader" />
<s:complexType name="AuthNASoapHeader">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="ClientName" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Password" type="s:string" />
</s:sequence>
<s:anyAttribute />
</s:complexType>
<s:element name="StartFixedLineTest">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="circuitNumber" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
我也想知道通過header認證后如何調用function StartFixedLineTest。 請幫忙
您應該能夠使用以下代碼進行 SOAP 調用(也許您需要一些額外的 Soapoptions)
<?php
$auth = (object)[
'user' => 'username',
'password' => 'password'];
$authHeader = new SoapHeader('namespace','AuthNASoapHeader', $auth);
$soapClient = new SoapClient('http://localhost:44333/SoapService.com?wsdl');
$soapClient->__setSoapHeaders($authHeader);
$return = $soapClient->__soapCall('StartFixedLineTest',[
'parameters' => [
'circuitNumber' => 'SomeNumber'
]
]);
var_dump($return);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.