wwSoap::CallWSDLMethod

Calls a SOAP Server method based on a WSDL description. Call AddParameter for any parameters you need to add to your Methods, then call this method with the name of the method.

This method simplifies calling a SOAP service and reduces the process to setting the parameters for the call and calling this method specifying merely the method and the URL to the SDL file.

If you call only a single method on the Web Service you can pass the WSDL url to this method. Otherwise it's recommended you use loSOAP.ParseServiceWSDL(), so that the service description can be reused.

o.CallWSDLMethod(lcMethod, lvWSDLURL)

Return Value

Variant result - return value from the method call
or .F. if the call fails (like VFP does). Check lError and cErrorMsg for error information.

Parameters

lcMethod
The method to call.

lvWSDLURL
Optional - The URL to the WSDL file
or
A pre-parsed loWSDL object as returned by the ParseServiceWSDL method. This value is used by default if it exists.


Remarks

Method and parameter names must be provide in case sensitive fashion as provided by the WSDL description. Always use the same case as the WSDL file!

Calling multiple methods
If you want to call multiple methods on the same service you need to reset the parameter list by passing RESET to the AddParameter method. Notice the explicit call to ParseServiceWSDL which parses the WSDL file once and is thereafter reused for subsequent calls.

oSOAP = CREATEOBJECT("wwSOAP")
oSoap.AddParameter("lcName","Rick")
oSoap.ParseServiceWSDL("http://localhost/wconnect/soap/soapserver.wsdl")

? oSOAP.CallWSDLMethod("HelloWorld")

oSOAP.AddParameter("RESET")
oSoap.AddParameter("lnNumber1",10.2122)
oSoap.AddParameter("lnNumber2",10.1212)

*** Reuse the WSDL reference
? oSOAP.CallWSDLMethod("AddNumbers")

Return Values
Simple parameters are simply returned as their value. If you return complex parameters (DataSets, Objects, Arrays etc.) the lParseReturnedObjects flags determines if wwSOAP tries to parse the objects based on the WSDL description. If the flag is .F. or the object cannot be parsed then a DOM node to the return object is returned.

If the object can be parsed an object will be returned. The object is based on the description provided in the WSDL file. Only simple types are supported although the object can be hierarchical/nested. Arrays and Collections currently don't work - only simple types and sub objects are supported. DataSets are returned as a DOM node.

Example

oSoap = CREATEOBJECT("wwSOAP")

oSOAP.AddParameter("translationmodel","en_de")
oSoap.AddParameter("sourcedata","Hello world!")
lvResult = oSOAP.CallWSDLMethod("BabelFish","http://www.xmethods.net/sd/BabelFishService.wsdl")

IF oSOAP.lError
   MessageBox(oSOAP.cErrorMsg)
   RETURN
ENDIF

See also:

Class wwSoap

© West Wind Technologies, 1996-2024 • Updated: 10/25/04
Comment or report problem with topic