Show TOC Start of Content Area

Procedure documentation Providing TU&C/C Web Services  Locate the document in its SAP Library structure

Use

You can provide a TU&C/C Web service based on the WSDL document of a Service Interface modeled in the ESR with an interface pattern TUCC. In this case, after the generation of the outside-in Web service, the Web service framework generates a Java Bean skeleton which contains annotations for all the configurations relevant for this interface pattern. You only have to provide an implementation to the business methods in the implementation bean.

More information about interface patterns: Enterprise Services Repository for SAP NetWeaver CE Developer's Guide Enterprise Services Repository Defining Design Objects for Specifying Applications Defining the Service Structure with Interface Objects Developing Service Interfaces Interface Pattern.

Note

If you want to provide the TU&C/C Web service in a cluster environment, you have to enable session handling for the Web service manually by using the @SessionHandlingDTannotation. More information: Configuring Stateful Communication.

Alternatively, you can provide a TU&C/C Web service by using the inside-out approach starting from a Web service implementation. You can also provide a TU&C/C Web service starting from a WSDL document (outside-in approach) of a Service Interface which was not modeled in the ESR and does not have the settings relevant for TU&C/C communication. In these two cases, you have to use SAP-specific annotations to apply the necessary configuration settings.

More information about creating outside-in Web services: Providing Web Services Outside In.

More information about creating inside-out Web services: Providing Web Services Inside Out.

Prerequisites

The implementation bean of the Web service is available.

Procedure

       1.      In the application-j2ee-engine.xml file of the EAR containing the Web service, add a runtime reference to the WS-RM application on the application server as shown in the code sample below:

Syntax

<?xml version="1.0" encoding="UTF-8"?>

<application-j2ee-engine xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="application-j2ee-engine.xsd">

  <reference reference-type="hard">

    <reference-target target-type="application" provider-name="sap.com">tc~esi~esp~wsrm~app</reference-target>

  </reference>

</application-j2ee-engine>

       2.      Communication using TU&C/C runs on top of WS-RM-enabled communication. This is why WS-RM needs to be enabled for all compensate and confirm service methods in the implementation bean for which you also want to use TU&C/C.

The code sample below shows the implementation bean of a WS-RM-enabled Web service which can provide its functionality over TU&C/C respectively.

       WS-RM is enabled for the compensate and confirm methods via the @RelMessagingNW05DTOperation(enableWSRM=true) annotation provided by SAP. More information about enabling WS-RM for a Web service: Configuring Web Services Reliable Messaging.

       For WS-RM to be enabled for the methods, they have to return void and their Message Exchange Pattern (MEP) has to be set to one-way via the standard @Oneway annotation. More information about setting a one-way MEP, see Configuring a One Way Message Exchange Pattern.

In addition, if you want to provide the TU&C/C Web service in a cluster environment, stateful communication has to be enabled for the Web service by using the @SessionHandlingDTannotation.

Note

When you provide the implementation of a Web service generated from a WSDL document with the interface pattern TUCC in the ESR, make sure you leave the signature of the WS-RM-enabled CONFIRM and COMPENSATE methods unchanged so that the methods return void.

Syntax

package com.sap.tucc;

 

import javax.ejb.Stateful;

import javax.jws.Oneway;

import javax.jws.WebService;

import javax.jws.WebMethod;

import javax.jws.WebParam;

 

import com.sap.engine.services.webservices.espbase.configuration.ann.dt.RelMessagingNW05DTOperation;

import com.sap.engine.services.webservices.espbase.configuration.ann.dt. SessionHandlingDT;

 

@WebService(serviceName="TuccExampleService", portName="TuccExampleBeanPort", name="TuccExample", targetNamespace="http://sap.com/tucc/")

@Stateful

 

//Enable session handling for the whole class

//if you want to provide the TUCC Web service

//in cluster environment

@SessionHandlingDT(enableSession=true)

 

public class TuccExampleBean implements TuccExampleLocal {

   int sum = 0, currentSum = 0;

 

   @WebMethod(exclude=false, operationName="compensate")

   //Enable WS-RM for the method

   @RelMessagingNW05DTOperation(enableWSRM=true)

   //Set the message exchange pattern to one-way

   @Oneway

   public void compensate() {

      currentSum = 0;

   }

 

   @WebMethod(operationName="confirm", exclude=false)

   //Enable WS-RM for the method

   @RelMessagingNW05DTOperation(enableWSRM=true)

   //Set the message exchange pattern to one-way

   @Oneway

   public void confirm() {

      sum += currentSum;

      currentSum = 0;

   }

 

   @WebMethod(operationName="update", exclude=false)

   public void update(@WebParam(name="i")

   int i) {

      currentSum += i;

   }

 

   @WebMethod(operationName="getState", exclude=false)

   public int getState() {

      return sum;

   }

}

More Information:

Consuming TU&C/C Web Services

End of Content Area