Show TOC

Procedure documentationConfiguring a One Way Message Exchange Pattern Locate this document in the navigation structure

 

By default, the Web services you create have a request-response message exchange pattern (MEP). In a request-response MEP, when the Web service client invokes a method of the Web service (the client sends a request SOAP message), the Web service returns a response to the request.

In the SAP NetWeaver Developer Studio, you can configure a Web service to use a one-way MEP in which the Web service client only sends a request SOAP message but does not receive a response from the Web service.

You configure a one-way MEP on method level by using the standard @Oneway annotation defined in the JAX-WS 2.0 specification. Use this annotation only for Web service methods that return void, do not take a Holder class as input, or do not throw a checked exception.

Note Note

You can use @Oneway() annotation only for inside-out Web services.

End of the note.

You can add the @Oneway()annotation only in the Service Endpoint Interface (SEI) of the implementation bean. Only when you create an inside-out Web service without using an SEI can you add the @Oneway()annotation directly in the implementation bean. More information about creating inside-out Web services: Providing Web Services Inside Out. More information about service endpoint interface: Service Endpoint Interface.

Note Note

You can enable Web service reliable messaging only for Web service methods which use a one-way MEP. More information: Configuring Web Services Reliable Messaging.

End of the note.

Prerequisites

  • The Web service implementation bean is available.

  • If you are configuring an inside-out Web service by using a service endpoint interface (SEI), you must have the SEI available in the NetWeaver Developer Studio.

Procedure

If you are configuring an inside-out Web service which you create without using an SEI, you can insert the @Oneway()annotation directly in the implementation bean as shown in the code sample below.

Syntax Syntax

  1. package com.sap.example;
    
    import javax.ejb.Stateless;
    import javax.jws.WebService;
    import javax.jws.WebMethod;
    import javax.jws.WebParam;
    import javax.jws.Oneway;
    
    @WebService(targetNamespace="http://sap.com/example/", serviceName="MyOnewayMEPImplementationClassService",
    	 name="MyOnewayMEPImplementationClass", portName="MyOnewayMEPImplementationClassPort")
    @Stateless
    
    public class MyOnewayMEPImplementationClass {
    		//Set the a one way message exchange pattern for MyMethod1
    		@WebMethod(exclude=false, operationName="MyMethod1")
    		@Oneway()
    		public void MyMethod1 (@WebParam(name="newValue1")
    		int newValue1)
    		{
    			//MyMethod1 implementation	
    		}
    		@WebMethod(exclude=false, operationName="MyMethod2")
    		public int MyMethod2 (@WebParam(name="arg")
    		int arg)
    		{
    			return arg;
    		}
    }
    
End of the code.

Note that the method MyMethod2 cannot use a one-way MEP because it does not return void.

If you are configuring an inside out Web service for which you have an SEI, you have to insert the @Oneway annotation in the SEI. If you insert it in the implementation bean, it will not be processed.

The code sample below shows an SEI in which the @Oneway() annotation is used.

Syntax Syntax

  1. package com.sap.example;
    
    import javax.jws.Oneway;
    import javax.jws.WebService;
    import javax.jws.WebMethod;
    import javax.jws.WebParam;
    
    @WebService(name="MyOnewayMEPImplementationSEI", targetNamespace="http://sap.com/example/")
    public interface MyOnewayMEPImplementationSEI {
    
    	@WebMethod(operationName="MyMethod2")
    	public int MyMethod2(@WebParam(name="arg")
    	int arg);
    	@WebMethod(operationName="MyMethod1")
    	//Set the a one way message exchange pattern for MyMethod1
       @Oneway()
    	public void MyMethod1(@WebParam(name="newValue1")
    	int newValue1);
    }
    
End of the code.