:: XWebTD :: Implementation Guides ::
|
Get Item Availability from Tech Data's warehouses
|
|
The procedures in this implementation guide require that you have some knowledge of
Windows Forms development with the Microsoft Visual Basic.NET development tool.
The steps in this "how-to" implementation guide are:
To download the source code for this "how-to" implementation guide, as well as for additional
hints and tips, please read our Final Notes.
|
 |
Add a "Web Reference" to the XWebTD Availability Web Service WSDL
-
In your project, add a Web Reference to the XWebTD Availability Web Service WSDL. Here are 2 ways you can
accomplish this:
- Browse the Solution Explorer, right click on References and select
Add Web Reference... from the drop down menu.
- From the File Menu, select Project - Add Web Reference....
The Add Web Reference pop-up window will open. In the URL textbox, enter the following URI:
http://ws.xwebservices.com/XWebTD/V1/Availability.wsdl
- Hit the Enter key or click the Go button located to the right of the URL textbox.
- Change the Web reference name to Availability for easier reference.
- Click the Add Reference button to complete this step.
|
 |
Add a "Windows Form" to the Application
|
 |
Write code in the "Codebehind" of the form to obtain quantities of available items by consuming the Web Service
Based on the documentation for the XWebTD Availability Web Service, in order to successfully consume the Web Service, we will
need to authenticate first using WS-Security Username Token. Here's how:
Since the Web Service requires WS-Security Username Token for authentication purposes, we must first configure the project to use WSE:
- Right click the project and select WSE Settings.
- On the General tab of WSE Settings window check 'Enable this project for Web Services Enhancements'
- Open the "Codebehind" of the form we added to the web project in the
previous step.
-
Next, we need to create a new instance of the proxy class and add authentication token to it:
Dim avaiProxy As New Availability.AvailabilityPortWse
avaiProxy.RequestSoapContext.Security.Tokens.Add(New Microsoft.Web.Services2.Security.Tokens.UsernameToken(System.Configuration.ConfigurationSettings.AppSettings("LOGIN_NAME"), System.Configuration.ConfigurationSettings.AppSettings("PASSWORD"), Microsoft.Web.Services2.Security.Tokens.PasswordOption.SendHashed))
-
Then create a new AvailabilityRequest object
Dim avaiRequestObj As New Availability.AvailabilityRequest
-
Next, create a new RequestAvailabilityType object assign it to AvailabilityRequest object created in the previos step and set request data for Header, Detail and Summary
Dim avaiRequest As New Availability.RequestAvailabilityType
avaiRequestObj.RequestAvailability = avaiRequest
avaiRequest.Header = New Availability.RequestHeaderType
avaiRequest.Header.TransControlID = "<TransControlID>"
Dim avaiRequestInfoLines(0) As Availability.RequestLineInfoType
avaiRequest.Detail = avaiRequestInfoLines
avaiRequestInfoLines(0) = New Availability.RequestLineInfoType
avaiRequestInfoLines(0).AssignedID = "<AssignedID>"
avaiRequestInfoLines(0).RefID = "<RefID>"
avaiRequestInfoLines(0).RefIDQual = <RefIDQual>
avaiRequest.Summary = New Availability.RequestSummaryType
avaiRequest.Summary.NbrOfSegments = <NumberOfSegments>
-
We are now ready to call the method on the proxy class that communicates with the Web Service method and returns the availability of the items we requested.
Dim avaiResponseObj As Availability.AvailabilityResponse
avaiResponseObj = avaiProxy.Availability(avaiRequestObj)
|
 |
Final Notes
The source code for this "how-to" implementation guide can be downloaded by clicking the link
below (zip file)
XWebTDDesktopClient.zip
It's always good practice to implement a Try...Catch... error handling technique to handle some or all
possible errors that may occur while the code is executing. We strongly recommend that you implement such
a technique.
|