Post SOAP XML Request - php

I was trying several examples from here, but nothing seems to work for me.
I need to send this envelope for the request:
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" xmlns:v2="http://xmlns.oracle.com/oxp/service/v2">
<soapenv:Header />
<soapenv:Body>
<v2:runReport>
<v2:reportRequest>
<v2:attributeLocale>en-US</v2:attributeLocale>
<v2:attributeTemplate>Default</v2:attributeTemplate>
<v2:reportAbsolutePath>/Custom/Financials/Fac/XXIASA_FAC.xdo</v2:reportAbsolutePath>
<v2:dynamicDataSource xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
<v2:parameterNameValues xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
<v2:XDOPropertyList xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
</v2:reportRequest>
<v2:userID>user</v2:userID>
<v2:password>password</v2:password>
</v2:runReport>
</soapenv:Body>
</soapenv:Envelope>
This is my code:
$url = 'https://soapurl/v2/ReportService?WSDL';
$headers = array("Content-type: application/soap+xml; charset=\"utf-8\"", "Content-length: " . strlen($xml));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
print_r($response);
And this is the weird result I am getting back:
��R;o�0��+\ﱁTj�QZ�S_R���m�%sF�#��k�Q�l�����lwjT紅�$�H��Rñ���6OxW2gy�`�_aPƶ �|�\{��:Q��;�S���H���EG�<9���q$�v&gI�ҟ���l��6y��yB���?[��x���X5�a��6��5& ��<8�Q���e`�/F+������{���]������K�(2Q��T���X(�F*ϵ�k��eym����Ӊ��]�M�!y ��"m.�����0z�|�1���g�����}� ������C
Why I'm getting this?

If you used a network sniffer (I would recomend Wireshark), you would see that the data is compressed. This is usually employed server-side to reduce the bandwidth needed. Every single modern browser will decompress automatically, but curl on your application is not. If you saved that string on a file (response.bin, for example) and ran file response.bin, you will see the compressing algorithm employed (probably gzip or deflate).
To solve this, ask curl to decompress the response for you:
curl_setopt($ch,CURLOPT_ENCODING, '');

Related

Execute multiple parallel cURL against the same URL?

I need to execute 2 requests in parallel using cURL to get a reply from the web service.
The problem is that I need to get the encrypted password from the first XML's output and pass it to the second XML to get 100 success response from the API.
Currently, I have created 2 cURL to achieve this but the API responds "101 Password Expired" because the encrypted password is valid only for the first request.
Here is my code for reference:
1st cURL:
$soapUrl = "http://localhost:54934/frmMutualFund.asmx?op=getPassword"; // asmx URL of WSDL
// xml post structure
$xml_post_string = '<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<getPassword xmlns="http://tempuri.org/">
<pUserId>12345</pUserId>
<pPassword>98765</pPassword>
<pPasskey>ksjhdfksj</pPasskey>
</getPassword>
</soap:Body>
</soap:Envelope>'; // data from the form, e.g. some ID number
$headers = array(
"Content-type: text/xml;charset=\"utf-8\"",
"Accept: text/xml",
"Cache-Control: no-cache",
"Pragma: no-cache",
"SOAPAction: http://tempuri.org/getPassword",
"Content-length: ".strlen($xml_post_string),
); //SOAPAction: your op URL
$url = $soapUrl;
// PHP cURL for https connection with auth
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//curl_setopt($ch, CURLOPT_USERPWD, $soapUser.":".$soapPassword); // username and password - declared at the top of the doc
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string); // the SOAP request
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// converting
$response = curl_exec($ch);
2nd cURL:
$soapUrl = "http://localhost:54934/frmMutualFund.asmx"; // asmx URL of WSDL
// xml post structure
$xml_post_string = '<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<MFUAPI xmlns="http://tempuri.org/">
<pFlag>06</pFlag>
<pUserId>12345</pUserId>
<pEncPassword>'.$response.'</pEncPassword>
<pParam>some_parameters</pParam>
</MFUAPI>
</soap:Body>
</soap:Envelope>'; // data from the form, e.g. some ID number
$headers = array(
"Content-type: text/xml;charset=\"utf-8\"",
"Accept: text/xml",
"Cache-Control: no-cache",
"Pragma: no-cache",
"SOAPAction: http://tempuri.org/MFUAPI",
"Content-length: ".strlen($xml_post_string),
); //SOAPAction: your op URL
$url = $soapUrl;
// PHP cURL for https connection with auth
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//curl_setopt($ch, CURLOPT_USERPWD, $soapUser.":".$soapPassword); // username and password - declared at the top of the doc
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string); // the SOAP request
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// converting
$response = curl_exec($ch);
curl_close($ch);
// converting
$response1 = str_replace("<soap:Body>","",$response);
$response2 = str_replace("</soap:Body>","",$response1);
// convertingc to XML
$parser = simplexml_load_string($response2);
// user $parser to get your data out of XML response and to display it.
print_r($parser);
first
I need to execute 2 requests in parallel
then
The problem is that I need to get the encrypted password from the
first XML's output and pass it to the second XML to get 100 success
response from the API.
if the request body of the 2nd request depends on the response of the first request, then you cannot do these 2 requests in parallel.
(generally speaking. you might be able to do some micro-optimization where you send the first request, and partially send the 2nd request, then wait for the password of the first request to be retrieved, then finish the 2nd request, but it'd be difficult to pull off, the gains would probably be very small and if you time it wrong you'll probably get a timeout for the 2nd request and have to start the 2nd request all over again, which would be even slower than just doing the 2 requests sequentially in the first place. you'll also need reliable recovery code for 2nd request timeout'ed while waiting for the password of the 1st request, it would be easy to code it wrong.)

