missing WS-Addressing envelope headers
ocramuni opened this issue · 6 comments
Hi,
I need to send a request like this:
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
<s:Header>
<a:Action mustUnderstand="1">https://www.example.com/API/GetPersonInfoByUserID_Post</a:Action>
<a:MessageID>urn:uuid:73e142a1-df57-4bfe-9caa-aaaaaaaaaaaa</a:MessageID>
<a:ReplyTo>
<a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
</a:ReplyTo>
<a:To mustUnderstand="1">https://yoursite.example.com/services/API.svc/ws</a:To>
</s:Header>
<s:Body>
<GetPersonInfoByUserID_Post xmlns="https://www.example.com/">
<username>username</username>
<password>password</password>
<user_id>a_user</user_id>
</GetPersonInfoByUserID_Post>
</s:Body>
</s:Envelope>
and my code is:
$client = Soap::baseWsdl('https://yoursite.example.com/services/API.svc?Wsdl')
->withWsa()
->withOptions([
'soap_version' => SOAP_1_2,
'trace' => true,
]);
$response = $client->call('GetPersonInfoByUserID_Post', [
'username' => 'username',
'password' => 'password',
'user_id' => 'a_user',
]);
$debug = $client->debugLastSoapRequest();
return $debug;
Actual behavior
I'm using debugLastSoapRequest()
to know the request sent by Laravel:
"request": {
"headers": "",
"body": "
<?xml version=\"1.0\" encoding=\"UTF-8\"?> <env:Envelope xmlns:env=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:ns1=\"https://www.example.com/\">
<env:Body>
<ns1:GetPersonInfoByUserID_Post>
<ns1:username>username</ns1:username>
<ns1:password>password'</ns1:password>
<ns1:user_ide>a_user</ns1:user_id>
</ns1:GetPersonInfoByUserID_Post>
</env:Body>
</env:Envelope>\n"
},
and, as you can see, the WSA envelope headers are missing. I've tried to add header:
->withHeaders(['Content-Type' => 'application/soap+xml; charset="utf-8"; action="https://www.example.com/API/GetPersonInfoByUserID_Post"'])
or:
->withHeaders(['SoapAction' => 'https://www.example.com/API/GetPersonInfoByUserID_Post'])
but I'm not able to get any WSA headers in my request.
The response from the SOAP server is:
The SOAP action specified on the message, '', does not match the HTTP SOAP Action
Am I missing something (I'm a newbie in php/soap world) or is there a problem in withWsa()
function ?
Thanks
Additional information
Laravel v9.42.2
laravel-soap v3.0.2
Good afternoon, I already found a solution to your problem.
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!
Good afternoon, I already found a solution to your problem.
Could you share it with us ? Thanks
Hello!
Do something similar to this
$this->app->singleton('soap', function () {
return Soap::withBasicAuth(config('soap.basic_auth.username'), config('soap.basic_auth.password'))
->withOptions([
'cache_wsdl' => WSDL_CACHE_NONE,
'trace' => true,
'exceptions' => true,
'soap_version' => SOAP_1_1,
'stream_context' => stream_context_create([
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => false,
],
'http' => [
'header' => 'Authorization: Basic '.base64_encode(config('soap.basic_auth.username').':'.config('soap.basic_auth.password')),
'Accept-Encoding' => 'gzip,deflate',
'Content-Type' => 'text/xml;charset=UTF-8',
'SOAPAction' => '',
]]),
])->withWsse([
'privateKeyFile' => Storage::disk('local')->path(config('cifin.private_key')),
'publicKeyFile' => Storage::disk('local')->path(config('cifin.public_key')),
'digitalSignMethod' => SignatureMethod::RSA_SHA256,
'timestamp' => 10000,
'signAllHeaders' => true,
]);
});
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!
Hey there, it's me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Laravel Soap!