473,406 Members | 2,549 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How can I get the message-body ?



Hy all

In my application I'll receive XML text in the HTTP-message body in a
particular format that only my application understands
My script will be requested by the client with HTTP POST and the HTTP
request will contain the XML as reqest-message body

I couldn't find a way to acces the POST message body in my script to parse
the XML and extract my data. I know I can get the request-message headers
and I know I can set some of the response-headers.

How do I get the HTTP request message body ? My request method is POST and
the message body contains the information I need

-----------------
Thank you
Timothy Madden
Romania
And I don't wanna miss a thing
Jul 17 '05 #1
9 3924
> How do I get the HTTP request message body ? My request method is POST and
the message body contains the information I need


I have never done anything like that, but imagine for a moment, that there
is a form with textarea where users type XML messages.

I think that the easiest way to do it ist to have a HTTP POST variable
that contains whole xml message. Probably the xml message should be URL
encoded.

DG

Jul 17 '05 #2
On Thu, 22 Jul 2004 16:54:03 +0300, Timothy Madden wrote:
Hy all

In my application I'll receive XML text in the HTTP-message body in a
particular format that only my application understands
My script will be requested by the client with HTTP POST and the HTTP
request will contain the XML as reqest-message body

I couldn't find a way to acces the POST message body in my script to parse
the XML and extract my data. I know I can get the request-message headers
and I know I can set some of the response-headers.

How do I get the HTTP request message body ? My request method is POST and
the message body contains the information I need


What's hapening, nobody knows ? It can't be that hard ...

--
------------------------------------
Thank you
Timothy Madden
Romania
And I don't wanna miss a thing
Jul 17 '05 #3
Hello,

On Thu, 22 Jul 2004 16:54:03 +0300, Timothy Madden wrote:
In my application I'll receive XML text in the HTTP-message body in a
particular format that only my application understands
My script will be requested by the client with HTTP POST and the HTTP
request will contain the XML as reqest-message body

I couldn't find a way to acces the POST message body in my script to parse
the XML and extract my data. I know I can get the request-message headers
and I know I can set some of the response-headers.

How do I get the HTTP request message body ? My request method is POST and
the message body contains the information I need


You may want to try this HTTP client class that lets you send POST
requests with arbitrary body data. It even comes with an example of
posting requests with XML body data:

http://www.phpclasses.org/httpclient
--

Regards,
Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
Jul 17 '05 #4
On Fri, 23 Jul 2004 11:51:09 -0300, Manuel Lemos wrote:
Hello,

On Thu, 22 Jul 2004 16:54:03 +0300, Timothy Madden wrote:
In my application I'll receive XML text in the HTTP-message body in a
particular format that only my application understands
My script will be requested by the client with HTTP POST and the HTTP
request will contain the XML as reqest-message body

I couldn't find a way to acces the POST message body in my script to parse
the XML and extract my data. I know I can get the request-message headers
and I know I can set some of the response-headers.

How do I get the HTTP request message body ? My request method is POST and
the message body contains the information I need


You may want to try this HTTP client class that lets you send POST
requests with arbitrary body data. It even comes with an example of
posting requests with XML body data:

http://www.phpclasses.org/httpclient