"Version Mismatch" error using SOAP and php to connect to API

I am trying to write some code to connect a webpage to an external API. The API's documentation tells me that the request should be done with a SOAP envelope, which should look like this:
<soap:Envelope xmlns:soap="https://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="https://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetNote>
<Request>
<Security>
<Username>username</Username>
<Password>password</Password>
</Security>
<NoteID>noteID</NoteID>
</Request>
</GetNote>
</soap:Body>
</soap:Envelope>
Using some sample code created by a helpful StackOverflow user here: SOAP request in PHP with CURL I then turned it into this (slightly redacted) php:
<?php
$soapUrl = 'https://www.blah.com/DoodadService.cfc?wsdl';
$xml_post_string = '<soap:Envelope xmlns:soap="https://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="https://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetNote>
<Request>
<Security>
<Username>'.$soapUser.'</Username>
<Password>'.$soapPassword.'</Password>
</Security>
<NoteID>'.$soapNoteID.'</NoteID>
</Request>
</GetNote>
</soap:Body>
</soap:Envelope>';
$headers = array(
"Content-type: text/xml;charset=\"utf-8\"",
"Accept: text/xml",
"Cache-Control: no-cache",
"Pragma: no-cache",
"SOAPAction: https://www.blah.com/DoodadService.cfc?wsdl",
"Content-length: ".strlen($xml_post_string),
);
$url = $soapUrl;
$ch = curl_init();
echo('set curl<br>');
$f = fopen('request.txt','w');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, $soapUser.":".$soapPassword);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_VERBOSE,true);
curl_setopt($ch, CURLOPT_STDERR, $f);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string); // the SOAP request
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
echo('about to execute<br>');
// converting
$response = curl_exec($ch);
fclose($f);
echo('Got '.strlen($response).' characters in response<br>');
curl_close($ch);
echo('Saved error strings to request.txt<br> ');
?>
The result was a Version Mismatch error, ie:
<soapenv:Fault>
<faultcode>
soapenv:VersionMismatch</faultcode>
<faultstring>
Version Mismatch</faultstring>
<detail>
<ns1:hostname xmlns:ns1="http://xml.apache.org/axis/">
ip-10-4-4-149</ns1:hostname>
</detail>
</soapenv:Fault>
Can anyone tell me what this error means, what is being "mismatched" against what, and how I might be able to fix it up?
Thanks!
You could try to change the Content-type header to a SOAP+XML content. The charset doesn't need quotation.
"Content-type: application/soap+xml; charset=utf-8"
Otherwise, surely you have missed something that you don't know.
You could find some examples using this API or similar cases with SOAP in another SO questions.
As it turns out, the issue was "online manual giving out of date information". Not a problem that general SOAP experts can help out with after all!
In course of consultation with the API providers, was pointed at a useful tool SoapUI - https://www.soapui.org/ - which, as it turns out, can be used to generate correct Soap envelopes given the API's URL - meaning that I am no longer dependent on this API's providers to have their documentation up to date. I recommend it to anyone else who finds themselves in a similar fix.

Integrating with php Sabre Soap API for hotels

