Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Consuming Web Service...

Status
Not open for further replies.

bartee

MIS
Mar 20, 2005
147
US
I have a web service that I am consuming on my .net web form.

I am able to connect and accept return information fine.

However, the web service returns 5 parameters. I want to set a local variable to the value of each parameter returned but only want to call the web service once.

Can anyone suggest sample code for doing this?

Here is an example:

Instead of using the following way of assignining a local variable to the return values of returnID and returnNam...

Dim ID As String = myservice.specificmethod("x", "xx", "user", "123456", "aa", 1).returnID

Dim Name As String = myservice.specificmethod("x", "xx", "user", "123456", "aa", 1).returnName

I would like to accomplish the same thing but only call the web service ONCE...


Thanks in advance.


 
I think that would be a function of the web service and not code you write. You'll have to see if the web service can return all the values you want, say in an array or collection, and then you can do what you want.
 
Thanks for the reply. I am new to working with web services.

Unfortunately, I don't have any control over the web service that I am consuming.

Here is my call:

consumeWebService.mymethod("x", "xx", "user", "pass", "type", 1)

It returns 5 variables: ID, Name, Code 1, Code 2, Code 3

Is there a way, once I've called the service, to view determine how the results are returned?

Can I store them in an object to retrieve? If so, any samples would help.

Thanks again in advance.
 
You'll have to speak to the people who created the web-service, look at the documentation for the service or simply try it out to see what format it returns the data in. We can't help with any of that unless you provided access to the service.


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244 on how to get better results.
 
Again.. this is dependent on the web service. You have to find out what the web service returns when you make the call.
Code:
consumeWebService.mymethod("x", "xx", "user", "pass", "type", 1)
Does it return an array of values, a collection..etc?
 
Also, I notice that although you have asked around 50 questions and been a meber for 2 years on these forums, you haven't marked any of the answers as valuable, and I can only see one or two acknowledgements of other peoples responses. If you are not getting the answers that you need read FAQ222-2244 to see how to ask better questions. If you are getting the answers you need see FAQ222-2244 to see how to acknowledge the answers given.

Paragraph 16 of the FAQ explains about this being a two-way forum, to give guidance on answering other peoples questions, as I also notice that you haven't yet made any posts in other peoples threads.


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244 on how to get better results.
 
the webservice may be returning a complex object (DTO) of some kind. something like this might work
Code:
Dim result As WebServiceObject = consumeWebService.mymethod("x", "xx", "user", "pass", "type", 1)

//use values... example
Console.WriteLine("ID={0}; Name={1}; Code 1 = {2};  Code 1 = {3}; Code 1 = {4};", result.ID, result.Name, result.Code1, result.Code2, result.Code3)

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
intellisense should tell you the returntype of consumewebservice.mymethod. and then you can do this

dim a as consumewebservice.returntypesuggestedbyintellisense
a = consumewebservice.mymethod(blah,blah).
and then you can do

Dim ID As String = a.returnID

Dim Name As String = a.returnName

BTW this all depends on how well written the webservice is. But because you can do this myservice.specificmethod("x", "xx", "user", "123456", "aa", 1).returnID this means that is is returning something of a certain type and that something is understood by vb.net) and I bet the webservice was written in java because of the camelcasing.

BTW2 I think DTO's (Data transfer Objects) are always simple complex objects.

Christiaan Baes
Belgium

"My old site" - Me
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top