Discussion Locked

How do consume web service using VS.NET 2003 in VB

0 helpful
6 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hello.

I'm using Visual Studio.NET Enterprise Architect 2003. I want to be able to request a web service using VB and have it return a message.

I used the walkthrough "Accessing an XML Web Service Using Visual Basic or Visual C#" VB version to create my own project.

Below is the information i got from the web services web site on requesting just one of their operations using SOAP. How do i put this into my VB project ?

Any help would be greatly appreciated.

Thanks,
Tony
=====================================================
GetPeriodMileageData
Returns the mileage data for a vehicle or all vehicles within the specified
date range.
The result dataset consists of the following elements:

Adam
115.1
2001-11-06T15:04:00.0000000-06:00
67873.4
2002-03-26T10:55:00.0000000-06:00
230
2001-10-14T00:00:00.0000000-05:00
2002-10-14T23:59:59.0000000-05:00
ABC Company
4194334
1
1FV6HJBA9XHA219

Test
The test form is only available for requests from the local machine.
SOAP
The following is a sample SOAP request and response. The placeholders shown
need to be replaced with actual values.

POST /xatanetwebservice/export.asmx HTTP/1.1
Host: www.xatanet.net
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://www.xatanet.net/XataNetWebService/GetPeriodMileageData"

string
string
string
string

HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

dataset

6 replies

by rick1947

In your client project, click on the project and select "Add Web Reference". Navigate to the web service, and then select it. Before you save it, I would suggest changing the default name (which may be localhost in a dev environment) to something more descriptive - but not the name of the class or one of the Web Methods.
Then, use:
Dim MyService As New [renamed host name].[service class name]
You will then be able to reference MyService.[Web Method name] as if it were local.

by tonygirgenti

Hello Rick.

Thanks for your reply.

I did what you sugested using the routine attached. When i run it, i get an error in Label1.Text of "Conversion failed = WSE402: The message does not conform to the policy it was mapped to."

Any help that you can provide would be gratefully appreciated.

Thanks,
Tony

==================================================
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ws As New ExportXata.Export
Dim XataTruckData As DataSet
Dim organizationID As String
Dim truckname As String
Dim LogonRet As New Object
Dim startDate As String
Dim endDate As String
organizationID = "Coyne Chemical"
truckname = "251638"
startDate = "20060201"
endDate = "20060201"

Try
XataTruckData = ws.GetPeriodMileageData(startDate, endDate, organizationID, truckname)
Catch ex As Exception
Label1.Text = "Conversion failed = " & ex.Message
End Try

End Sub

by rick1947

The error message is a policy violation from Web Services Extensions. I'm not familiar with this, but a Google search on the error message turns up a number of references.

If you are developing both sides, I would recommend first getting this working without the security policies. If you can't, then you'll have to make sure your client side conforms (encrypting messages if required, etc.)

If you do control both sides, you might want to think about returning an XML string instead of a dataset, assuming that the data is small, and doesn't require the heft of the DataSet schema. This will make your web service more interoperable, as the DataSet is purely a .NET construct.

by tonygirgenti

Hi Rick,

I'm only developing the client side.

I tried googling that error message. Yes, there a lot of hits, but a lot of them are duplicates and a lot are forum questions asked but never replied to. So far, the rest of the references don't explain to me how to incorporate WSE into my messages.

Thanks,
Tony

by tonygirgenti

Hi Rick,

I'm only developing the client side.

I tried googling that error message. Yes, there a lot of hits, but a lot of them are duplicates and a lot are forum questions asked but never replied to. So far, the rest of the references don't explain to me how to incorporate WSE into my messages.

Thanks,
Tony

by rick1947

Then, I think you'll need to go to:
http://www.microsoft.com/downloads/details.aspx?familyid=1ba1f631-c3e7-420a-bc1e-ef18bab66122&displaylang=en
to download the version of WSE (2.0) suitable for VS.NET 2003. I also recommend:
http://msdn.microsoft.com/webservices/webservices/building/wse/default.aspx
for other resources you may need. If I knew the answers, I'd be glad to give them to you, but I suspect they're out there. You should also post your question on:
microsoft.public.dotnet.framework.webservices. enhancements
You can get to this through your usual newsreader or google:
http://groups.google.com/group/microsoft.public.dotnet.framework.webservices.enhancements?start=10&hl=en
When I searched this group for WSE402, I found a number of threads.
Good luck!

This discussion is closed to new replies.