1
votes

I'm trying to implement the AAA Cooper Freight's SOAP API via PHP. When I send XML request to http://wsportal.aaacooper.com:8188/wsportal20/wsGenEst, it via Postman, works fine, but when using CURL, it doesn't return anything

I use the direct url(from the wsdl file), because their WSDL file seems to be broken and its not working with it: http://wsportal.aaacooper.com:8188/wsGenRateEstimate.wsdl

Here is screenshot from Postman(Working!) enter image description here and my php code:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,            "http://wsportal.aaacooper.com:8188/wsportal20/wsGenEst" );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt($ch, CURLOPT_POST,           1 );
curl_setopt($ch, CURLOPT_POSTFIELDS,     $input_xml ); 
curl_setopt($ch, CURLOPT_HTTPHEADER,     array('Content-Type: text/xml; charset=ISO-8859-1')); 
$data = curl_exec($ch);
print_r($data);
curl_close($ch);

I'm using same XML string on both places.

1
2 things, add to OP the error you are getting, "doesn't work" is not a good description :p. 2) On postman you send an XML with UTF-8 encoding but in curl the Content -type header says charset=ISO-8859-1. Server may or may not ignore that so it could be breaking the request. - LMC

1 Answers

3
votes

Postman can generate the PHP code for any given request using the Code button on the top right corner of the screen. A demonstration of this feature can be seen in the image below.

Postman generated code