General discussion

Locked

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

By TonyGirgenti ·
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:
<PeriodMileageReportDataObject>
<Truckname>Adam</Truckname>
<StartOdometer>115.1</StartOdometer>
<StartTruckTime>2001-11-06T15:04:00.0000000-06:00</StartTruckTime>
<EndOdometer>67873.4</EndOdometer>
<EndTruckTime>2002-03-26T10:55:00.0000000-06:00</EndTruckTime>
<OffsetMiles>230</OffsetMiles>
<StartTime>2001-10-14T00:00:00.0000000-05:00</StartTime>
<EndTime>2002-10-14T23:59:59.0000000-05:00</EndTime>
<OrganizationName>ABC Company</OrganizationName>
<XVIN>4194334</XVIN>
<ReportType>1</ReportType>
<VIN>1FV6HJBA9XHA219</VIN>
</PeriodMileageReportDataObject>

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"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetPeriodMileageData xmlns="http://www.xatanet.net/XataNetWebService">
<startDate>string</startDate>
<endDate>string</endDate>
<organizationID>string</organizationID>
<truckname>string</truckname>
</GetPeriodMileageData>
</soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetPeriodMileageDataResponse
xmlns="http://www.xatanet.net/XataNetWebService">
<GetPeriodMileageDataResult>dataset</GetPeriodMileageDataResult>
</GetPeriodMileageDataResponse>
</soap:Body>
</soap:Envelope>

This conversation is currently closed to new comments.

6 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Just create a Web Reference

by rick1947 In reply to How do consume web servic ...

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.

Collapse -

Executing client returns error WSE402

by TonyGirgenti In reply to Just create a Web Referen ...

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

Collapse -

What does the Web Method look like?

by rick1947 In reply to Executing client returns ...

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.

Collapse -

Only developing client side

by TonyGirgenti In reply to What does the Web Method ...

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

Collapse -

Only developing client side

by TonyGirgenti In reply to What does the Web Method ...

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

Collapse -

Where to look for more information

by rick1947 In reply to Only developing client si ...

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!

Back to Web Development Forum
6 total posts (Page 1 of 1)  

Related Discussions

Related Forums