Web Service SOAP Question

W

Wee Bubba

i have created a web service with one method which returns a code. i
am currently trying to access the return value of this method through
a page which has not got the proxy.dll referenced. i.e. as if this
request is from an external company. at the moment my method is
returning the whole SOAP return message as a string. 2 questions
please:

1. how do i just get the value of the node CLIENTCODE. this is the
return parameter of my web service method so this is all i am
interested in, not the whole SOAP message.

2. my code below does not use the SoapExtension class. is my code
below wrong? is there a better way to send and receive data using
SOAP?

here is my method:

XmlDocument doc = new XmlDocument();
doc.Load(xmlfile);
HttpWebRequest req = (HttpWebRequest)
WebRequest.Create(@"http://localhost/test/webservicebridge/bridgeservice.asmx");
if (proxy != null)
req.Proxy = new WebProxy(proxy, true);
req.Headers.Add("SOAPAction",
@"http://localhost/webservices/GetClientCode");
req.ContentType = "text/xml;charset=\"utf-8\"";
req.Accept = "text/xml";
req.Method = "POST";
Stream stm = req.GetRequestStream();
doc.Save(stm);
stm.Close();
WebResponse resp = req.GetResponse();
stm = resp.GetResponseStream();
StreamReader r = new StreamReader(stm);
string s = (r.ReadToEnd());
 
K

Kevin Spencer

You're going to a lot of unnecessary trouble here. The .Net platform has
built-in functionality for consuming Web Services. Basically, a Web Service
is a remote method call. A .Net method returns an object, whether that
object is a string, an integer, a class, or any other data type. In other
words, a Web Service returns an object in the same way that any other method
returns an object. The only difference is that the return value of a Web
Method is serialized. You de-serialize it back into an object. However, the
..Net framework has built-in functionality for doing this transparently. The
following is an MSDN article which demonstrates consuming a DataSet from a
Web Service. Note, however, that the return type isn't important. The
methodology is the same:

http://msdn.microsoft.com/library/d.../html/cpconconsumingdatasetfromwebservice.asp

If you have Visual Studio.Net, creating your proxy is rather simple to do as
well. It is done by adding a Web Reference to your References. Visual
Studio.Net will build the proxy for you.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top