mibuso.com

Microsoft Business Solutions online community
It is currently Tue May 21, 2013 7:10 am

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: [Solved] web service example needed in visual basic
PostPosted: Tue Feb 24, 2009 11:10 am 
Offline

Joined: Tue Jul 10, 2001 7:01 am
Posts: 132
Location: Epse, Netherlands
Country: Netherlands (nl)
Hello,

I'm new in the world of web services. I tried to get the example 'Walkthrough: Registering and Consuming a Page Web Service' from the NAV 2009 Help working.
The problem is i'm not so good in the language C. I tried to convert the example to vb but that didn't success.
I want to search for all customer within a filter and get them to vb.

The following lines must do the trick in C:
// Create filter for searching for customers
List<Customer_Filter> filterArray = new List<Customer_Filter>();
Customer_Filter nameFilter = new Customer_Filter();
nameFilter.Field = Customer_Fields.Name;
nameFilter.Criteria = "C*";
filterArray.Add(nameFilter);

Can anyone help me with an example in vb which search for the customers and get them to vb.

Thanks in advance.


Last edited by elwin68 on Tue Feb 24, 2009 3:59 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: web service example needed in visual basic
PostPosted: Tue Feb 24, 2009 2:12 pm 
Offline

Joined: Tue Apr 15, 2008 11:20 am
Posts: 7
Location: Zulte
this is the VB version of the code you've posted here:

Code: Select all
dim filterArray as New List(Of Customer_Filter)
dim nameFilter as New Customer_Field()
nameFilter.Field = Customer_Fields.Name
nameFilter.Criteria = "C*"
filterArray.Add(nameFilter)


Top
 Profile  
 
 Post subject: Re: web service example needed in visual basic
PostPosted: Tue Feb 24, 2009 2:51 pm 
Offline

Joined: Tue Jul 10, 2001 7:01 am
Posts: 132
Location: Epse, Netherlands
Country: Netherlands (nl)
Thank you very much for the translation.
I think something is missing in the example of the NAV help.
The following errors occure in Visual Studio 2008:
- Type 'Customer_Filter' is not defined
- Name 'Customer_Fields' is not declared

Which lines are missing in the example so the example of the web service works?

Thanks in advance.


Top
 Profile  
 
 Post subject: Re: web service example needed in visual basic
PostPosted: Tue Feb 24, 2009 3:07 pm 
Offline
MVP Microsoft Dynamics NAV

Joined: Tue Feb 07, 2006 9:34 am
Posts: 66
Location: Moscow
Country: Russia (ru)
Did you add web reference to your web service?

Quote:
3. In Solution Explorer, right-click the References node in the project and select Add Web Reference.
Note
If you are running Visual Studio 2008, select Add Service Reference.

4. In the Add Web Reference window, type the URL that you used when checking the WSDL, for example, http://localhost:7047/DynamicsNAV/WS/Services and then click Go.
Note
In Visual Studio 2008, click the Advanced button, click the Add Web Reference button, and then type the URL, and then click Go.

5. When the Customer service is displayed, click View Service, and then click Add Reference. Rename localhost to WebService.


Top
 Profile  
 
 Post subject: Re: web service example needed in visual basic
PostPosted: Tue Feb 24, 2009 3:37 pm 
Offline

Joined: Tue Jul 10, 2001 7:01 am
Posts: 132
Location: Epse, Netherlands
Country: Netherlands (nl)
Yes, In have added the web reference. When entering the link in internet explorer the service is shown.

I have almost done the thing with the following example:

Dim ws As New Mywebservice.Customer_Binding
ws.UseDefaultCredentials = True
ws.Url = "http://localhost:7047/DynamicsNAV/WS/CRONUS_International_Ltd/Page/Customer"

Dim Cust(100) As Mywebservice.Customer
Dim wsFields As New Mywebservice.Customer_Fields
Dim wsfilter(1) As Mywebservice.Customer_Filter
wsfilter(1).Field = wsFields.Name
wsfilter(1).Criteria = "J*"
Cust = ws.ReadMultiple(wsfilter, "", 0)

For Counter = LBound(Cust) To UBound(Cust)
Me.ListBox1.Items.Add(Counter & ": " + Cust(Counter).No & "-> " & Cust(Counter).Name)
Next Counter

When leaving the 2 lines to set the filter (wsfilter(1).....), all customer appeare in the listbox.
The only thing I want to do next is the set a filter on the field name.
Does anyone know the syntax for that?

Thanks in advance.


Top
 Profile  
 
 Post subject: Re: web service example needed in visual basic
PostPosted: Tue Feb 24, 2009 3:59 pm 
Offline

Joined: Tue Jul 10, 2001 7:01 am
Posts: 132
Location: Epse, Netherlands
Country: Netherlands (nl)
Finally I found it myself:

Dim ws As New Mywebservice.Customer_Binding
ws.UseDefaultCredentials = True
ws.Url = "http://localhost:7047/DynamicsNAV/WS/CRONUS_International_Ltd/Page/Customer"

Dim Cust(100) As Mywebservice.Customer
Dim wsFilterArray As New List(Of Mywebservice.Klantje_Filter)
Dim wsFilter As New Mywebservice.Klantje_Filter()
wsFilter.Field = wsFields.Name
wsFilter.Criteria = "C*"
wsFilterArray.Add(wsFilter)
Cust = ws.ReadMultiple(wsFilterArray.ToArray, "", 0)

For Counter = LBound(Cust) To UBound(Cust)
Me.ListBox1.Items.Add(Counter & ": " + Cust(Counter).No & "-> " & Cust(Counter).Name)
Next Counter

Thanks everyone for thinking with me.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum


Search for:
Jump to: