Click to See Complete Forum and Search --> : Regarding Making a SOAP request


M_Dec
November 17th, 2008, 09:56 PM
Hi,

I need to build a SOAP request from C# to access a web service.

Following is a sample request that I have to build.

POST /gwy/test.asmx HTTP/1.1
Host: test.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://test.com/gwy/getdata"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<OriginatorHeader xmlns="http://test.com/gwy/">
<OriginatorId>int</OriginatorId>
</OriginatorHeader>
</soap:Header>
<soap:Body>
<getdata xmlns="http://test.com/gwy/">
<Id>int</Id>
<Name>string</Name>
</getdata>
</soap:Body>
</soap:Envelope>


Can you please let me know how to write code in C# to build the request for the above format. Appreciate if someone can help me with this.

Thanks in Advance!

MMH
November 17th, 2008, 11:40 PM
May be you could just get the refrence of the web service you want to access in your project.
OR,
Create a proxy class and access the methods of the web service.

toraj58
November 18th, 2008, 05:30 AM
if you want to write code from scratch to access a web services yoy shoud deal with SOAP, WSDL, UDDI, DISCO and XML all by yuorself;so let the visual stadion .net (if you use it) do the hard part for you and save your time then focus on the logic of your program.

tale a look at this article:
http://www.codeproject.com/KB/webservices/myservice.aspx