
The implementation EJB session bean is exposed as a Web service.
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 .
In the Project Explorer , choose , and then open the ConverterBean.java session bean.
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);
}
}
Save your changes.
The authentication level for the Converter Web service is set.
Next Step