Mert 2973
Mert 2973

Reputation: 37

How to set wsa true and ws addressing true in pure php of soap webservice

$data2=[
        "user_name"=>"****",
        "password"=>"****",
        "customer_num"=>"***",
        "process_num"=>000,
      ];
$wsdl = "https://vbtestservice.vakifbank.com.tr/HesapHareketleri.OnlineEkstre/SOnlineEkstreServis.svc?singleWsdl";
$client =new SoapClient($wsdl,array("trace"=>true,"exceptions"=>0));

$a=$client->__soapCall('GetirDekont', $data2);
echo $client->__getLastResponse();

Result of php : looks like we got no xml document or response

The requested URL was rejected. Please consult with your administrator."

But

enter image description here As shown in the pictures the wdsl is working at he SoapUI but how to implement the options in the pure php or in the laravel framework. Thank you you for helping !!

SoapUI return response this xml:

xmlns:a="http://www.w3.org/2005/08/addressing">
   <s:Header>
      <a:Action s:mustUnderstand="1">
      Peak.Integration.ExternalInbound.Ekstre/ISOnlineEkstreServis/GetirDekontResponse
      </a:Action>
   </s:Header>
   <s:Body>
      <GetirDekontResponse xmlns="Peak.Integration.ExternalInbound.Ekstre">
         <GetirDekontResult 
         xmlns:b="http://schemas.datacontract.org/2004/07/Peak.Integration.ExternalInbound.Ekstre.DataTransferObjects" 
         xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
            <b:IslemKodu>VBD0004</b:IslemKodu>
            <b:IslemAciklamasi>Talimat için dekont bulunamadı.</b:IslemAciklamasi>
            <b:DekontListesi xmlns:c="http://schemas.microsoft.com/2003/10/Serialization/Arrays"/>
         </GetirDekontResult>
      </GetirDekontResponse>
   </s:Body>
</s:Envelope> ```

    

Upvotes: 1

Views: 381

Answers (1)

beginnerDeveloper
beginnerDeveloper

Reputation: 11

I found the solution :) Quote from Alper Yaman, a member of Laravel Turkey group on Facebook.

To set WSA Addressing and add default wsa:To options on SoapClient connection in Laravel, you can follow these steps: You can specify "soap_version" and "features" in the options array when creating the SoapClient object. Example:

$options = array(
'soap_version' => SOAP_1_2,
'features' => SOAP_SINGLE_ELEMENT_ARRAYS
);

$client = new SoapClient($wsdl, $options);

You can set WSA Addressing and add default wsa:To options by editing the headers of the request sent to the SoapClient object. Example:

$headers = array(
new SoapHeader("http://www.w3.org/2005/08/addressing", "Peak.Integration.ExternalInbound.Ekstre/ISOnlineEkstreServis/GetirDekont", $to),
new SoapHeader("http://www.w3.org/2005/08/addressing", "WEB SERVICE LINK ENDING WITH ?WSDL HERE", $action)
);
$client->__setSoapHeaders($headers);

Note: The $to and $action variables are required values for WSA Addressing. After doing these operations, try to connect to the web service with the SoapClient object. If you still get the error, please contact the server's administrator to ensure that the URL is not rejected.

Upvotes: 1

Related Questions