0

I have one SOAP WSDL api and i have a test api access.

My SOAP Url : https://development.avinode.com/avinode/AvinodeIntegrationWeb/ws/EmptyLegFlightDemand.ws?wsdl

i need to call and get the details from this url. i must send my username and password into this api call. so i tried to build the code. the code is given below.

    <?php  
$soapUrl='https://development.avinode.com:443/avinode/AvinodeIntegrationWeb/ws/EmptyLegDownload.ws?wsdl';
$xml_post_string='<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <S:Header>
        <To xmlns="http://www.w3.org/2005/08/addressing">https://development.avinode.com/avinode/AvinodeIntegrationWeb/ws/EmptyLegDownload.ws</To>
        <Action xmlns="http://www.w3.org/2005/08/addressing">http://www.avinode.com/integration/EmptyLegDownload#request</Action>
        <ReplyTo xmlns="http://www.w3.org/2005/08/addressing">
            <Address>http://www.w3.org/2005/08/addressing/anonymous</Address>
        </ReplyTo>
        <FaultTo xmlns="http://www.w3.org/2005/08/addressing">
            <Address>http://www.w3.org/2005/08/addressing/anonymous</Address>
        </FaultTo>
        <MessageID xmlns="http://www.w3.org/2005/08/addressing">uuid:6a456287-923e-458e-9ccb-f900307f2b0f</MessageID>
        <wsse:Security S:mustUnderstand="1">
            <wsu:Timestamp xmlns:ns13="http://www.w3.org/2003/05/soap-envelope" xmlns:ns14="http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512" wsu:Id="_1">
                <wsu:Created>2014-10-17T15:45:42Z</wsu:Created>
                <wsu:Expires>2014-10-17T15:50:42Z</wsu:Expires>
            </wsu:Timestamp>
            <wsse:UsernameToken xmlns:ns13="http://www.w3.org/2003/05/soap-envelope" xmlns:ns14="http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512" wsu:Id="uuid_2da8da35-1c69-4f38-9899-ba6950c825f5">
                <wsse:Username>MY_USERNAME</wsse:Username>
                <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">PASSWORD</wsse:Password>
            </wsse:UsernameToken>
        </wsse:Security>
    </S:Header>
    <S:Body>
        <ns3:request xmlns="http://www.avinode.com/core/CommonTypes" xmlns:ns2="http://www.avinode.com/services/EmptyLegDownload" xmlns:ns3="http://www.avinode.com/integration/EmptyLegDownload">
            <ns2:product>
                <name>osiz</name>
                <version>1.0</version>
            </ns2:product>
            <ns2:domain>http://flightcomparision.osiztechnologies.com</ns2:domain>
            <ns2:locale>en_US</ns2:locale>
            <ns2:currency>USD</ns2:currency>
            <ns2:region>AMERICA</ns2:region>
            <ns2:after>2014-11-01T00:00:00Z</ns2:after>
            <ns2:before>2014-12-01T00:00:00Z</ns2:before>
            <ns2:pax>1</ns2:pax>
            <ns2:excludeBrokers>false</ns2:excludeBrokers>
            <ns2:requireTailNumber>false</ns2:requireTailNumber>
        </ns3:request>
    </S:Body>
</S:Envelope>';




   $headers = array( 
   "Content-Type: text/xml;charset=UTF-8", 
   "Accept: gzip,deflate", 
   "Cache-Control: no-cache", 
   "Pragma: no-cache", 
   "SOAPAction: \"\"", 
   "Authorization: Basic $auth", 
   "Content-length: ".strlen($xml_post_string), 
   ); 

   // PHP cURL  for https connection with auth
   $ch = curl_init();
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
   curl_setopt($ch, CURLOPT_URL, $soapUrl);
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
   curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
   curl_setopt($ch, CURLOPT_TIMEOUT, 500);
   curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 500);
   curl_setopt($ch, CURLOPT_MAXREDIRS, 12);
   curl_setopt($ch, CURLOPT_POST, true);
   curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string); // the SOAP request
   curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
   $ss = curl_getinfo($ch);
   //print_r($ss);
  // exit;
   $response = curl_exec($ch); 
   print_r($response);
   exit;
   curl_close($ch);   
   ?>

I got only Empty response only please give me any idea highly appreciated.

2
  • Try to turn on the error reporting if it's disabled, may be the script has errors. Try to do a simple curl call (GET method) to wsdl url, so we will be sure that PHP can access correctly to your wsdl. Commented Oct 23, 2014 at 8:44
  • @Anas thanks for your response but normal curl working fine with me. i need to send the login header into my request. so only i got this no response issue Commented Oct 23, 2014 at 9:33

1 Answer 1

1

I would start by adding:

$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);

That will allow you to see the response http code of the server.

Usually when I work on SOAP / REST services I make sure to have Fiddler running in the background, that makes debugging a lot easier.

You can find how to use Fiddler with cURL here: Configure PHP cURL

Sign up to request clarification or add additional context in comments.

Comments

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.