I have an SSL Error from Submitting a SOAP request with PHP
I am getting the following response from a SOAP call to a server...
HTTP/1.1 200 OK
Date: Sun, 01 Mar 2009 01:37:46 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Cache-Control: private, max-age=0
Content-Type: application/soap+xml; charset=utf-8
Content-Length: 712
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<getProductResponse xmlns="http://domain.com/">
<getProductResult>
<Error xmlns="">Error trying to get data from the store. Technical description: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.</Error>
</getProductResult>
</getProductResponse>
</soap:Body>
</soap:Envelope>
How can i fix this... I have a certificate on my site, and i tried running the script in https... no dice.. below is my php code...
<?php // THE XML STRING, WITH PLACEHOLDERS FOR PHP VARIABLES$xml = '<?xml version="1.0" encoding="utf-8"?><soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> <soap12:Body> <getProduct xmlns="http://domain.com/"> <storeUrl>www.domain.com</storeUrl> <userKey>thekey</userKey> <batchSize>1</batchSize> <startNum>1</startNum> </getProduct> </soap12:Body></soap12:Envelope>';// SETTING THE SOCKET COMMUNICATIONS INFORMATION$method = 'POST';$uri = '/service.asmx';$protocol = 'HTTP/1.1';$service = 'www.theapi.com';$c_type = 'Content-Type: application/soap+xml; charset=utf-8';$length = strlen($xml);// CREATE MESSAGE HEADERS FOR THE WEB SERVICE$header .= "$method $uri $protocol\r\n";$header .= "Host: $service\r\n";$header .= "$c_type\r\n";$header .= "Content-Length: " . $length . "\r\n\r\n";// OPEN THE SOCKET$fp = fsockopen ($service, 80, $errno, $errstr, 30);// TEST FOR VERIFICATIONif (!$fp) // HTTP ERROR{ die("fsockopen() FAILED \n\n ERRNO=$errno \n\n ERRSTR=$errstr \n\n");}// WITH HTTP OPEN - WRITE HEADER AND REQUESTfputs ($fp, $header . $xml);// HTTP OPEN - READ WEBSERVICE RESPONSE, INCLUDING HEADERS AND BODY$reply = '';while (!feof($fp)){ $reply .= fgets ($fp, 1024);}// SEE THE REPLYvar_dump($reply);
That would of been my first thought, and I had tried that, and it didn't work... instead what did work was the storeurl needed to be changed slightly. It was strange to receive that error though.