Skip to main content

Working with Complex Objects

The SOAPService GetContact method returned a complex object instance — an instance of Contact. Caché Web Service methods can also accept complex objects as arguments. As with complex object return values, the complex object type for the argument must be XML-enabled. That is, it must extend %XMLAdaptor.

The following method, SaveContact, accepts a Contact instance as a parameter and saves it to the database. The method returns the ID value of the newly created Contact instance.

Using the Studio Class Editor, add the following method to your SOAPService class. Recompile the class by clicking Build —> Compile.


Method SaveContact(contact As SOAPTutorial.Contact) 
As %Integer [ WebMethod ]
{
 set sc = contact.%Save()
 if sc {
  quit contact.%Id()
 } 
 else {
  quit 0
 }
}
FeedbackOpens in a new tab