Click to See Complete Forum and Search --> : how to i post XML to SOAP server


vincenzobar
June 6th, 2006, 09:21 AM
I have a XML document i want to pass to my Soap server. I am using cURL. But all i get in return is "1"

I need to get back the XML generated by the server. How do i do this? here is my cURL so far

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $postUrl);
curl_setopt($ch, CURLOPT_POST, 1 );
curl_setopt($ch, CURLOPT_POSTFIELDS, client_info($urlSetting, $sSoapAction, $username, $password, $partnerId, $productId, $ratePlanId, $responseGroups, $zipcode));
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // process page
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$postResult = curl_exec($ch);

if (curl_errno($ch)) {
print curl_error($ch);
}
curl_close($ch);
echo $postResult;

What i get back is:
HTTP/1.1 100 Continue HTTP/1.1 400 Bad Request Date: Tue, 06 Jun 2006 14:18:14 GMT Server: Microsoft-IIS/6.0 X-Powered-By: ASP.NET X-AspNet-Version: 1.1.4322 Transfer-Encoding: chunked Cache-Control: private Content-Type: text/html

Do i need to store a cookie with the header info?

I think i am using POSTFIELDS wrong because that is just the generated XML and not a query string.

How do i pass XML to a service in cURL?

Arg... this is my last step and i can't get it, any help is much appreciated!!!

vincenzobar
June 6th, 2006, 12:39 PM
well i just added a header to before the XML and i got through. Now only if IT would get there **** servers working and it would stop sending a .NET error. I hate .NET!

vincenzobar
June 6th, 2006, 09:34 PM
i am posting this for people if they ever need the answer.

to rewrite the header in cURL add this:

// $header must be an array of values you want to add to the header
// in my case i needed to add the SOAPAction attribute to my header

$header = array('SOAPAction: "domain-com:2006:03:catalog/GetDeviceDetails"');
$ch = curl_init();
// add the header element
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_URL, $postUrl);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_POST, 1 );
curl_setopt($ch, CURLOPT_POSTFIELDS, client_info($urlSetting, $sSoapAction, $username, $password, $partnerId, $productId, $ratePlanId, $responseGroups, $zipcode));
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // process page
// for error check
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$postResult = curl_exec($ch);

if (curl_errno($ch)) {
print curl_error($ch);
}
curl_close($ch);
echo $postResult;



you would not believe how easy it was but how hard it was to find that answer!!

Now see my question about UTC format and i am done this monster script!