473,396 Members | 1,942 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,396 software developers and data experts.

Webrequest and POST

Jay
am trying to call a webservice from C# client.
I am having trouble sending a POST via webrequest.

This is the URL: http://T9946ISP0001:8080/PrintMgr/ProcessRequest.jsp

Here is the method : createSession

The params are :param1=1024

Following is the code snippet - I am not sure how I specify the URL , the
method name and its params..

----------------------------------------------------------------------------
------------------

req.ContentLength = postData.Length;

HttpWebRequest req = (HttpWebRequest)

WebRequest.Create("http://T9946ISP0001:8080/PrintMgr/ProcessRequest.jsp");

req.Method = "POST";
ASCIIEncoding enc = new ASCIIEncoding();

byte[] postData = enc.GetBytes("methodAlias=createSession&param1=102 4");

req.ContentLength = postData.Length;

Stream reqStream = req.GetRequestStream();

reqStream.Write(postData, 0, postData.Length);

reqStream.Close();

WebResponse resp = req.GetResponse();
Nov 28 '05 #1
1 1894
Jay wrote:
am trying to call a webservice from C# client.
I am having trouble sending a POST via webrequest.

This is the url: http://T9946ISP0001:8080/PrintMgr/ProcessRequest.jsp

Here is the method : createSession

The params are :param1=1024

Following is the code snippet - I am not sure how I specify the URL ,
the method name and its params..

----------------------------------------------------------------------
------ ------------------

req.ContentLength = postData.Length;

HttpWebRequest req = (HttpWebRequest)

WebRequest.Create("http://T9946ISP0001:8080/PrintMgr/ProcessRequest.js
p");

req.Method = "POST";
ASCIIEncoding enc = new ASCIIEncoding();

byte[] postData =
enc.GetBytes("methodAlias=createSession&param1=102 4");

req.ContentLength = postData.Length;

Stream reqStream = req.GetRequestStream();

reqStream.Write(postData, 0, postData.Length);

reqStream.Close();

WebResponse resp = req.GetResponse();


A Web Service deployed as JSP? That doesn't seem right... anyway,
you're code is basically OK, except that you don't set a Content-Type
and that you need to know if that Web Service can be called like that
or if you need to use SOAP as protocol. In the latter case forget about
manually implementing this functionality and use Visual Studio to build
a Web Service client.

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Nov 28 '05 #2

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

Similar topics

2
by: Keith Selbee | last post by:
I am trying to submit data to a webpage in the form of a post and my code is below. It is a function that takes a url and the post content as strings and then performs the post. But as soon as I...
17
by: James Johnson | last post by:
Dear C#dex, I define a variable: HttpWebRequest webRequest and run the following request webRequest = WebRequest.Create(TARGET_URL) as HttpWebRequest; The webRequest object returns values...
4
by: Paul | last post by:
Hello, I tried to execute a button on an aspx webpage using WebRequest, but it failed. When posting data as if I did a login (see code), I just receive the login page, instead of the page I...
3
by: Paul | last post by:
Hello, First I want to refer to the problem "WebRequest : execute a button" of a few days ago. The way I solved it, I loose my session, and as a consequence my session variables. I don't want...
3
by: Stephane | last post by:
Hi, I'm trying to use PayPal and its Instant Payment Notification. In short, when a payment is made, PayPal send a post to my server and I post it back to PayPal. I'm using WebRequest to do...
6
by: Jensen Bredhal | last post by:
Hello, I need to send command to a web server from a method. I understand this should be possible using the WebClient or WebRequest class. how can this be done? below an example of my...
0
by: WIWA | last post by:
Hi, I want to login to a password protected website and fetch the content of the page behind. I have based my code on http://weblogs.asp.net/jdennany/archive/2005/04/23/403971.aspx. When I use...
4
by: Savas Ates | last post by:
I have a vb.net web application. I want to post some variables to another web page and take some values back and process them. This is codes in my target url. I should post "langpair" cariable...
3
by: Dave | last post by:
string m_request = some_web_page; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(m_request ); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Which works...
4
by: CindyH | last post by:
Hi I'm trying to use webrequest - webresponse to post a stream. I have set up a simple test with one aspx form holding the post code and trying to get another aspx form to receive the post on...
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?
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.