I've been asked to interface into a web service - i've done some searching on this forum and an xHarbour forum and recreated some of the examples that i've seen. However, when trying to interface to the web service below, i've had no joy. Could anyone have a look atthe code sample below and let me know what i need to do?
Thanks in advance
Pete
- Code: Select all Expand view
- Code Samples
Below are sample code snippets for the various web service methods. These samples are not code complete and do not contain proper null handling or error handling. These samples are purely to demonstrate request/response object usage through the web service. As the web services are still under development, there may be small changes to the web service definition going forward.
Module Setup
Imports WindowsApplication1.wsIWB_Tfr 'Import iWB Webservice Namespace
Module Module1
Dim wsiwb As New Transfer_Client 'Instantiate new iWB Transfer web service
Dim MyInstallID As New Guid("AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA")
Dim Cono As String = "HR"
Public Sub main()
'iWB Transfer web service URL can be set
wsiwb.Url = "http://is1.huntrad.net/IWB_WS_V200/Transfer_Client.asmx"
End Sub
Ticket Get
Public Function Ticket_Get_Code_Snippet() As Boolean
Dim response As transferTicketGetResponseObj
'Instantiate new request object
Dim request As New transferTicketGetRequestObj
'Construct request object
request.MyInstallID = MyInstallID 'Set MyInstallID
request.TicketObj = New dtoTicket 'Instantiate new ticket (sub)object
request.TicketObj.Cono = Cono 'Set Cono value
request.TicketObj.WBTID = 123456 'iWB Ticket Number
'Call web method
response = wsiwb.iWB_Transfer_Ticket_Get(request)
'Process response
If response.ReturnCode = False Then
'This has failed, output error type and user error message
Debug.Print(response.ErrorObj.ErrorType.ToString)
Debug.Print(response.ErrorObj.UserErrorMessage)
'exit function reporting failure
Return False
End If
'Disseminate response objects
'Note: Null object handling code is not included
Dim d 'Note: this is a dummy object variable
'Ticket object
d = response.TicketObj.WBTID 'iWB Ticket Number
d = response.TicketObj.LoadGross 'Gross weight
d = response.TicketObj.LoadNet 'Net weight
'... other fields follow
'Load unit object
d = response.LoadUnitObj.LoadID1 'Vehicle Reg
d = response.LoadUnitObj.LoadID3 'IWS Ticket Number
'Carrier Unit object
d = response.CarrierUnitObj.CarrierID1 'Container Number
d = response.CarrierUnitObj.CarrierID2 'Seal Number
d = response.CarrierUnitObj.CarrierID3 'Number of bales
'...
'Location 1 object
'Location 2 object
'Product 2 object
'exit function reporting success
Return True
End Function
End Module
Ticket Set
Public Function Ticket_Set_Code_Snippet() As Boolean
Dim response As transferTicketSetResponseObj
'Instantiate new request object
Dim request As New transferTicketSetRequestObj
'Construct request object
request.MyInstallID = MyInstallID 'Set MyInstallID
'Instantiate new ticket (sub)object
request.TicketObj = New dtoTicket
request.TicketObj.Cono = Cono 'Set Cono value
'iWB Ticket Number (zero denotes new ticket)
request.TicketObj.WBTID = 123456
request.TicketObj.IrisRef = "IWCS/HR1/54321"
request.TicketObj.LoadNet = 7654 'kilos
request.TicketObj.LoadOutDtm = Now 'transaction date/time
request.TicketObj.CollectionLocationID_Descr = "IWS Pickup Loc"
request.TicketObj.LoadProductID02_Descr = "IWS Product Desc"
'...other fields should be populated...
'Instantiate new load unit(sub)object
request.LoadUnitObj = New dtoLoadUnit
request.LoadUnitObj.LoadID1 = "Vehicle Reg"
'*** IWS TICKET NUMBER IS SET HERE
request.LoadUnitObj.LoadID3 = "IWS Ticket Number"
'*** IWS TICKET NUMBER IS SET HERE
'Only instantiate carrier unit if a container is being used
If CarrierExists = True Then
request.CarrierUnitObj = New dtoCarrierUnit
request.CarrierUnitObj.CarrierID1 = "Container No"
request.CarrierUnitObj.CarrierID2 = "Seal No"
request.CarrierUnitObj.CarrierID3 = "No of bales"
End If
'Call web method
response = wsiwb.iWB_Transfer_Ticket_Set(request)
'Process response
If response.ReturnCode = False Then
'This has failed, output error type and user error message
Debug.Print(response.ErrorObj.ErrorType.ToString)
Debug.Print(response.ErrorObj.UserErrorMessage)
'exit function reporting failure
Return False
Else
'*** iWB TICKET NUMBER IS RETURNED HERE
d = response.WBTID
'*** iWB TICKET NUMBER IS RETURNED HERE
Return True
End If
End Function
Ticket Cancel
Public Function Ticket_Cancel_Code_Snippet() As Boolean
Dim response As transferTicketCancelResponseObj
'Instantiate new request object
Dim request As New transferTicketCancelRequestObj
'Construct request object
request.MyInstallID = MyInstallID 'Set MyInstallID
'Instantiate new ticket (sub)object
request.TicketObj = New dtoTicket
request.TicketObj.Cono = Cono 'Set Cono value
request.TicketObj.WBTID = 123456 'iWB Ticket Number
'Call web method
response = wsiwb.iWB_Transfer_Ticket_Cancel(request)
'Process response
If response.ReturnCode = False Then
'This has failed, output error type and user error message
Debug.Print(response.ErrorObj.ErrorType.ToString)
Debug.Print(response.ErrorObj.UserErrorMessage)
'exit function reporting failure
Return False
Else
'Ticket cancelation success
Return True
End If
End Function
Contract List
Public Function Contract_List_Code_Snippet() As Boolean
Dim response As transferContractListResponseObj
'Instantiate new request object
Dim request As New transferContractListRequestObj
'Construct request object
request.MyInstallID = MyInstallID 'Set MyInstallID
'Instantiate new query (sub)object
request.QueryObj = New oDesktopQueryObject
request.QueryObj.Cono = Cono
'Call web method
response = wsiwb.iWB_Transfer_ContractList(request)
'Process response
If response.ReturnCode = False Then
'This has failed, output error type and user error message
Debug.Print(response.ErrorObj.ErrorType.ToString)
Debug.Print(response.ErrorObj.UserErrorMessage)
'exit function reporting failure
Return False
Else
Dim row As desktopDB.sp_vContract_UnionRow
'Eunumerate returned contract data table
For Each row In response.ContractDataTableObj
d = row.IrisRef
d = row.CollectionDesc
d = row.DestinationDesc
d = row.MaterialDesc
d = row.startdate
'...other fields available
Next
Return True
End If
End Function
Load Pass List
Public Function LoadPass_List_Code_Snippet() As Boolean
Dim response As transferLoadPassListResponseObj
'Instantiate new request object
Dim request As New transferLoadPassListRequestObj
'Construct request object
request.MyInstallID = MyInstallID 'Set MyInstallID
'Instantiate new query (sub)object
request.QueryObj = New oDesktopQueryObject
request.QueryObj.Cono = Cono
'Call web method
response = wsiwb.iWB_Transfer_LoadPassList(request)
'Process response
If response.ReturnCode = False Then
'This has failed, output error type and user error message
Debug.Print(response.ErrorObj.ErrorType.ToString)
Debug.Print(response.ErrorObj.UserErrorMessage)
'exit function reporting failure
Return False
Else
Dim listitem As dtoLoadPass
'Eunumerate returned list of Load Pass objects
For Each listitem In response.LoadPassListObj
d = listitem.note_id
d = listitem.IrisRef
d = listitem.startdate
d = listitem.enddate
'...other fields available
Next
Return True
End If
End Function