By Marone: December 2016

Soap parameterstyle bare exceptions


Show some famous Exception around the ParameterStyle.BARE and how to deal with it

Used technologies

JDK 1.8

Document + Bare

@WebService(endpointInterface = "com.wstutorial.soap.WSDocBare")
@SOAPBinding(style=Style.DOCUMENT, use=Use.LITERAL, parameterStyle=ParameterStyle.BARE)
public class WSDocBare {
	public Tutorial getTutorial(String query, boolean all) {
		return new Tutorial("Foo", "John Doe");

RuntimeModelerException: more than one parameter

Exception in thread "main" 
runtime modeler error: SEI com.wstutorial.soap.WSDocBare has method getTutorial annotated as BARE but it has more than one parameter bound to body. This is invalid. 
Please annotate the method with annotation: @SOAPBinding(parameterStyle=SOAPBinding.ParameterStyle.WRAPPED)

The parameterStyle determines how to map parameters onto SOAP messages. Bare accepts a empty method or a method with one parameter.
To solve this problem just wrap both parameters in a class

Solution: wrap both parameters in a class

/* The wrapped class */
public class WrappedInput {
	private String query; 
	private boolean all;
 /* The web service class */
@WebService(endpointInterface = "com.wstutorial.soap.WSDocBareSolution")
@SOAPBinding(style=Style.DOCUMENT, use=Use.LITERAL, parameterStyle=ParameterStyle.BARE)
public class WSDocBareSolution {
	public String getTutorial(WrappedInput input) {
		return "OK";

RCP + Bare

@WebService(endpointInterface = "com.wstutorial.soap.WSRcpBare")
@SOAPBinding(style=Style.RPC, use=Use.LITERAL, parameterStyle=ParameterStyle.BARE)
public class WSRcpBare {
	public String getTutorial(String query) {
		return "OK";

RuntimeModelerException: Incorrect usage of Annotation

Exception in thread "main" 
Incorrect usage of Annotation @javax.jws.soap.SOAPBinding(parameterStyle=BARE, use=LITERAL, style=RPC) 
on class com.wstutorial.soap.WSRcpBare, ParameterStyle can only be WRAPPED with RPC Style Web service.

Warning! RPC Literal Bare is not allowed, why?
The RPC style aims to use parameters in the request and return values in the response, whereas BARE allowed only one paramter in the request! CONFLICT