Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Webrequest and POST

Reply
Thread Tools

Webrequest and POST

 
 
Jay
Guest
Posts: n/a
 
      11-28-2005
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 aram1=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();


 
Reply With Quote
 
 
 
 
Joerg Jooss
Guest
Posts: n/a
 
      11-28-2005
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 aram1=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
(E-Mail Removed)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
webrequest post method and navigate to the new url guoqi zheng ASP .Net 3 05-29-2006 07:06 AM
Webrequest and POST Jay ASP .Net Web Services 1 11-28-2005 09:57 PM
Re: HTTP webclient or webrequest File post with variables Joerg Jooss ASP .Net 0 04-10-2004 07:18 PM
Re: problem with webRequest.method = post John Saunders ASP .Net 0 08-20-2003 05:48 PM
problem with webRequest.method = post Sujith Jagini ASP .Net 1 08-17-2003 07:33 AM



Advertisments