Skip to main content

Testing the Service from the Terminal

Using the Terminal we can generate a client for the Web Service based on its WSDL. Open the Terminal in any namespace and set a variable to the value of the url of the WSDL for the Web Service. Note that the port number for the for the url and the name of the namespace you use might differ from what is shown here:


USER>Set url="http://localhost:57772/csp/tutorials/SOAPTutorial.SOAPService.cls?WSDL=1"

Create an instance of %SOAP.WSDL.ReaderOpens in a new tab and use its Process method to generate a client for the service.


USER>Set reader=##class(%SOAP.WSDL.Reader).%New()
USER>Write reader.Process(url)
Compilation started on 09/25/2014 09:48:38 with qualifiers 'dk', compiling 2 classes, using 8 worker jobs
Compiling class SOAPService.PhoneNumber
Compiling class SOAPService.Contact
Compiling routine SOAPService.PhoneNumber.1
Compiling routine SOAPService.Contact.1
Compilation finished successfully in 0.296s.

Compilation started on 09/25/2014 09:48:38 with qualifiers 'dk'
Compiling class SOAPService.SOAPServiceSoap
Compiling routine SOAPService.SOAPServiceSoap.1
Compiling class SOAPService.SOAPServiceSoap.GetContact
Compiling class SOAPService.SOAPServiceSoap.Test
Compiling routine SOAPService.SOAPServiceSoap.GetContact.1
Compiling routine SOAPService.SOAPServiceSoap.Test.1
Compilation finished successfully in 0.641s.
1

Next, create an instance of the generated client and invoke its Test method. It should return “Test”.


USER>Set client=##class(SOAPService.SOAPServiceSoap).%New()
USER>Write client.Test()
Test

Finally, use the client to test the GetContact method, passing it “1”. This will return a Contact instance. You can access its Name and PhoneNumbers properties.


USER>Set contact=client.GetContact(1)
USER>Write contact.Name
Campos,Debby A.
USER>Write contact.PhoneNumbers.GetAt(1).Number
886-391-4821

Note:

In order for the GetContact method to return a contact, the sample application must be populated. See Compiling and Populating the Sample Application for instructions.

FeedbackOpens in a new tab