473,385 Members | 2,069 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,385 software developers and data experts.

http Request

Hello, this is a sample app but it doesnt seem to work. I am trying to
get my head round this.

I have a html doc that goes:

POST /webservices/Service1.asmx/HelloWorld HTTP/1.1
Host: 192.168.1.153
Content-Type: application/x-www-form-urlencoded
Content-Lengt: 3495

this is a http request for the webservice HelloWorld. I know the
webservice works but how do i actually get the response. I hope this
makes sense. When I load this into my browser it just shows the request
in text. do i need to add some html tags or something. Any help would
be wonderful

Jul 6 '06 #1
6 1524
I need someway of calling the http request and getting a response.

Jul 6 '06 #2
okay i have worked out that i need to open a socket and send the
request that way. I think it is all becoming clearer.
Iain Adams wrote:
I need someway of calling the http request and getting a response.
Jul 6 '06 #3
Iain Adams wrote:
okay i have worked out that i need to open a socket and send the
request that way. I think it is all becoming clearer.
Why don't you try to generate a stub for your Web services with Visual
Studio or WSDL.exe tool that comes with .NET Framework SDK?

If you want to handcraft your Web service client, derive from a
SoapHttpClientProtocol base class and implement your Web services calls
by means of this class. It will be still a lot easier than sending SOAP
messages via HTTP.

In .NET there is a simpler way to handle HTTP than operating on raw
sockets. Please read about WebRequest, HttpWebRequest and
HttpWebResponse classes.

These classes make life a little bit easier, but if you wan't to invoke
Web services this way, prepare for a tough challenge of actually
constructing and parsing SOAP messages yourself.

Best regards!
Marcin
Jul 6 '06 #4
Hi Iain,

Provided the web service supports httpget/post you can simply do

HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("http://<host>/webservices/Service1.asmx/HelloWorld");
using (HttpWebResponse resp = (HttpWebResponse)req.GetResponse())
{
using (StreamReader sr = new StreamReader(resp.GetResponseStream()))
{
string returndata = sr.ReadToEnd();
}
}

--
Happy coding!
Morten Wennevik [C# MVP]
Jul 6 '06 #5
Btw, a quick check to see if this works is to load the uri in a browser, you would then see the returnstring in the browser as well. Note though that the return stream may be in xml format.

--
Happy coding!
Morten Wennevik [C# MVP]
Jul 6 '06 #6
Thanks, I will check them out right away.

O and the browser does return the string in xml but is actually quite
helpful.

Thanks again

Morten Wennevik wrote:
Btw, a quick check to see if this works is to load the uri in a browser, you would then see the returnstring in the browser as well. Note though that the return stream may be in xml format.

--
Happy coding!
Morten Wennevik [C# MVP]
Jul 6 '06 #7

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

Similar topics

7
by: Michael Foord | last post by:
#!/usr/bin/python -u # 15-09-04 # v1.0.0 # auth_example.py # A simple script manually demonstrating basic authentication. # Copyright Michael Foord # Free to use, modify and relicense. #...
8
by: turnit \(removethis\) | last post by:
I have a login form that uses the post method to carry the information to the next page. The form works just fine in ie6.0, but fails in mozilla and fails in ie5.2 on a mac. "HTTP/1.1 400 Bad...
3
by: Patrick Fogarty | last post by:
I am programming what is to be a web service client that will use an HTTP-POST to request and retrieve data. The remote server (written in java for what it's worth) requires basic authentication...
2
by: MDANH2002 | last post by:
Hi From VB.NET I want to simulate the POST request of the following HTML form <html> <title>HTTP Post Testing</title> <body> <form action=http://www.example.com/postdata ...
3
by: =?Utf-8?B?U3ViYQ==?= | last post by:
Hi I having a similar issue. my website url has https://blahblahblah but when i do Response.Write(Request.Url); it writes the url with http..........its really strange........i dont have a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.