No luck :( not what I need
--
------------------------------------
Thank you
Timothy Madden
Romania
And I don't wanna miss a thing
Jul 17 '05 #5
Timothy Madden <ba****@rmv.spam.home.ro> wrote in message news:<ny****************************@40tude.net>.. .
<snip>
How do I get the HTTP request message body ? My request method is POST and
the message body contains the information I need
http://in.php.net/curl
-----------------
Your sig-marker is wrong. It should be "-- \n"
Thank you
Timothy Madden
Romania
And I don't wanna miss a thing


--
| Just another PHP saint |
Email: rrjanbiah-at-Y!com
Jul 17 '05 #6
On 26 Jul 2004 21:05:42 -0700, R. Rajesh Jeba Anbiah wrote:
Timothy Madden <ba****@rmv.spam.home.ro> wrote in message news:<ny****************************@40tude.net>.. .
<snip>
How do I get the HTTP request message body ? My request method is POST and
the message body contains the information I need


http://in.php.net/curl

Can you please be more specific ?

I did not find what I need in there either.
I need to get the message-body of the HTTP-request-message that initiated
my script, that is the one that requested my URL.

Normally such a message is a GET request and doesn't have a message-body.
But it can have one anyway and in my case the request message is a POST
request. POST requests can carry form-fields values in the message body and
if so PHP will automaticaly set up variables with these values. But in my
case the request-message-body contains some arbitrary raw data that I need
to get.

Any help would be apreciated.

--
------------------------------------
Thank you
Timothy Madden
Romania
And I don't wanna miss a thing
Jul 17 '05 #7
Timothy Madden <ba****@rmv.spam.home.ro> wrote in message news:<1u*****************************@40tude.net>. ..
On 26 Jul 2004 21:05:42 -0700, R. Rajesh Jeba Anbiah wrote:
Timothy Madden <ba****@rmv.spam.home.ro> wrote in message news:<ny****************************@40tude.net>.. .
<snip>
How do I get the HTTP request message body ? My request method is POST and
the message body contains the information I need


http://in.php.net/curl

Can you please be more specific ?

I did not find what I need in there either.
I need to get the message-body of the HTTP-request-message that initiated
my script, that is the one that requested my URL.

<snip>

Now, I'm totally confused. I'd thought that you want to do POST to
some script and get back the message body alone.

Could you provide more details like some pseudo-code..? or perhaps
you may want to try print_r($GLOBALS) ??

--
| Just another PHP saint |
Email: rrjanbiah-at-Y!com
Jul 17 '05 #8
On 27 Jul 2004 04:37:46 -0700, R. Rajesh Jeba Anbiah wrote:
Timothy Madden <ba****@rmv.spam.home.ro> wrote in message news:<1u*****************************@40tude.net>. ..
On 26 Jul 2004 21:05:42 -0700, R. Rajesh Jeba Anbiah wrote:
Timothy Madden <ba****@rmv.spam.home.ro> wrote in message news:<ny****************************@40tude.net>.. .
<snip>
How do I get the HTTP request message body ? My request method is POST and
the message body contains the information I need
<snip>
Could you provide more details like some pseudo-code..? or perhaps
you may want to try print_r($GLOBALS) ??


Here's how it is:

A machine in my intranet, which is not a personal computer, but a SMS
gateway, will open a TCP/IP connection on port 80 on my webserver, using
regular sockets and will send the following:

POST /smschat/dispatch.php HTTP/1.1
Content-Type: text/plain; charset=ISO-8859-1
Content-Length: 250

<xml>
<object>
<request>
<msisdn>0888567987</msisdn>
<mcc>040</mcc>
<mnc>010</mnc>
<body>I have a new SMS</body>
</request>
</object>

And after that the sms-gateway will start to receive data on the connection
from the webserver. This is what the sms-gateway does, not me or my script,
and is not something that I could easyly change. This just happens.

Now I am the author of '/smschat/dispatch.php' script on my webserver. What
I want in my php script is to get the body of the message, that is the
following:

<xml>
<object>
<request>
<msisdn>0888567987</msisdn>
<mcc>040</mcc>
<mnc>010</mnc>
<body>I have a new SMS</body>
</request>
</object>
</xml>

Note the value of the Content-Type header is not text/x-wwwform-urlencoded.

What do you think ? Anyone has any ideea ?
--
------------------------------------
Thank you
Timothy Madden
Romania
And I don't wanna miss a thing
Jul 17 '05 #9

"Timothy Madden" <ba****@rmv.spam.home.ro> wrote in message
news:dd****************************@40tude.net...
On 27 Jul 2004 04:37:46 -0700, R. Rajesh Jeba Anbiah wrote:
Timothy Madden <ba****@rmv.spam.home.ro> wrote in message news:<1u*****************************@40tude.net>. ..
On 26 Jul 2004 21:05:42 -0700, R. Rajesh Jeba Anbiah wrote:

Timothy Madden <ba****@rmv.spam.home.ro> wrote in message news:<ny****************************@40tude.net>.. . <snip>
> How do I get the HTTP request message body ? My request method is POST and> the message body contains the information I need
<snip>

Could you provide more details like some pseudo-code..? or perhaps
you may want to try print_r($GLOBALS) ??


Here's how it is:

A machine in my intranet, which is not a personal computer, but a SMS
gateway, will open a TCP/IP connection on port 80 on my webserver, using
regular sockets and will send the following:

POST /smschat/dispatch.php HTTP/1.1
Content-Type: text/plain; charset=ISO-8859-1
Content-Length: 250

[snip ... ]
And after that the sms-gateway will start to receive data on the connection from the webserver. This is what the sms-gateway does, not me or my script, and is not something that I could easyly change. This just happens.

Now I am the author of '/smschat/dispatch.php' script on my webserver. What I want in my php script is to get the body of the message>
Note the value of the Content-Type header is not text/x-wwwform-urlencoded.


After a few months I found the answer.

There is a variable called $HTTP_RAW_POST_DATA available when the
Content-Type is not text/x-wwwform-urlencoded and there is also php:://stdin
as a file in the special, 'php://', protocol I could use with fopen.

Timothy Madden
Romania
----------------------------------
And I don't wanna miss a thing
Jul 17 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Hugh Welford | last post by:
Hi Using WIN XP and FP2000 Using CDO.message to out put a message from my site, I get the following error message 8004020f from using the code:- strsql = "SELECT * FROM details WHERE patid...
6
by: MLH | last post by:
I've followed the instructions found on Microsoft's site... http://support.microsoft.com/default.aspx?scid=kb;en-us;149119&Product=acc97 Here are those instructions... To play and record...
8
by: Steve | last post by:
I have several pairs of synchronized subforms in an application. I have a Delete button for each pair that uses the following code or similar to delete a record in the second subform: ...
3
by: Serious_Practitioner | last post by:
Hello, all - A few days ago, I posted the following message - Hello all, and thank you for your help in the recent past. Got a new error message in the last few days. While working with...
1
by: Serious_Practitioner | last post by:
Good day - As you suggested, I got and used the right version of Jetcomp, and I also tried to run compact and repair a couple of times. I think that the compact and repair process doesn't fully...
8
by: Brian Keating EI9FXB | last post by:
Would I be correct in saying that the only way to get a user message into a Windows form would be to use P/Invoke with Message? Of is there some part of the .NET API that I am totally un aware...
8
by: Rod | last post by:
I have been working with ASP.NET 1.1 for quite a while now. For some reason, opening some ASP.NET applications we wrote is producing the following error message: "The Web server reported...
0
by: ronscottlangham | last post by:
I am working on a custom WCF EndpoingBehavior that will modify the messages coming in and out of my Service. I am having an error related to the modification of the message in the...
2
by: bernd | last post by:
Hi netties, posted this in a different group already, which seems to be inappropriate. I create a message queue with msgget(), sent a 5-byte message to it with msgsnd() and try to receive the...
2
by: forums_mp | last post by:
Facing a design problem here and I'm not sure how to solve this. The system consists of bi-directional communication between a subject communicating with two (at least for now ) listeners. ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.