Show TOC Start of Content Area

Procedure documentation Setting an Authentication Level to the Web Service  Locate the document in its SAP Library structure

Use

When you create a Web service, you can configure it at design time (in SAP NetWeaver Developer Studio) to customize the Web service’s behavior at runtime. You configure a Web service at design time by using a set of annotations which SAP provides. You add the annotations manually in the Web service implementation bean. More information: Configuring Web Services at Design Time.

Prerequisites

The implementation EJB session bean is exposed as a Web service.

Procedure

       1.      In the Project Explorer, choose ejbModule com.sap.tutorial.javaee, and then open the ConverterBean.java session bean.

       2.      Update the source code as shown in the sample below.

The code sample below shows the implementation of a class level annotation. This way you make a design time configuration of the basic authentication level of the session bean.

Syntax

package com.sap.tutorial.javaee;

import java.math.BigDecimal;

import javax.ejb.Stateless;

import javax.jws.WebService;

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

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

@WebService(endpointInterface="com.sap.tutorial.javaee.ConverterLocal", portName="ConverterBeanPort", serviceName="ConverterService", targetNamespace="http://sap.com/tutorial/javaee/")

@AuthenticationDT(authenticationLevel = AuthenticationEnumsAuthenticationLevel.BASIC)

@Stateless(name="ConverterBean")

public class ConverterBean implements ConverterLocal {

   private BigDecimal dollarRate = new BigDecimal("1.2");

   private BigDecimal euroRate = new BigDecimal("0.83");

   public BigDecimal dollarToEuro(BigDecimal dollars) {

     BigDecimal result = dollars.multiply(euroRate);

     return result.setScale(2, BigDecimal.ROUND_UP);

     }

   public BigDecimal euroToDollar(BigDecimal euros) {

     BigDecimal result = euros.multiply(dollarRate);

     return result.setScale(2, BigDecimal.ROUND_UP);

     }

}

       3.      Save your changes.

Result

The authentication level for the Converter Web service is set.

Next Step

Deploying the Converter Web Service

 

 

End of Content Area