Following the Sabre authentication process from here
https://developer.sabre.com/docs/read/soap_basics/Authentication
Want to get sabre SOAP API results with php, but there are problems getting the response, using curl as seen in following code
$input_xml = '
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:eb="http://www.ebxml.org/namespaces/messageHeader" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<SOAP-ENV:Header>
<eb:MessageHeader SOAP-ENV:mustUnderstand="1" eb:version="1.0">
<eb:ConversationId/>
<eb:From>
<eb:PartyId type="urn:x12.org:IO5:01">999999</eb:PartyId>
</eb:From>
<eb:To>
<eb:PartyId type="urn:x12.org:IO5:01">123123</eb:PartyId>
</eb:To>
<eb:CPAId>IPCC</eb:CPAId>
<eb:Service eb:type="OTA">SessionCreateRQ</eb:Service>
<eb:Action>SessionCreateRQ</eb:Action>
<eb:MessageData>
<eb:MessageId>1000</eb:MessageId>
<eb:Timestamp>2001-02-15T11:15:12Z</eb:Timestamp>
<eb:TimeToLive>2001-02-15T11:15:12Z</eb:TimeToLive>
</eb:MessageData>
</eb:MessageHeader>
<wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext" xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/12/utility">
<wsse:UsernameToken>
<wsse:Username>USERNAME</wsse:Username>
<wsse:Password>PASSWORD</wsse:Password>
<Organization>IPCC</Organization>
<Domain>DEFAULT</Domain>
</wsse:UsernameToken>
</wsse:Security>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<eb:Manifest SOAP-ENV:mustUnderstand="1" eb:version="1.0">
<eb:Reference xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="cid:rootelement" xlink:type="simple"/>
</eb:Manifest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>';
$url = $envUrl;
//setting the curl parameters.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
// Following line is compulsary to add as it is:
curl_setopt($ch, CURLOPT_POSTFIELDS,
"xmlRequest=" . $input_xml);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 300);
$data = curl_exec($ch);
curl_close($ch);
//convert the XML result into array
$array_data = json_decode(json_encode(simplexml_load_string($data)), true);
print_r('<pre>');
print_r($array_data);
print_r('</pre>');
The $array_data returns nothing + also tried to create session before
https://developer.sabre.com/docs/read/soap_apis/session_management/create_session
but the response is same. I know there there is some good way to communicate with sabre in php, please help me find it
This question is a few months old, but maybe my answer might still be useful nonetheless.
I've managed to use PHP and CURL successfully to communicate with Sabre's SOAP API. Looking at your code and comparing with my own, I have a few suggestions:
1) Try passing some HTTP header information with your SOAP call as follows (I remember this as being somewhat important):
$action = 'SessionCreateRQ'; // Set this to whatever Sabre API action you are calling
$soapXML = $input_xml; // Your SOAP XML
$headers = array(
'Content-Type: text/xml; charset="utf-8"',
'Content-Length: ' . strlen($soapXML),
'Accept: text/xml',
'Keep-Alive: 300',
'Connection: keep-alive',
'Cache-Control: no-cache',
'Pragma: no-cache',
'SOAPAction: "' . $action . '"'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $soapXML);
2) After your call to curl_exec, check for any errors as follows which should help with debugging:
$data = curl_exec($ch);
if(curl_error($ch)) {
echo "Curl error: " . curl_error($ch);
} else {
echo $data;
...
}
3) Many Sabre SOAP API calls require that you create a session first. So that often requires making a SOAP request with SessionCreateRQ, after which you can make another SOAP call for your desired action, followed by another SOAP request to SessionCloseRQ to close the session. Each SOAP request needs the full header and payload set correctly, which can be sort of a pain, but that's the required flow.
I hope that helps!

Amazon MWS SubmitFeed error: Keys may not contain <

I'm having problems submitting a feed to Amazon MWS. I keep receiving the following error: "Invalid query string provided - Keys may not contain <"
This is my code:
$apicall = $this->build_url($function, $params);
$ch = curl_init($apicall);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
if ($this->xml) {
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, (string)$this->xml);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-type: text/xml"));
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-MD5: " . base64_encode(md5($this->xml))));
}
else {
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: text/xml'));
}
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
$response = curl_exec($ch);
$info = print_r(curl_getinfo($ch), true);
curl_close($ch);
$apicall is formed on-the-fly and comes in the form:
https://mws.amazonservices.com/Feeds/2009-01-01?ASINList.ASIN.1=B00C5XBAOA&AWSAccessKeyId=***&Action=SubmitFeed&FeedType=_POST_PRODUCT_PRICING_DATA_&MWSAuthToken=***&SellerId=***&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2015-06-09T09%3A58%3A01.000Z&Version=2009-01-01&Signature=***
(which works fine with other calls to Reports or to Orders)
$this->xml is kept as a "TEXT" field in the MySQL db; this is a sample XML (I added lines to make it readable):
<?xml version="1.0"?>
<AmazonEnvelope xsi="http://www.w3.org/2001/XMLSchema-instance" noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>***</MerchantIdentifier>
</Header>
<MessageType>Price</MessageType>
<Message>
<MessageID>1</MessageID>
<OperationType>Update</OperationType>
<Price>
<SKU>***</SKU>
<StandardPrice currency="USD">33.5</StandardPrice>
</Price>
</Message>
</AmazonEnvelope>
I seem to review every single relevant link on the internet and cannot find the answer.
Maybe someone can give me a hint what may go wrong in the above code?
Thanks.
Found the solutions myself (after digging more that a day):
1) Content-MD5 must be calculated in the following way:
base64_encode(md5($this->xml, **true**));
(thanks to this answer: https://sellercentral.amazon.com/forums/message.jspa?messageID=2767745)
2) passing header parameters to cUrl must be one-time operation, that is - all headers have to be passed as an array.

SOAP XML call using PHP curl?

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.
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

Categories