Click to See Complete Forum and Search --> : How do you receive xml web service responses?
token
Aug 11th, 2005, 04:01 PM
I am quite new to working with web services.
I just recently created a web service that returns an xml document. All the xml serialization is done by .net, all i really did was create an array of a structure, populate it and return it.
Now in the app calling the method of the web service, what am I receiving the xml document into.
proxyWebService = devServer.Services
unknownVariableType = proxyWebService.GetMeSomeValues
What is the unknownVariableType?
I know I could just return a dataset, and have tried that and it does work, I just want to know if I could do it this way as well.
Thanks again.
wild_bill
Aug 11th, 2005, 04:16 PM
In your service you should have this:
Public Function GetMeSomeValues() as whatever
You'll have to declare your variable as whatever. Is that what you are wondering?
token
Aug 11th, 2005, 04:30 PM
I was actually wondering what would the using app of the webservice have to receive an xml response.
In my service i do have a function GetMeSomeValues, and it works just fine when the return value is a dataset. But I know that you can also return structures, that will get translated into xml documents.
I was wondering what the receiving line of code would look like to receive such a document; what the caller of the method would put as a variable to receive the xml response.
God i hope that made sense. I have a habit of not making things any more clearer.
wild_bill
Aug 11th, 2005, 05:45 PM
As you've already got a dataset, all you've got to do is convert it to an xmldoc:
Public Function GetMeSomeValues() as xml.xmldocument
Dim xdRtn As New Xml.XmlDocument
dim dsRtn as new dataset
'populate dataset
xdRtn.LoadXml(dsRtn.GetXml)
return xdRtn
end function
token
Aug 12th, 2005, 09:50 AM
Thanks wild_bill, I dont know why that didnt occur to me.
I was just wondering though:
Is there a way to convert an array of structures to an xml document? Or maybe how to just receive an array of structures from the calling app? Or should I just stick to the dataset thing?
public structure person
dim firstName as string
dim lastName as string
end structure
public sub searchPerson (searchText as string) as person()
'find all persons that match searchText
'populate an array of structures
return person
end sub
token
Aug 12th, 2005, 01:37 PM
Thanks again wild_bill, I figured it out.
I can return an array of structures from the web service. And to receive it, I didnt realize that in the proxy created when you consume the webservice there is a class created for the return. You simply make an instance of it and return the web service response into that and it works just great.
I read about it in an article published by one of the 4guysfromrolla.com guys.
But thanks again for your help.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.