• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 183
  • Last Modified:

Filling a Windows Froms Combo Box From a .Net Web Service

Hi All,

I am developing a VB.Net app that uses a SQL Server Backend, a .Net Web Service as the middle tier and a VB.Net Windows Forms app as the front end.  It seems that everyone assumes that if you are using a Web service that your front end will be ASPX or at least browser based.  To date I have not been able to find a single example that shows a web service consumed by a Windows forms app.  (I digress here only to ask that if anyone knows of a good resource for Web service to Windows Forms app info please include. – this includes Books, Web sites, and Magazines etc.)

Ok, now on to the meat so to speak.  I have a Customer class in my web service; it contains the usual stuff Name, address etc.  I have a web method GetCustomer that will return a class Customer if you provide the Customer ID.  (The Customer Class has all the necessary code to retrieve a customer from the backend.)

Now that works but I cannot find any windows forms examples on how to return a list of Names and customer ID’s to load into a combo so the user can select a customer by name.

I tried creating a collection with just Name and ID as properties.  But it will not show up as a web method. And any examples seem to state that I must include the code for the entire collection in my front end to even think about using it.  (didn’t have to do that for the class!?!)

Thought about using a List array but I can’t find any examples that aren’t ASPX based.
Besides, I like the whole collection idea better because it seems cleaner to me.

I’m giving out 500 points for this question because I think this will become a running dialog over the next few days.

Help?

Thanks in advance!
0
mnichols1202
Asked:
mnichols1202
  • 5
  • 2
1 Solution
 
sagacitysolutionsCommented:
Try this

Add a web reference to your project and go from there

Some documentation:
http://www.codeproject.com/vb/net/vbwebservice.asp

0
 
sr101880Commented:
Just to be clear,  you are having trouble getting the name and id from your web service or are you having trouble putting the name and id into a combo so the user can select a customer by name?
0
 
mnichols1202Author Commented:
Both actually,  i have a class called "Customer" with all the usual info and a webmethod "GetCustomer" that take a customer id and returns a class customer (i.e looks up the appropreate data in the backend and returns the customer)
so i created a collection "Customers"  with a simple class with two properties Customer_ID and Name.

So another web method "GetCustomers" should return the collection customers.  however, the collection never shows up in intellisense (remember the Get Customer Web method is working fine - and i've refreshed the web reference)

I've been reading some fleeting passages about Web Services can only return a limited number of simple types....but i can't find anything definitive!!

0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
sr101880Commented:
Is your other web method GetCustomers in the same web service or is it in a separte web service?
0
 
sr101880Commented:
If GetCustomers is in the same web service did you declare the method using "Public" like the example below?

Public Function GetCustomer( _
 ByVal customerID As String) As DataSet
0
 
mnichols1202Author Commented:
Yes and Yes again.

The call is
<WebMethod>Public Function GetCustomers() as Customers


and

<WebMethod> Public Function GetCustomer(CustomerID as Long) as Customer

Second one works - first one doesn't even show up in the Client Object list or intellisense
0
 
sr101880Commented:
The code you gave above looks correct.  The only thing I can think of is that there isn't  a new instance of customers created before you call the method.

I have found a good example of what you are trying to accomplish for an overall goal.  It is at:  

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/webservicesdcom.asp

All you need to do is select "The xml web service" from the hyperlinks under contents.  It will give you step by step instructions to create the web service and windows app that you are looking for.  :-)

Let me know if you have any questions.
0
 
sr101880Commented:
mnichols1202,

     Did you find what you were looking for?
0

Featured Post

2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now