[SOAP] SOAP with cURL
[email protected] ("mat.altmann") Wed, 10 Feb 2010 09:42:02 -0800 (PST)
| Newsgroups | php.soap |
|---|---|
| Message-ID | <[email protected]> |
Hi Community,
hope you can help me.
I try to invoke a SOAP Service over cURL. I used soapUI
http://www.soapui.org/ http://www.soapui.org/ and copy-pasted the header
and xml-request code inside the PHP code. Then, I used the cURL routines to
address the WebService.
Now I always get the error message: "Bad Request - Invalid Header, HTTP
Error 400. The request has an invalid header name. "
What's wrong with the header, or did I make other errors?
See listing below:
<?php
$body = '
<?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tem="http://tempuri.org/"
xmlns:cis="http://schemas.datacontract.org/2004/07/C.Data"
xmlns:arr="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<soapenv:Header/>
<soapenv:Body>
<tem:AddSequence>
<!--Optional:-->
<tem:sequence>
<!--Optional:-->
</tem:sequence>
</tem:AddSequence>
</soapenv:Body>
</soapenv:Envelope>';
$headers = array("POST http://1.2.3.4/Service HTTP/1.1 \n",
"Accept-Encoding: gzip,deflate\n",
"Content-Type: text/xml;charset=UTF-8\n",
"SOAPAction: \"http://tempuri.org/IMHC/AddSequence\"\n",
"User-Agent: Jakarta Commons-HttpClient/3.1\n",
"Host: 80.153.206.248\n",
"Content-Length: 1052\n");
$fh = fopen("input.txt","w+");
$ch = curl_init("http://1.2.3.4/MHC/TestSequence");
//set Session Options
// curl_setopt($ch, CURLOPT_URL,
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_TIMEOUT, 200);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_FILE, $fh);
$xml_response = curl_exec($ch);
curl_close($ch);
echo $xml_response;
$xml_string = "";
/* Read data from file into a string buffer */
rewind ($fh);
while (!feof($fh)) {
$xml_string .= fgets($fh, 1024);
}
echo $xml_string;
$parser = xml_parser_create();
/* Disable XML tag capitalisation (Case Folding) */
xml_parser_set_option ($parser, XML_OPTION_CASE_FOLDING, FALSE);
/* Define Callback functions for XML Parsing */
xml_set_object($parser, $this);
xml_set_element_handler ($parser, "ep_xml_element_start",
"ep_xml_element_end");
xml_set_character_data_handler ($parser, "ep_xml_data");
/* Parse the XML response */
xml_parse($parser, $xml_response, TRUE);
// exit();
/* Clean up after ourselves */
xml_parser_free ($parser);
// fclose ($fh);
?>
--
View this message in context: http://old.nabble.com/SOAP-with-cURL-tp27535162p27535162.html
Sent from the Php - Soap mailing list archive at Nabble.com.