wwSoap::CreateObjectXmlFromSchema

Creates Xml from an object with proper case field names based on the WSDL schema definition of the Web Service.

This method needs to be used to create object graph XML IF the Web Service uses properties/fields in passed objects that require mixed or upper case field names. Since VFP cannot generate mixed case property names to be returned by AFIELDS() this method works around this by walking over the schema and pulling in properties based on the schema.

Note: You have to first call the ParseServiceWsdl method to cause the objects to get loaded:

loSoap.Parseservicewsdl(lcWSDL,.T.)

This method is used internally if you use AddParameter() and pass a WSDL custom type.

o.CreateObjectXmlFromSchema(loObject,lcTypeName,lcFieldName)

Parameters

loObject
Object reference to be turned into XML

lcTypeName
Name of the type as defined in the WSDL file.

lcFieldName
Optional - name of the root node. If not specified same as the typename.

lnIndent
Optional - Indentation of XML node

Remarks

Note you have to create the object to match the schema exactly.

Example

LOCAL loSoap as wwSOAP
loSoap = CREATEOBJECT('wwSoap')

*** Must first read the WSDL file!
loSoap.Parseservicewsdl(lcWSDL,.T.)

loAuthor = GetAuthorProxyObject()
loAuthor.au_lname = "Strahl"
loAuthor.au_fname = "Rick"
loAuthor.Phone = "808 123-1211"
loAuthor.Address = "32 Kaiea Place"
loAuthor.City = "Paia"
loAuthor.State = "HI"
loAUthor.Zip = "96779"
loAuthor.Contract = 0

lcXML = loSOAP.CreateObjectXmlFromSchema(loAuthor,"AuthorEntity")

? lcXML
RETURN

FUNCTION GetAuthorProxyObject()

*** Manunally parse the result back into an object
loAuthor = CREATEOBJECT("Relation")
loAuthor.AddProperty("Au_id","")
loAuthor.AddProperty("Au_lname","")
loAuthor.AddProperty("Au_fname","")
loAuthor.AddProperty("Phone","")
loAuthor.AddProperty("Address","")
loAuthor.AddProperty("City","")
loAuthor.AddProperty("State","")
loAuthor.AddProperty("Zip","")
loAuthor.AddProperty("Contract",.f.)

loAuthor.AddProperty("PhoneNumbers",CREATEOBJECT("RELATION"))
loAuthor.PhoneNumbers.AddProperty("HomePhone","")
loAuthor.PhoneNumbers.AddProperty("WorkPhone","")
loAuthor.PhoneNumbers.AddProperty("Fax","")
loAuthor.PhoneNumbers.AddProperty("ServiceStarted",DATETIME())


*** Code to add an array for invoices
loAuthor.AddProperty("Invoices")
*DIMENSION loAuthor.Invoices[2]


*LOCAL loInvoices as Collection
loAuthor.Invoices = CREATEOBJECT("Collection")

loInv = CREATEOBJECT("Empty")
ADDPROPERTY(loInv,"InvoiceNumber","")
ADDPROPERTY(loInv,"InvoiceDate",{05/10/2004 :})
ADDPROPERTY(loInv,"InvoiceTotal",0.00)

loAuthor.Invoices.Add(loInv)
*loAuthor.Invoices[1] = loInv


loInv = CREATEOBJECT("Empty")
ADDPROPERTY(loInv,"InvoiceNumber","")
ADDPROPERTY(loInv,"InvoiceDate",{01/10/2004 :})
ADDPROPERTY(loInv,"InvoiceTotal",0.00)

*loAuthor.Invoices[2] = loInv
loAuthor.Invoices.Add(loInv)

RETURN loAuthor


See also:

Class wwSoap

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