Web Service Help

Web Service Help

Postby PeterHarmes » Fri Oct 22, 2010 2:29 pm

Hi,

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

 
PeterHarmes
 
Posts: 363
Joined: Wed Feb 15, 2006 2:06 pm
Location: Oxford, England

Re: Web Service Help

Postby pcordonet » Fri Oct 22, 2010 4:04 pm

Esta seria la Una llamada de la Clase 'iWB_Transfer_TicketList_MonthCurrent'

Despues, el trabajo és para ti, una llama de ejemplo seria,
Code: Select all  Expand view

Function FXHB_CALL_iWB_Transfer_TicketList_MonthCurrent( )
Local cXMLDoc,oXMLDoc,success

cXMLDoc:= FXHB_REQUEST_iWB_Transfer_TicketList_MonthCurrent( )

objXMLHTTP := TOLEAUTO():New( "Microsoft.XMLHTTP" )
objXMLHTTP:open( "post", "http://is1.huntrad.net/IWB_WS_V200/Transfer_Client.asmx", .f. )
objXMLHTTP:setRequestHeader("content-type","application/soap+xml; charset=utf-8")
objXMLHTTP:setRequestHeader("Content-Length","length")
objXMLHTTP:setRequestHeader("SOAPAction",'"http://transfer.HuntRAD.net/webservices/iWB_Transfer_TicketList_MonthCurrent"')
objXMLHTTP:send( cXMLDoc )

If objXMLHTTP:status == 200
    /*
    Devuelve esto :    
        <?xml version="1.0" encoding="utf-8"?>
        <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
          <soap12:Body>
            <iWB_Transfer_TicketList_MonthCurrentResponse xmlns="http://transfer.HuntRAD.net/webservices">
              <iWB_Transfer_TicketList_MonthCurrentResult xmlns="http://iWB.DataTypes.Contract.Transfer.Ticket/2010/08" />
            </iWB_Transfer_TicketList_MonthCurrentResponse>
          </soap12:Body>
        </soap12:Envelope>
    */

    MemoWrit("Response.xml",objXMLHTTP:responseText)

EndIf

Return success
Function FXHB_REQUEST_iWB_Transfer_TicketList_MonthCurrent( )
Local oXmlDoc,oXmlEnv,oXmlBody,oXmlMethod,oXmlRequest,cXml:=""

// Create empty XML document with header
oXmlDoc  := TXmlDocument():new( '<?xml version="1.0" encoding="utf-8"?>' )

oXmlEnv:= TXmlNode():new( ,'soap12:Envelope',{ "xmlns:xsi"=> "http://www.w3.org/2001/XMLSchema-instance" , "xmlns:xsd" => "http://www.w3.org/2001/XMLSchema","xmlns:soap12" =>"http://www.w3.org/2003/05/soap-envelope"  } )
oXmlDoc:oRoot:addBelow( oXmlEnv )

// copy structure information to XML
oXmlBody := TXmlNode():new( , "soap12:Body" )
oXmlEnv:addBelow( oXmlBody )

// copy structure information to XML
oXmlMethod := TXmlNode():new( , "iWB_Transfer_TicketList_MonthCurrent", { "xmlns" => "http://transfer.HuntRAD.net/webservices" } )
oXmlBody:addBelow( oXmlMethod )

// copy structure information to XML
oXmlRequest:= TXmlNode():new( , "Request", { "xmlns" => "http://iWB.DataTypes.Contract.Transfer.Ticket/2010/11" } )
oXmlMethod:addBelow( oXmlRequest )

cXml:=  oXmlDoc:toString(  4 )
 
return cXml

 


Espero que te funcione correctament.
Pere
pcordonet
 
Posts: 111
Joined: Sat Jan 30, 2010 8:35 am
Location: Girona


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 42 guests