1

I need to make a SOAP request and get a response back, but I have no idea how SOAP works. I tried to search for it and everything is so confusing.

I need to make an authentication request here like this :

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:dir="http://stellatravelgateway.stellatravelservices.co.uk/DirectoryService">
   <soapenv:Header/>
      <soapenv:Body>
        <dir:Authenticate>
           <!-- Optional: -->
           <dir:authenticateRequest BranchCode="abcde" UserName="user" Password="password" Application="application" Client="?">
           <dir:BranchID>1</dir:BranchID>
        </dir:authenticateRequest>
      </dir:Authenticate>
  </soapenv:Body>
</soapenv:Envelope>

And get an response after that, but have no idea how to do it. I searched and found some similar questions, but can not get any response.

What I am doing is this :

$send = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:dir="http://stellatravelgateway.stellatravelservices.co.uk/DirectoryService">
        <soapenv:Header/>
            <soapenv:Body>
                <dir:Authenticate>
                <!-- Optional: -->
                <dir:authenticateRequest BranchCode="abcde" UserName="user" Password="password" Application="application" Client="?">
                    <dir:BranchID>1</dir:BranchID>
                </dir:authenticateRequest>
            </dir:Authenticate>
        </soapenv:Body>
     </soapenv:Envelope>';


 $soapUrl ="http://devapi.stellatravelgateway.stellatravelservices.co.uk/DirectoryService.svc?singleWsdl";
      $soapClientVar = new SoapClient("http://devapi.stellatravelgateway.stellatravelservices.co.uk/DirectoryService.svc?singleWsdl"); 

 $resp = $soapClientVar->Authenticate($send);

 var_dump($resp);

I know that 99% I totally wrong of what should I do. Can someone please help me understand what exactly should I do and make this SOAP work?

TIA

1 Answer 1

1

The WSDL sets up the SoapClient:

http://devapi.stellatravelgateway.stellatravelservices.co.uk/DirectoryService.svc?singleWsdl

and tells the client what to expect in terms of methods to call on the SOAP service. SoapClient takes care of creating what you see in $send.

Instead of sending raw SOAP (which SoapClient will do for you), you work at the method level. From the WSDL the Authenticate() method takes a parameter of type tns:AuthenticateRequest which contains BranchCode, UserName etc. and returns an object of type tns:AuthenticateResponse, containing tns:ResultBase which contains the actual result Success, Narrative etc.

this might get you towards your solution:

$soapClientVar = new SoapClient("http://devapi.stellatravelgateway.stellatravelservices.co.uk/DirectoryService.svc?singleWsdl"); 
$params = array(
  "BranchCode" => $BranchCode,
  "UserName" => $UserName,
  "Password" => $Password,
  "Application" => $Application,
  "Client" => $Client
);
$response = $soapClientVar->__soapCall("Authenticate", array($params));
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your explanation at least now I get an error back after I tried to catch the error... Is not just a blank page.
This one with that URL ("The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.