467,920 Members | 1,194 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,920 developers. It's quick & easy.

Web Service SOAP Question

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());

Nov 18 '05 #1
  • viewed: 1697
Share:
2 Replies
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/de...webservice.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.

"Wee Bubba" <ma***********@yahoo-dot-com.no-spam.invalid> wrote in message
news:41**********@Usenet.com...
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.asm
x"); 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());

Nov 18 '05 #2
"Wee Bubba" <ma***********@yahoo-dot-com.no-spam.invalid> wrote in message
news:41**********@Usenet.com...
here is my method:


Aren't you using Visual Studio? If you are, there's really no need for you
to do any of this, as it's all taken care of for you...
Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Liza | last post: by
9 posts views Thread by Marty McDonald | last post: by
3 posts views Thread by Jerome Cohen | last post: by
10 posts views Thread by Mike Schilling | last post: by
3 posts views Thread by Enda Manni | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.