Multiple methods in Web services

Unofficial Content

Versión en Español

Web Services use to have many methods in order to make them easier to understand and use. In that way, for example, we can have a CustomerServices service with methods BasicInformation and PurchaseHistory. Code in CustomerService procedure (service) will look like the following.

// CustomerServices services
…
Stub BasicInformation( in:&CustomerId, out:&BasicInformation)
   For each
	// Navigation to populate &BasicInformation
   Endfor
EndStub

Stub PurchaseHistory( in:&CustomerId, out:&PurchaseHistory)
   For each
	// Navigation to populate &PurchaseHistory
   Endfor
EndStub

The WSDL generated for a service having multiple methods like the above can be inspected by other GeneXus Knowledge Bases (Tools/Application Integration/WSDL Import), generating an external object having service's methods that is used as shown in the example below.

&CustomerServices = new() 							// &CustomerServices’ data type is CustomerServices (the imported External Object)
&CustomerBasicInformation = &CustomerServices.BasicInformation( 1)
// Process information of Customer with Id = 1.

&CustomerBasicInformation = &CustomerServices.PurchaseHistory( 2)
// Process PurchaseHistory of Customer with Id = 2

In the same way, the generated service can be inspected and consumed by programming languages like C#, Java, etc.

Notes/Usage

  • Objects with Stubs do _not_ expose the “execute” method.

If necessary (for compatibility) you must define a Stub with that name (execute).

  • Parameters defined in the parm() rule are _not_ Stubs parameters too
  • Stub objects must not have code out of the Stub/EndStub scope.

Availability

Stubs and Web services with multiple methods was implemented in .Net and Java generators as of GeneXus X Evolution 1 Upgrade 2. In previous versions, Web services had only one method named “execute”.