JBoss.orgCommunity Documentation

Chapter 6. Service Development

6.1. BPEL
6.1.1. Generating WS-BPEL based Services
6.1.2. Statically Verifying the Service
6.2. SCA Java
6.2.1. Generating SCA Java based Services
6.2.2. Verifying the SCA Java implementation against a Scenario

Services can be developed by generating initial development artifacts, based on artifacts created in preceding phases (e.g. architectural model or service contracts/designs).

To ensure that the services continue to conform to the artifacts defined in the previous phases, the tools will (eventaully) perform conformance checking between the service implementation and the existing architecture/design artifacts. This is not possible with all implementation languages - they must provide the means to extract the communication structure for comparison.

The following sections explain how the generation can be achieved for the WS-BPEL and SCA Java implementations.

The tools include a capability to generate a service implementation, for a participant in a choreography, using WS-BPEL.

This section shows how to generate SCA Java based services from a choreography, add implementation details to the service and then verify it against scenarios.

In a previous section of the document, it showed how to use the Scenario (that represents a particular use case or requirement) to verify an architectural model (or choreography). The same scenarios can be used to test the service implementations generated from those architectural models or designs.

For example, to test the SCA Java implementation for the Store participants, you open the requirements/SuccessfulPurchase.scn scenario and press the green "play" button in the toolbar. This will show the 'scenario simulation' dialog. Then for the Store role, select the relevant composite file, so for the Store role locate the Store.composite file in the PurchaseGoods-Store/src/main/resources folder:

When the SCA composite has been selected, then it will automatically set the simulator to be "SCA simulator" and clear the model role - this is because the model role is not relevant as the service implementation represents a single role, rather than a collection of roles as in the case of a choreography being used for the model.

Next press the "Simulate" button. Unlike the verification against a choreography model, which is pure simulation, when the SCA simulator is used and configured with a particular SCA composite file, then the simulation is performed by executing the service implementation. The simulation output is the same though:

Note however, before being able to verify the SCA Store implementation through simulation, you will need to implement the service logic. Initially it will be created as a skeleton. The following is a completed version of the org.savara.examples.store.StoreImpl class:

package org.savara.examples.store;

import java.math.BigInteger;
import java.util.logging.Logger;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.xml.bind.annotation.XmlSeeAlso;

import org.savara.examples.creditagency.CreditAgency;
import org.savara.examples.logistics.Logistics;
import org.jboss.examples.store.AccountNotFoundType;
import org.oasisopen.sca.annotation.Reference;

 * This class was generated by Apache CXF 2.4.0
 * 2012-02-08T10:25:28.453Z
 * Generated source version: 2.4.0

                      serviceName = "StoreService",
                      portName = "StorePort",
                      targetNamespace = "http://www.savara.org/examples/Store",
                      wsdlLocation = "wsdl/PurchaseGoods_Store.wsdl",
                      endpointInterface = "org.savara.examples.store.Store")

public class StoreImpl implements Store {

    private static final Logger LOG = Logger.getLogger(StoreImpl.class.getName());

    public CreditAgency  creditAgency;

    public Logistics  logistics;

    /* (non-Javadoc)
     * @see org.savara.examples.store.Store#buy(org.jboss.examples.store.BuyRequestType  content )*
    public org.jboss.examples.store.BuyConfirmedType buy(org.jboss.examples.store.BuyRequestType content) throws InsufficientCreditFault , AccountNotFoundFault    {
        LOG.info("Executing operation buy");
        try {
        	org.jboss.examples.creditagency.CreditCheckType check=
        			new org.jboss.examples.creditagency.CreditCheckType();

        	org.jboss.examples.creditagency.CreditRatingType rating=


        	if (rating.getRating().intValue() > 5) {
	        	org.jboss.examples.logistics.DeliveryRequestType deliveryRequest=
	    			new org.jboss.examples.logistics.DeliveryRequestType();
	        	deliveryRequest.setAddress("1001 Acme Street");

	        	org.jboss.examples.logistics.DeliveryConfirmedType delivery=

	            org.jboss.examples.store.BuyConfirmedType _return =
	            		new org.jboss.examples.store.BuyConfirmedType();
	            return _return;
        	} else {
	            org.jboss.examples.store.BuyFailedType buyFailed =
	            		new org.jboss.examples.store.BuyFailedType();

	            throw new org.savara.examples.store.InsufficientCreditFault("Buy failed", buyFailed);
        } catch(org.savara.examples.creditagency.CustomerUnknownFault cuf) {
        	AccountNotFoundType anft=new AccountNotFoundType();
        	anft.setReason("Don't know you");
        	throw new AccountNotFoundFault("Account not found", anft);