wwSoap::AddParameter

Adds a parameter to a SOAP request.

Parameters can be passed by FoxPro type or using one of the special names:

  • Automatic (FoxPro type detection)
  • <WSDL Object Name>
  • NodeList
  • Xml
  • RawXml
o.AddParameter(lcName, lvValue,lcXMLType)

Return Value

nothing

Parameters

lcName
Name of the parameter. You can also pass RESET to clear all parameters.

lvValue
The value of the parameter

lcXMLType
For simple data types this parameter is optional and if omitted the FoxPro type is determined and converted to its matching XML type.

For complex types you need to specify one of the special parameter options:

There are a few special types that are supported:

WSDL Object Type Name
If you're passing a Complex object you can pass the Fox object as the second parameter and then specify the WSDL type name EXACTLY as it exists in the WSDL definition.

Note that objects passed in this fashion must match the WSDL defined object EXACTLY in structure, otherwise the call will fail. For more info on this see the Working with Complex Objects topic.

NodeList
If you objects in XML format you should pass in an XML nodelist (for example DOM.DocumentElement.ChildNodes) of the nodes immediately below the parent object. This allows creation of proper top level node names required for the SOAP package. In this case the second parameter has to be an XMLNodeList!

Xml
Allows you to embed Nodelist XML as an XML string. This means that wwSOAP provides the root node with the field name and your code provides the XML body. The value will be emded like this:

<FieldName>
   <yourXml>
   ...
   </yourXml>
</FieldName>

RawXml
You can also pass raw XML which will embed the XML as is into the document. Note that if you do this you should make sure that the top level node matches the schema/field definition for the entity that gets embedded. In other words if the XML is generating for a field called Author, make sure the top level node is indeed called Author. The value will be emded like this:

<yourXml>
   ...
</yourXml>

Which one of these two XML approaches are used depends on what you are passing. If you're generating your own XML for passing an object then you'll likely want RawXml because the object XML starts at the name root. If you embde an XMLDOM Node type value those values get embedded underneath the fieldname. You will have to experment with the modes.

Example of passing a Raw parameter:

TEXT TO cPortNames NOSHOW
<portNames q0:arrayType="xsd:string[2]"
          xsi:type="q0:Array">
	<string xsi:type="xsd:string">Busan</string>
	<string xsi:type="xsd:string">London</string>
</portNames>
ENDTEXT


LOCAL loSoap as wwSoap
loSoap = CREATEOBJECT("wwSoap")
loSoap.cExtraEnvelopeAttributes = ;
	[ xmlns:q0="http://schemas.xmlsoap.org/soap/encoding/" ] +;
	[ xmlns:xsd="http://www.w3.org/2001/XMLSchema" ] +;
	[xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"] 
loSDL = loSoap.Parseservicewsdl("http://dist.netpas.net/NPSystem/services/NPDistance?wsdl",.t.)

loSoap.AddParameter("pinCode","DEMO")
loSoap.AddParameter("accessCode","DEMO")
loSoap.AddParameter("portNames",cPortNames,"RawXml")

result = loSoap.CallWsdlMethod("getDistance",loSdl)

Example

oSoap = CREATEOBJECT("wwSoap")

lcWSDL = "http://localhost/foxInternetopWebService.asmx?WSDL"

oSOAP.ParseServiceWSDL(lcWSDL,.T.)  && Parse Objects

*** ROPE ASP Demo
oSoap.AddParameter("lnNumber1",10)
oSoap.AddParameter("lnNumber2",5)

oSoap.AddParameter("Customer",loCustomer,"CustomerEntity")

lcXML = GetXmlToSend()
oSOAP.AddParameter("XmlNode",lcXML,"RawXML")

lcEntityXml = GetEntityXml()
oSoap.AddParameter("EntityXml",lcEntityXml,"Xml")

lvResult = oSoap.CallWsdlMethod("DoSomething")

? lvResult	
? VARTYPE(lvResult)

See also:

Class wwSoap

© West Wind Technologies, 1996-2024 • Updated: 03/20/08
Comment or report problem with topic