Business Component - Publication as Web Service

Official Content
This documentation is valid for:

To publish a business component as a Web Service in order to bring the possibility of inserting, modifying and deleting the database, you have to:

1) set the Business component property of the transaction to True
2) set the Expose as Web Service property of the transaction to True.

Once these properties are set, you have to generate and compile the transaction, so that the web service associated to the transaction is generated and transfered to the corresponding directory (as every generated web object is transfered).

The name of the generated program will be:

  • In .Net Enviroment: TransactionName_bc (i.e. : customer_bc)
  • In Java Enviroment: TransactionName_bc_ws (i.e. : customer_bc_ws)

By adding the WSDL parameter to the URL in the browser (i.e. : http://localhost/BillingSystem.NetEnvironment/customer_bc.aspx?wsdl) you can see all the information that describes the web service (it's location, methods, parameters, etc.).

The following methods will be offered:

  • LoadKeySvc
  • SaveSvc
  • CheckSvc
  • DeleteSvc

These methods -as it's names let see- offer the same as the LoadSaveCheck and Delete business component methods.

Important: The only difference between the web service methods we are introducing and the common business component methods, is that the web service methods execute commit after executing their operations.

Let's suppose now that in another Knowledge Base we want to consume the web service published. In that Knowledge Base, we have to select in the GeneXus Menubar: Tools / Application Integration / WSDL Import. Then, the WSDL Import Wizard will be opened:

WSDL Import Wizard

In the WSDL Location file field, we have to enter the URL where the web service is published with the wsdl parameter (i.e. : http://localhost/BillingSystem.NetEnvironment/customer_bc.aspx?wsdl)

In the second page of the WSDL Import Wizard we have to enter the name of the external object (EO) which will be created in the KB in order to store all the information related to the Web Service (name, properties, methods, parameters, etc.). Also, an SDT similar to the transaction structure is created in the KB (the SDT has one property for each attribute and another property for each old value of each attribute (named: AttributeName_Z). In case of multi-level transactions, besides the first level SDT, nested collections are defined.

Thus, we will be able to define variables based on that external object, and invoke the web service methods.

Examples

1) Invoking a remote service to insert a Customer

&ws.LoadKeySvc(10,&Customer)
&Customer.CustomerName = 'Susan Parker'
&ws.SaveSvc(&Customer)

Where:

&ws
    Is based on the external object created in the KB.

&Customer
    Is based on the SDT created by the WSDL Import Wizard when the Wsdl was consumed.

2) Invoking a remote service to insert an Invoice

&Invoice.InvoiceId = 111
&Invoice.CustomerId = 1

&Invoiceline.Mode = 'INS'
&Invoiceline = new()
&Invoiceline.ProductId = 1
&Invoiceline.InvoiceLineQuantity = 10
&Invoice.InvoiceLevel.Add(&Invoiceline)

&Invoiceline = new()
&Invoiceline.ProductId = 2
&Invoiceline.InvoiceLineQuantity = 20
&Invoice.InvoiceLevel.Add(&Invoiceline)

&ws.SaveSvc(&Invoice)  

Where:

&Invoice and InvoiceLine
    Are based on the SDT created by the WSDL Import Wizard when the Wsdl was consumed. 

&ws 
    Is based on the external object created in the KB.

3) Invoking a remote service to update an invoice line

&Invoice.InvoiceId = 111
&ws.LoadKeySvc(&Invoice.InvoiceId,&Invoice)  

For &Invoiceline in &Invoice.Level
  IF &Invoiceline.ProductId = 1
        &Invoiceline.InvoiceLineQuantity = 5
        &InvoiceLine.Modified = 1
  Endif
endfor
&ws.SaveSvc(&Invoice)  

Where:

&Invoice and InvoiceLine
    Are based on the SDT created by the WSDL Import Wizard when the Wsdl was consumed. 

&ws 
    Is based on the external object created in the KB.


Was this page helpful?
What Is This?
Your feedback about this content is important. Let us know what you think.