0

I've been working on this for days and I can't seem to get it to work. Does anyone see a problem with the code below?

The result is nothing. I get no response from the service whatsoever. I've confirmed that the webservice, written in .Net, can accept and xml string, I've matched their schema, etc. But I get no response back.

I should also mention that I'm new to using web services with php but have done this in .Net countless times.

Additionally, is there a way to test the webservice .asmx to view any type of error output in php just to see if it's even working on the server side?

<?php
$url = 'https://someurl/someservice.asmx';
$xml = '<?xml version="1.0" encoding="utf-8" ?>
    <query>
        <version>1.0</version>
        <login>userName</login>
        <password>password</password>
        <keyword>cancer</keyword>
    </query>'; 

$c = curl_init(); 

curl_setopt($c, CURLOPT_URL, $url); 
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);  
curl_setopt($c, CURLOPT_HEADER, true); 
curl_setopt($c, CURLOPT_HTTPHEADER, array("application/x-www-form-urlencoded", "Content-length: ".strlen($xml))); 
curl_setopt($c, CURLOPT_POST, true); 
curl_setopt($c, CURLOPT_POSTFIELDS, 'xmlInput='.urlencode($xml)); 
curl_setopt($c, CURLOPT_TIMEOUT, (int)30);  

$xmlResponse = curl_exec($c); 
curl_close ($c); 
echo 'Output :: '.$xmlResponse;
?>
attach
  • 23
  • 7
  • `SoapClient` http://php.net/manual/en/class.soapclient.php works perfectly fine ... must you use `curl` – Baba Apr 06 '12 at 13:06
  • Fivell - "SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed" – attach Apr 07 '12 at 02:04

2 Answers2

0

try without

<?xml version="1.0" encoding="utf-8" ?>

or whrite

<?xml version=\"1.0\" encoding=\"utf-8\" ?>
  • Do I have to somehow account for https? – attach Apr 06 '12 at 14:14
  • I've removed this element altogether. Still no responses from the web service. What I don't understand is why I get no response unless the web service is throwing an internal error. – attach Apr 07 '12 at 02:02
0

Have you tried adding the following to your request?

curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($c, CURLOPT_SSL_VERIFYHOST, false);
dldnh
  • 8,923
  • 3
  • 40
  • 52
user1207994
  • 30
  • 1
  • 7