Exercises
Exercise 1: Add a Web Method to SOAPTutorial.SOAPService that adds a PhoneNumber object to a Contact object specified by the client. The method should satisfy the following requirements:
-
Its name is AddPhoneNumber.
-
It receives both a SOAPTutorial.PhoneNumber object and a %StringOpens in a new tab value (representing the ID of a SOAPTutorial.Contact) from the client. It adds the PhoneNumber object to the PhoneNumbers array of the Contact with the specified ID value.
-
It uses the Contact %Save method to save the changes to the database.
-
The method returns the Contact ID value if the operation is successful and 0 otherwise.
-
Test the method using the Terminal. Why are you unable to test the method using the Web Service Test page?
Exercise 2: Add a Web Method to SOAPTutorial.SOAPService that returns all Contact instances with a value for ContactType that is specified by the client. The method should satisfy the following requirements:
-
Its name is GetContactByType.
-
The method accepts an argument of type %StringOpens in a new tab that specifies the ContactType value.
-
The method returns a list of objects containing the Contact instances with the specified ContactType value. Be sure that the method returns a list of objects rather than an %XML.DataSetOpens in a new tab object.
-
The method uses Dynamic SQL to retrieve the Contact instances with the specified ContactType value. To learn more about Dynamic SQL, read Using Dynamic SQL in Using Caché SQL.
-
Test the method using the Web Services Test Page.