IProxyFactory2::CreateProxy Method

HRESULT CreateProxy([in] BSTR endpointURL, [in, defaultvalue("")] VARIANT methodNameURI, [in, defaultvalue("$uri#$method")] VARIANT SOAPActionPattern, [in, defaultvalue("")] VARIANT transport, [out, retval] IDispatch	** Proxy);

This creates a new proxy object, based on the parameters. Once created calls to the proxy object are automatically translated into SOAP calls. the expandable parts of the SOAPAction pattern are $url the SOAP endpoint URL $uri the methodname URI $method the name of the method being called



BSTR, [in]: This is the URL of the SOAP server to call.
VARIANT, [in, defaultvalue("")]: This is the namespace URI for the methodName element [the actual method name is populated by the resulting proxy object based on the name of the method called against it.
VARIANT, [in, defaultvalue("$uri#$method")]: This is either a direct string value that represents the value for the SOAPAction header, or if the SOAPAction header is defined in terms of other parameters [as is the case for many SOAP servers], you can specify the a pattern for the SOAPAction and the proxy will expand the pattern into the SOAPAction for each call.
VARIANT, [in, defaultvalue("")]: This allows you to specify the transport to use when making calls. If you leave this as the default then the standard pocketSOAP HTTP transport will be used. You can pick a different transport by passing in its Prog-ID here. Or you already have an instance of the transport object created, you can pass a ISOAPTransport interface pointer.
IDispatch **, [out, retval]: The resulting SOAP Proxy object.


Return Values

An IDispatch interface pointer to the newly created proxy object is returned.


Sample Code

Dim pf As Object, sp As Object
Set pf = CreateObject("pocketsoap.Factory")

' a simple proxy configuration
Set sp = pf.CreateProxy("http://services.xmethods.net/soap", "urn:xmethods-delayed-quotes")
Msgbox sp.getQuote(symbol:="INTC")
' getQuote becomes the methodName in the SOAP request, and it will have a single parameter "symbol" with the value "INTC"
' the result of the SOAP call is passed back as the result of the method, and so the quote value for INTC gets displayed in the message box

' this uses a SOAPAction pattern, to generate the correct SOAPAction for different methods
' you will have to check the document for the server you are calling to work out the correct pattern.
set sp = pf.CreateProxy("http://example.org/", "http://soap.example.org/", "$uri$method"

' this generates a SOAPAction header of http://soap.example.org/getQuote

' this generates a SOAPAction header of http://soap.example.org/buyStock
sp.buyStock(ticker:="MSFT", shares:=200)

' use a preconfigured transport object, instead of the default
dim t
set t = CreateObject("pocketSOAP.HTTPTransport.2")
t.SetProxy "proxy.domain.com", 8080
t.ProxyAuthentication "simon", "password"
Set sp = pf.CreateProxy("http://services.xmethods.net/soap", "urn:xmethods-delayed-quotes", "", t)
' this call goes through the configured transport object, and so uses the authenticated proxy server.
Msgbox sp.getQuote(symbol:="INTC")


See Also

The IProxyFactory2 Interface | 




Copyright © Simon Fell, 2000-2004. All rights reserved.