[英]How to call SOAP wsdl with header parameters in Laravel 5.3?
我使用artisaninweb/laravel-soap
包來運行SOAP wsdl文件。 為了解析WSDL文件,我需要將它與頭參數一起調用。 換句話說,首先我需要設置標頭參數,然后將其與此參數一起調用。 在我的laravel代碼中,它是這樣的:
$customHeader1 = new SoapHeader('Accept-Encoding','gzip,deflate'); // <!-- The custom header 1
$customHeader2 = new SoapHeader('Content-Type', 'text/xml;charset=UTF-8'); // <!-- The custom header 2
$customHeader3 = new SoapHeader('SOAPAction', '"urn:sap-com:document:sap:soap:functions:mc-style:yws_check_fincode:YcheckFincodeRequest"');
$customHeader4 = new SoapHeader('Content-Length','346');
$customHeader5 = new SoapHeader('Host','host');
$customHeader6 = new SoapHeader('Connection',' Keep-Alive');
$customHeader7 = new SoapHeader('User-Agent',' Apache-HttpClient/4.1.1 (java 1.5)');
SoapWrapper::add(function ($service) use($customHeader1,$customHeader2,$customHeader3,$customHeader4,$customHeader5,$customHeader6,$customHeader7) {
$service
->name('myapp')
->wsdl('http://wsdl_url')
//->header($namespace,$name,$data,$mustunderstand,$actor)
->customHeader($customHeader1)
->customHeader($customHeader2)
->customHeader($customHeader3)
->customHeader($customHeader4)
->customHeader($customHeader5)
->customHeader($customHeader6)
->customHeader($customHeader7)
;
});
SoapWrapper::service('myapp', function ($service) {
print_r($service->getFunctions());
});
我可以在SOAP ui中完美地調用WSDL文件。 但是當我運行我的laravel代碼時它不起作用。 SOAP UI中的標題就像那樣(即圖像下方) 。 如何將這些標題添加到我的laravel代碼中?:
或者我的laravel代碼有什么問題?
$ ns =' http://namespace.example.com/ '; // WS的命名空間。
//Body of the Soap Header.
$headerbody = array('Accept-Encoding' => 'gzip,deflate',
'Content-Type' => 'text/xml;charset=UTF-8',
'SOAPAction'=> "urn:sap-com:document:sap:soap:functions:mc-style:yws_check_fincode:YcheckFincodeRequest",
'Content-Length', '346',
'Host'=> 'host',
'Connection' => 'Keep-Alive',
'User-Agent' => ' Apache-HttpClient/4.1.1 (java 1.5)'
);
//Create Soap Header.
$myheader = new SOAPHeader($ns, 'RequestorCredentials', $headerbody);
SoapWrapper::add(function ($service) use($myheader) {
$service
->name('myapp')
->wsdl('http://wsdl_url')
->customHeader($myheader);
});
嘗試使用上面的代碼,沒有使用您的代碼進行測試,它應該工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.