|
Posted by Rik Wasmus on 12/05/07 16:22
On Wed, 05 Dec 2007 17:06:12 +0100, gentleJuggernaut <url84t@gmail.com> =
=
wrote:
> On Dec 5, 10:59 am, "Rik Wasmus" <luiheidsgoe...@hotmail.com> wrote:
>> On Wed, 05 Dec 2007 16:45:46 +0100, gentleJuggernaut <url...@gmail.co=
m>
>> wrote:
>>
>> > I am using curl to access a webservice. The webservice offers a
>> > search and confirm. The search works great. on the confirm there =
is
>> > a value that needs to be passed back to the webservice in order to
>> > confirm. This value often contains '+%20' etc. Curl appears to be=
>> > changing these values to spaces. Is there a curl option that will
>> > tell it not to encode the data, just pass it as is.
>>
>> > Here is the cURL code that I am working with:
>>
>> > $ch =3D curl_init ();
>> > $fp =3D @fopen('out.txt','w');
>> > $postdata =3D 'serviceRequest=3D' . $xml=
;
>>
>> Hmmz, shouldn't you 'double encode' the data in the $xml here? Once s=
ome
>> possible values/attributes in the XML itself, once the whole lot to m=
ake
>> it postdata? (just guessing here, might work though). So, something l=
ike
>> $postdata =3D 'serviceRequest=3D' . rawurlencode($xml);
>>
>> > the variable $xml contains my well formed xml request (I have verif=
ied
>> > this separately). When the server (represented by $this-
>> >> getGateway($test)) receives my xml statement with altered text (wh=
en
>> > I compare what the server receives with what I had prior to putting=
it
>> > through cURL some of the data contained in the xml has been
>> > reformatted with spaces in place of certain characters, referenced
>> > above). This of course causes the confirmation to fail. Any help
>> > would be appreciated.
>
> Thank you Rik, that is exactly what I needed. I am somewhat new to
> passing data to webservices, I am going to look up the rawurlencode()
> function, is there any other information that you could point me to?
Well, it helps to understand the underlying principle of HTTP requests:
http://www.w3.org/MarkUp/html-spec/html-spec_8.html#SEC8.2.1
http://www.jmarshall.com/easy/http/#postmethod
However, using webservices, a whole lot of other encoding besides =
application/x-www-form-urlencoded are possible. Having just the XML as r=
aw =
data in the request (so no classic form name/value pairs) is quite commo=
n. =
While fiddling around, testing/viewing your own post request can be quit=
e =
easy using php://input (<http://nl2.php.net/manual/en/wrappers.php.php>)=
=
for reading the 'raw' input and/or apache_request_headers() to check the=
=
request headers (if you're running apache offcourse).
-- =
Rik Wasmus
[Back to original message]
|