Show TOC

Setting an Authentication Level to the Web ServiceLocate this document in the navigation structure

Prerequisites

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

Context

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 .

Procedure


  1. In the Project Explorer , choose Start of the navigation path ejbModule Next navigation step com.sap.tutorial.javaee End of the navigation path, 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.

    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.

Results

The authentication level for the Converter Web service is set.