|
|
|
|
||||||
| comp.protocols.tcp-ip TCP and IP network protocols. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hello,
I' m trying to send a XML request (with some SOAP) to a server (more exactly a web service) by telnet. I do: ******************************************* $ telnet <serverIp> 8080 GET /wher/I/want/to/send/my/data/ HTTP/1.1 <ENT> <ENT> HTTP/1.1 400 Bad Request Server: Apache-Coyote/1.1 Transfer-Encoding: chunked Date: Sat, 29 Apr 2006 17:22:43 GMT Connection: close 0 Connection closed by foreign host. $ ******************************************** (<ENT> = push on enter) So i cant send my XML request .... When i try to use HTTP/1.0 instead HTTP/1.1, server anwer me the html page associate to the webservice. Of course, when i directly send the XML request, server returns me a bad request.... So how to send an XML request to a server please ? Thanks. |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Nanar Duff wrote: > Hello, > > > I' m trying to send a XML request (with some SOAP) to a server (more > exactly a web service) by telnet. I do: > > ******************************************* > $ telnet <serverIp> 8080 > > GET /wher/I/want/to/send/my/data/ HTTP/1.1 <ENT> > <ENT> > HTTP/1.1 400 Bad Request > Server: Apache-Coyote/1.1 > Transfer-Encoding: chunked > Date: Sat, 29 Apr 2006 17:22:43 GMT > Connection: close This is correct. You have just sent an invalid HTTP 1.1 request. Remember, HTTP 1.1 requires a Host: header. Not only that, HTTP 1.1 servers are REQUIRED TO REJECT requests without the Host: header with a 400 Bad Request error. Thus the minimum request should be: GET /wher/I/want/to/send/my/data/ HTTP/1.1\r\n Host: serverIp:8080\r\n\r\n > Connection closed by foreign host. > $ > ******************************************** > (<ENT> = push on enter) > > So i cant send my XML request .... When i try to use HTTP/1.0 instead > HTTP/1.1, server anwer me the html page associate to the webservice. This is also correct since HTTP 1.0 does not have any required headers. > Of course, when i directly send the XML request, server returns me a bad > request.... > > So how to send an XML request to a server please ? Typically you'd need to do a POST request with the XML document/code as part of the message body sent to the server: POST /wher/I/want/to/send/my/data/ HTTP/1.0\r\n Content-Length: 46\r\n \r\n <xml><code><sent>to server</sent></code></xml> |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
slebetman@yahoo.com a écrit :
> Nanar Duff wrote: > > > This is also correct since HTTP 1.0 does not have any required headers. > > > > > Typically you'd need to do a POST request with the XML document/code as > part of the message body sent to the server: > > POST /wher/I/want/to/send/my/data/ HTTP/1.0\r\n > Content-Length: 46\r\n > \r\n > <xml><code><sent>to server</sent></code></xml> > (sorry for the late, but server was down). Thanks for your answer, I try it by doing this: ************************************************* $ telnet <ip address> 8080 POST /wher/I/want/to/send/my/data/ HTTP/1.1\r\n Content-Type: text/xml; charset=utf-8\r\n SOAPAction: ""\r\n Content-Length: 785\r\n Expect: 100-continue\r\n Host: <ip address>:8080\r\n \r\n <xml><code><sent>to server</sent></code></xml> HTTP/1.1 400 Bad Request Server: Apache-Coyote/1.1 Date: Sat, 06 May 2006 07:25:32 GMT Connection: close Connection closed by foreign host. $ ************************************************** * But I' m not sure of the value of Content-Length. Is this the number of character in the XML request ? And maybe that my XML request is wrong. But server shouldn't send me "data" to warn me that my request was wrong ? Thanks. |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
Nanar Duff a écrit :
> Thanks for your answer, I try it by doing this: > > ************************************************* > $ telnet <ip address> 8080 > POST /wher/I/want/to/send/my/data/ HTTP/1.1\r\n > Content-Type: text/xml; charset=utf-8\r\n > SOAPAction: ""\r\n > Content-Length: 785\r\n > Expect: 100-continue\r\n > Host: <ip address>:8080\r\n > \r\n > <xml><code><sent>to server</sent></code></xml> > > HTTP/1.1 400 Bad Request > Server: Apache-Coyote/1.1 > Date: Sat, 06 May 2006 07:25:32 GMT > Connection: close > > Connection closed by foreign host. > $ > ************************************************** * > > > But I' m not sure of the value of Content-Length. Is this the number of > character in the XML request ? > > And maybe that my XML request is wrong. But server shouldn't send me > "data" to warn me that my request was wrong ? > > Thanks. Oops, I try request without \r\n, and its works fine. Thanks. |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
Nanar Duff wrote: > Nanar Duff a écrit : > > Thanks for your answer, I try it by doing this: > > > > ************************************************* > > $ telnet <ip address> 8080 > > POST /wher/I/want/to/send/my/data/ HTTP/1.1\r\n > > Content-Type: text/xml; charset=utf-8\r\n > > SOAPAction: ""\r\n > > Content-Length: 785\r\n > > Expect: 100-continue\r\n > > Host: <ip address>:8080\r\n > > \r\n > > <xml><code><sent>to server</sent></code></xml> > > > > HTTP/1.1 400 Bad Request > > Server: Apache-Coyote/1.1 > > Date: Sat, 06 May 2006 07:25:32 GMT > > Connection: close > > > > Connection closed by foreign host. > > $ > > ************************************************** * > > > > > > But I' m not sure of the value of Content-Length. Is this the number of > > character in the XML request ? > > > > And maybe that my XML request is wrong. But server shouldn't send me > > "data" to warn me that my request was wrong ? > > > > > Thanks. > > > Oops, I try request without \r\n, and its works fine. > Yes, \r in my post refers to Carrige Return and \n refers to Linefeeds as per C convention. For \r\n configure your telnet client to have CRLF line endings (LF works but is not really conformant to HTTP spec) and press the Enter key (actually the Return key which is labelled Enter on most PC keyboard. The "real" Enter key is actually the one on the numeric keypad). |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
slebetman@yahoo.com a écrit :
> Yes, \r in my post refers to Carrige Return and \n refers to Linefeeds > as per C convention. For \r\n configure your telnet client to have CRLF > line endings (LF works but is not really conformant to HTTP spec) Ok, thanx for all this info ![]() > press the Enter key (actually the Return key which is labelled Enter on > most PC keyboard. The "real" Enter key is actually the one on the > numeric keypad). Ah ? But heuh... what is the difference between the Return key and the "real" Enter key ? (just for my "general knowledge" :p ) |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
In article <445f0a78$0$1490$626a54ce@news.free.fr>,
Nanar Duff <_SPAMORAMA_dnanar@gmail.com> wrote: > slebetman@yahoo.com a écrit : > > Yes, \r in my post refers to Carrige Return and \n refers to Linefeeds > > as per C convention. For \r\n configure your telnet client to have CRLF > > line endings (LF works but is not really conformant to HTTP spec) > > > Ok, thanx for all this info ![]() > > > > press the Enter key (actually the Return key which is labelled Enter on > > most PC keyboard. The "real" Enter key is actually the one on the > > numeric keypad). > > Ah ? But heuh... what is the difference between the Return key and the > "real" Enter key ? (just for my "general knowledge" :p ) For most applications, there's no difference. -- Barry Margolin, barmar@alum.mit.edu Arlington, MA *** PLEASE post questions in newsgroups, not directly to me *** *** PLEASE don't copy me on replies, I'll read them in the group *** |
|
![]() |
| Outils de la discussion | |
|
|