Testing the Web Service Methods from the Terminal
We can test the Web service methods from terminal. To do this we will use its WSDL to generate a client. Here are the steps:
-
Use the InterSystems launcher to open the Terminal. You can use whichever namespace that you prefer.
-
Create and instance of %SOAP.WSDL.ReaderOpens in a new tab and use its Process method together with the WSDL url of the service to generate the client.
USER>Set url="http://localhost:57772/csp/user/CInfo.WebService.CLS?WSDL=1" USER>Set reader = ##class(%SOAP.WSDL.Reader).%New() USER>Write reader.Process(url) Compilation started on 09/26/2014 11:38:14 with qualifiers 'dk', compiling 2 classes, using 8 worker jobs Compiling class CompanyInfo.Address Compiling class CompanyInfo.Company Compiling routine CompanyInfo.Address.1 Compiling routine CompanyInfo.Company.1 Compilation finished successfully in 0.274s. Compilation started on 09/26/2014 11:38:14 with qualifiers 'dk' Compiling class CompanyInfo.CompanyInfoSoap Compiling routine CompanyInfo.CompanyInfoSoap.1 Compiling class CompanyInfo.CompanyInfoSoap.CreateCompanies Compiling class CompanyInfo.CompanyInfoSoap.GetCompanyInfo Compiling routine CompanyInfo.CompanyInfoSoap.CreateCompanies.1 Compiling routine CompanyInfo.CompanyInfoSoap.GetCompanyInfo.1 Compilation finished successfully in 0.168s.
-
Create an instance of the client.
USER>Set client = ##class(CompanyInfo.CompanyInfoSoap).%New()
-
Execute the CreateCompanies method to populate the database with Company instances.
USER>Write client.CreateCompanies(1000) 1000
-
Next, test GetCompanyInfo. You must pass a valid ID of a company to the method. It is likely that “1” is valid.
USER>Set company = client.GetCompanyInfo(1) USER>Write company.Name OptiTech LLC. USER>Write company.Mission Spearheading the next generation of nano-instrumentation technologies for the Fortune 50 USER>Write company.PrimaryAddress.City Pueblo