1

It's my first time with SOAP, I already read all manuals and still stacked with the following example:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"   
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Header>
    <AuthenticationInfo xmlns="https://blabla.com/ws/Quoting">
      <strUserName>[username]</strUserName>
       <strPassword>[password]</strPassword>
   </AuthenticationInfo>
 </soap:Header>
 <soap:Body>
    <GetQuotes xmlns="https://blabla.com/ws/Quoting">
      <CallerClientID>0</CallerClientID>
          <quoteRequest>
            <CapacityCode>2</CapacityCode>
           <BabiesCount>0</BabiesCount>
           <QuotingOptions>0</QuotingOptions>
         </quoteRequest>
      <clientIDs>
        <int>20295</int>
      </clientIDs>
      <withUrlParam>false</withUrlParam>
    </GetQuotes>
  </soap:Body>
</soap:Envelope>

I do not understand how to start the soapclient with authorization, please help.

1 Answer 1

1

You need to use SoapHeader. Below is the example.

$ns = 'https://blabla.com/ws/Quoting'; //Namespace of the WS. 

//Body of the Soap Header. 
$headerbody = array('strUserName' => $someUser, 
                    'strPassword' => $somePass); 

//Create Soap Header.        
$header = new SOAPHeader($ns, 'AuthenticationInfo', $headerbody);        

//set the Headers of Soap Client. 
$soap_client->__setSoapHeaders($header); 
Sign up to request clarification or add additional context in comments.

2 Comments

just tell me how, i`m newbe here ))
a green V on the left?

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.