I've encountered this problem myself recently and stumbled upon this thread multiple times. In our application we have a JAX-WS servlet which must use the format of ...Request and ...Response.
After a few days of searching, I found the solution.
Let's say your echoStringRequest has one String property that should be echoed back in the response.
class EchoMessage {
private String message;
//add getter and setter
}
First add this annotation to the web service class:
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
Then annotate your web service method like this:
@WebMethod
@WebResult(name = "echoStringResponse")
public EchoMessage echoString (@WebParam(name = "echoStringRequest") EchoMessage inputMessage) {
...
}
Without the parameterStyle BARE annotation, JAX-WS would automatically generate messages like this:
<echoString>
<echoStringRequest>
...
</echoStringRequest>
</echoString>
With the annotation, the outer element does not exist anymore.
The @WebParam and @ReturnType annotations are needed to determine the names of the root elements in the SOAP request and response body.