TUESDAY, FEBRUARY 07, 2012




MY ACCOUNT LOGIN

LOGIN NAME:

PASSWORD:

REGISTER TODAY!
FORGOT YOUR PASSWORD?
TRY ALL WEB SERVICES
FREE FOR 30 DAYS!

WEB SERVICES

XWEBEMAILVALIDATION [tool]

XWEB1003 [real estate]

XWEBACHDIRECTORY [financial]

XWEBCHECKOUT [ecommerce]

XWEBTD [ecommerce]

XWEBNEWS [content mgmt.]


ANNOUNCEMENTS


NEW IMPLEMENTATION GUIDE AVAILABLE: "XWEBTD DESKTOP CLIENT"

XWEBTD LAUNCHED



Web Services, SOA Solutions & Services, Cloud Computing - XWebServices Inc.


HOME

WEB SERVICES

SOA SOLUTIONS

SOA SERVICES

ABOUT US





XWEBTD


Documentation


FAQs


Implementation Guides


Forum


Pricing






SEARCH









HOME  ::  WEB SERVICES  ::  XWEBTD  ::  IMPLEMENTATION GUIDES

:: 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

  • In your project, add a Windows Form. This Form will submit the request and display the result. Here are 2 ways you can accomplish this:

    • Browse the Solution Explorer, right click the name of your project, and select Add - Add Windows Form....
    • From the File Menu, select Project - Add Windows Form....

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:

    'create proxy
    Dim avaiProxy As New Availability.AvailabilityPortWse

    'add authentification token
    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

    'create availability request 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

    'create RequestAvailabilityType object
    Dim avaiRequest As New Availability.RequestAvailabilityType
    avaiRequestObj.RequestAvailability = avaiRequest
    'create header object
    avaiRequest.Header = New Availability.RequestHeaderType
    avaiRequest.Header.TransControlID = "<TransControlID>"
    'create detail object
    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>
    'create summary object
    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.

    'store the response in a variable
    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.



HOME
WEB SERVICES
SOA SOLUTIONS
SOA SERVICES
MY ACCOUNT
ABOUT US