Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

PB/Win: MSSOAP client example gets random jokes

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Lance Edmonds
    replied
    Follow-up:

    If you don't have it already, the MSSOAP toolkit can be downloaded from http://download.microsoft.com/downlo...pToolkit30.EXE

    Sites such as www.salcentral.com offer loads of free SOAP services, such as stock quotes, etc.


    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • Lance Edmonds
    started a topic PB/Win: MSSOAP client example gets random jokes

    PB/Win: MSSOAP client example gets random jokes

    Code:
    '*******************************************************************
    ' Simple Object Access Protocol (SOAP) Example by Lance C. Edmonds.
    '
    ' Soap interface members are "virtual", so SOAP clients must use
    ' late-binding.  This example uses the Soap service described at 
    ' [url="http://www.salcentral.com/asp/spec.asp?WSURL=http://www.interpressfact.net/webservices/getJoke.asmx?wsdl"]Sal Central[/url].
    '*******************************************************************
     
    #INCLUDE "win32api.inc"
     
    FUNCTION ObjErr(BYVAL pbError AS LONG, BYVAL dError AS DWORD) AS STRING
        LOCAL pBuffer   AS ASCIIZ PTR
        LOCAL ncbBuffer AS DWORD
        LOCAL a$
     
        ncbBuffer = FormatMessage(%FORMAT_MESSAGE_ALLOCATE_BUFFER OR _
            %FORMAT_MESSAGE_FROM_SYSTEM OR %FORMAT_MESSAGE_IGNORE_INSERTS, _
            BYVAL %NULL, dError, BYVAL MAKELANGID(%LANG_NEUTRAL, %SUBLANG_DEFAULT), _
            BYVAL VARPTR(pBuffer), 0, BYVAL %NULL)
     
        IF pbError THEN a$ = "(PB Error =" & STR$(pbError) & ")"
     
        IF ncbBuffer THEN
            a$ = " " & @pBuffer & " (&H" & HEX$(dError, 8) & ") " + a$
            REPLACE $CRLF WITH "" IN a$
            FUNCTION = a$
            LocalFree pBuffer
        ELSE
            FUNCTION = " Unknown error (&H" & HEX$(dError, 8) & ") " + a$
        END IF
    END FUNCTION
     
     
    FUNCTION PBMAIN
        DIM oSoap AS DISPATCH
        DIM v1    AS VARIANT
        DIM v2    AS VARIANT
        DIM v3    AS VARIANT
     
        SET oSoap = NEW DISPATCH IN "MSSOAP.SoapClient"
        IF ISFALSE ISOBJECT(oSoap) THEN
            MSGBOX "Error: Soap could not be instantiated!"
            EXIT FUNCTION
        END IF
     
        LET v1="http://www.interpressfact.net/webservices/getJoke.asmx?wsdl"
        OBJECT CALL oSoap.mssoapinit(v1)
        IF ERR OR OBJRESULT THEN
            MSGBOX "oSoap.mssoapinit error:" & ObjErr(ERRCLEAR, OBJRESULT)
            EXIT FUNCTION
        END IF
         
        LET v1 = 8 ' Headlines!
        OBJECT CALL oSoap.getJoke(v1) TO v2
        IF ERR OR OBJRESULT THEN
            MSGBOX "oSoap.getJoke() error: " & ObjErr(ERRCLEAR, OBJRESULT) & STR$(VARIANTVT(v2))
            OBJECT GET oSoap.Detail TO v3
            MSGBOX "Result -> " + VARIANT$(v3)
            EXIT FUNCTION
        END IF
     
        MSGBOX VARIANT$(v2),,"Jokes via SOAP"
    END FUNCTION
    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>
Working...
X