源码介绍
PocketSoap interface for Pocket PowerBuilder
Abstract
This external DLL provides a simple access to the PocketSoap package.
The model for the API is that first the service object is created and you are given the access handle. Then you can set the various attributes in whatever order you desire. Internally, the attributes are simply stored for later use. Then you make the SOAP call. This uses the previously set attributes. Finally, you destroy the service object, which cuts away all the previously created COM objects.
Pocket Soap Project
All this is built on top of the PocketSoap system. Retrieve from www.pocketsoap.com and install both on the desktop and CE machines.
This has been tested with PocketSoap version 1.4.2
Making Available To Pocket PowerBuilder
All these can be made accessible from PocketBuilder as a global external function. In the "Application object", select "(Declare)" and the "Global External Functions".
Paste this into the editor (may need to be changed for your requirements and any interface drift):
// External Functions all in library "PKSoapif.DLL"
FUNCTION integer PocketSoap_Create( boolean fInProc, REF long lHandle ) library "PKSoapif.dll"
FUNCTION integer PocketSoap_Destroy( long lHandle ) library "PKSoapif.dll"
FUNCTION integer PocketSoap_SetProxy( long lHandle, readonly string pszProxyServer, long iProxyPort ) library "PKSoapif.dll"
FUNCTION integer PocketSoap_SetProxyAuthentication( long lHandle, readonly string pszUsername, readonly string pszPassword ) library "PKSoapif.dll"
FUNCTION integer PocketSoap_SetAuthentication( long lHandle, readonly string pszUsername, readonly string pszPassword ) library "PKSoapif.dll"
FUNCTION integer PocketSoap_SetMaxRedirects( long lHandle, long cRedirects ) library "PKSoapif.dll"
FUNCTION integer PocketSoap_SetTimeout( long lHandle, long cSeconds ) library "PKSoapif.dll"
FUNCTION integer PocketSoap_SetEndPoint( long lHandle, readonly string pszEndPointURL ) library "PKSoapif.dll"
FUNCTION integer PocketSoap_SetSoapAction( long lHandle, readonly string pszAction ) library "PKSoapif.dll"
FUNCTION integer PocketSoap_GetHTTPStatus( long lHandle, REF long lStatus ) library "PKSoapif.dll"
// Actually make the SOAP call
FUNCTION integer PocketSoap_SimpleCall( long lHandle, &
readonly string pszNameSpaceURI, &
readonly string pszMethodName, &
readonly string pszArgName, &
readonly string pszArgValue ) library "PKSoapif.dll"
FUNCTION integer PocketSoap_Call( long lHandle, &
readonly string pszNameSpaceURI, &
readonly string pszMethodName, &
readonly string pszArgString ) library "PKSoapif.dll"
// All the get result calls have a caller (PB) allocated buffer.
FUNCTION integer PocketSoap_GetResult( long lHandle, &
long cRetBufLen, REF string pszReturnValue ) library "PKSoapif.dll"
FUNCTION integer PocketSoap_GetResults( long lHandle, &
long cRetBufLen, REF string pszReturnValue ) library "PKSoapif.dll"
Pocket PowerBuilder Sample
A sample to retrieve a single stock quote...
string sMethod = "getQuote"
string sEndPoint = "http://services.xmethods.net/soap"
string sNameSpace = "urn:xmethods-delayed-quotes"
int cRetBufLen = 128
string sArgs
string sResult
long lHandle
int iRet
iRet = PocketSoap_Create( true, REF lHandle )
iRet = PocketSoap_SetEndPoint( lHandle, sEndPoint )
// preallocate the result string
sResult = Space( cRetBufLen )
// make a "simple call"
iRet = PocketSoap_SimpleCall( lHandle, sNameSpace, sMethod, "symbol", "SY" )
iRet = PocketSoap_GetResult( lHandle, cRetBufLen, REF sResult )
lb_1.addItem( "Value: [" + sResult + "]" )
iRet = PocketSoap_Destroy( lHandle )