Skip to main content

Add the MVBasic Code

The next step is to create the Search method. Before coding the method, set the value of the language keyword for the class to mvbasic. Change the class declaration for Services to the following:


Class MVFILE.Services Extends %SOAP.WebService 
[language=mvbasic, ProcedureBlock ]
 

Note that at this stage the class does not compile. In order to compile you must replace the Quit statement in Search with a RETURN statement.

Next, add three arguments to the method's argument list. The method declaration looks like this.


Method Search(ID As %String, ATTRNAME As %String, VNO As %String) 
As %String [ WebMethod ]

Note the following about the method declaration:

  • The method accepts three arguments representing an MVFILE.PERSON ID, an attribute name, and an attribute subvalue number.

  • The method is tagged with the WebMethod keyword. This means that Caché exposes it as a Web Service.

Finally, add the body to the method:


Method Search(ID As %String, ATTRNAME As %String, VNO As %String) 
As %String [ WebMethod ]
{
OPEN "DICT", "PERSON" ELSE RETURN "DICT Not Open"
READV ATTR.AMC FROM ATTRNAME,2
OPEN "PERSON" TO PERSFILE ELSE RETURN "File Not Open"
READV ATTR FROM PERSFILE,ID, ATTR.AMC
VM=CHAR(253)
VALUE = FIELD(ATTR,VM,VNO)
RETURN VALUE
}

The method returns the specified attribute value (or subvalue) of the specified MVFILE.PERSON record.

FeedbackOpens in a new tab