Skip to main content

Testing Complex Object Code from the Terminal

Here are the steps for testing SOAPService's SaveContact method using the Terminal:

  1. Open the Terminal in the namespace in which you are working.

  2. Use the WSDL to regenerate a client for the service and then instantiate the client. See Testing the Service from the Terminal for the steps.

  3. Enter the following commands to create a new instance of Contact and assign values to its Name and ContactType properties.

    
    USER>Set contact = ##class(SOAPTutorial.Contact).%New()
    USER>Set contact.Name = "Doe,John"
    USER>Set contact.ContactType = "Business"
    
    
  4. Enter the following command to invoke the SaveContact method, passing it the newly instantiated Contact object, and write the method's return value — the ID value of the new Contact instance. Note that the client variable represents the Web service client generated in the earlier step.

    
    USER>Set client = ##class(SOAPService.SOAPServiceSoap).%New()
    USER>write client.SaveContact(contact)
    6
    
    
  5. Use the GetContact method added earlier to retrieve the contact using the ID returned by SaveContact.

    
    USER>set contact = client.GetContact(6)
    USER>write contact.Name
    Doe,John
    
    
FeedbackOpens in a new tab