On 6/13/07, Matthew Weier O'Phinney <[EMAIL PROTECTED]> wrote:
-- Ian Warner <[EMAIL PROTECTED]> wrote
(on Wednesday, 13 June 2007, 11:51 PM +0100):
> Hi
>
> I want to send the following XMl through HTTP Client as a POST
>
>
> $XMLDATA = '<?xml version="1.0" encoding="ISO-8859-1"?>';
> $XMLDATA .= '<ResponseService Version="2.3">';
> $XMLDATA .= "<Header>";
> $XMLDATA .= "<Partner>test</Partner>";
> $XMLDATA .= "<Password>test</Password>";
> $XMLDATA .= "<Company>test</Company>";
> $XMLDATA .= "</Header>";
> $XMLDATA .= "<ResponseList>";
> $XMLDATA .= "<Response>";
> $XMLDATA .= "<TransactionID>99</TransactionID>";
> $XMLDATA .= "<OriginatingNumber>12345</OriginatingNumber>";
> $XMLDATA .= "<Time>" . date('YmdHi') . "</Time>";
> $XMLDATA .= "<Data>" . $message . "</Data>";
> $XMLDATA .= "<Destination>" . $destination .
"</Destination>";
> $XMLDATA .= "<Operator>23433</Operator>";
> $XMLDATA .= "</Response>";
> $XMLDATA .= "</ResponseList>";
> $XMLDATA .= "</ResponseService>";
>
> $client->setParameterPost(array('XMLDATA' => $XMLDATA));
>
> On the other end I SIMPLE XML this
>
> but I get load of errors due to HTTP client urlencoding and
addingslashes.
>
> If it is urlencoding why does it need to addslashes?
>
> anyway to get round this ?
Send it as a RAW POST:
$clent->setRawData($XMLDATA);
and read the raw post on the server side. This is the typical way XML is
transmitted via HTTP (XML-RPC and SOAP both use it, and it's the
recommended way to POST or PUT data to REST).
Depending on what the server requires, you might also need to set the
Content-Type header to the appropriate value. For Zend_Gdata, we use
application/atom+xml, but I suspect text/xml would be more appropriate in
your situation.
$client->setHeaders('Content-Type', 'application/atom+xml');
Cheers,
-Ryan
--
Matthew Weier O'Phinney
PHP Developer | [EMAIL PROTECTED]
Zend - The PHP Company | http://www.zend.com/