views:

116

answers:

2

I am using a webservice to get some results in XMl form... here is the part of the code

public function getXML()
{
    $url=$this->constructURL();
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $xml = curl_exec($ch);
    if ($error = curl_error($ch)) {
    echo "Error: $error<br />\n";
    }
    curl_close($ch);
    return $xml;
}


$resultXML = $api->getXML();
echo $resultXML;

when i echo that '$asd' it does nothing but a balnk page...

but when i use the value of $url directly in the browser it produce an XML result...

can any one suggest me where i am going wrong???

ADDED.........

when i included the error reporting after curl_exec

it gives an error

Error: SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

also Iam usig https://blahblh for request

+1  A: 

I i'm not blind - your "getXML" is a method of a class (ie myWebService). So, how do you think your $asd = getXML(); should work?

I suppose your code must look like this:

...
$service = new myWebService();
$asd = $service->getXML();
echo $asd;

ADDED:

I think, that browser just doesn't display your XML, because it receives a header with content-type text/html by default. Try to look at page source or write before echo

header('Content-type: text/xml');

Any browser, assuming that this is HTML should ignore unknown tags which are not HTML-compatible. So your XML is being interpreted as unknown non-HTML tag.

Jet
I know tht....I have created a class for my service and called getXML through an object of tht class....
Jasim
i haven't posted all the code in the question. only the relevant part
Jasim
when i added the header('Content-type: text/xml');i got XML Parsing Error: not well-formed
Jasim
+4  A: 

Solved Out The PROBLEM....

since i am using https:// ,i Have to include a single line of code which set the cURL options

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

Jasim
Thank you very much - I had been trying to solve this for hours.
M Schenkel