This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Web Services Certification (SCDJWS/OCEJWSD) and the fly likes When parameterStyle is Bare, web methods should only have 1 parameter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Web Services Certification (SCDJWS/OCEJWSD)
Bookmark "When parameterStyle is Bare, web methods should only have 1 parameter" Watch "When parameterStyle is Bare, web methods should only have 1 parameter" New topic
Author

When parameterStyle is Bare, web methods should only have 1 parameter

Himai Minh
Ranch Hand

Joined: Jul 29, 2012
Posts: 720


When I publish this using Endpoint.publish method, I got this error:

Exception in thread "main" com.sun.xml.internal.ws.model.RuntimeModelerException: runtime modeler error: SEI hello.HelloWS has method sayHello 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)
at com.sun.xml.internal.ws.model.RuntimeModeler.validateDocBare(RuntimeModeler.java:1247)
at com.sun.xml.internal.ws.model.RuntimeModeler.processDocBareMethod(RuntimeModeler.java:1236)
at com.sun.xml.internal.ws.model.RuntimeModeler.processMethod(RuntimeModeler.java:609)
at com.sun.xml.internal.ws.model.RuntimeModeler.processClass(RuntimeModeler.java:401)
at com.sun.xml.internal.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:240)
at com.sun.xml.internal.ws.server.EndpointFactory.createSEIModel(EndpointFactory.java:312)
at com.sun.xml.internal.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:178)
at com.sun.xml.internal.ws.api.server.WSEndpoint.create(WSEndpoint.java:456)
at com.sun.xml.internal.ws.api.server.WSEndpoint.create(WSEndpoint.java:475)
at com.sun.xml.internal.ws.transport.http.server.EndpointImpl.createEndpoint(EndpointImpl.java:213)
at com.sun.xml.internal.ws.transport.http.server.EndpointImpl.publish(EndpointImpl.java:143)
at hello.Publisher.main(Publisher.java:12)


I wonder why there is a rule that only one parameter is allowed in the web method. SOAP body can have multiple children elements, but why only 1 parameter is allowed?
a sarkar
Ranch Hand

Joined: Aug 05, 2010
Posts: 92
@SOAPBinding is not allowed on SEI.


Abhijit
-------
SCJP 5, SCBCD 5, OCWCD 5, OCEWSD 6, CSM
Himai Minh
Ranch Hand

Joined: Jul 29, 2012
Posts: 720
The @SOAPBinding is defined in the SEI , it compiles. But the problem occurs when I used Endpoint.publish. It complains that two parameters are not allowed.
a sarkar
Ranch Hand

Joined: Aug 05, 2010
Posts: 92
My bad, I was thinking about the javax.xml.ws.BindingType annotation. That's not allowed on the SEI.
You are not going to get a compilation error even if SOAPBinding were not allowed on the SEI (which it is). It's not a "syntax error" that the compiler will catch.

Anyway, I think I found the problem. Having multiple child elements is not WS-I BP 1.1 compliant. I don't know if you can force publishing of a non-compliant service.
R9981 An ENVELOPE MUST have exactly zero or one child elements of the soap:Body element.


http://www.ws-i.org/profiles/basicprofile-1.1.html
Himai Minh
Ranch Hand

Joined: Jul 29, 2012
Posts: 720
Well, a SOAP envelop can only have 1 SOAP body. But inside a SOAP body, there still can be multiple children elements.
This should be a valid bare parameter style soap request:

So, why the BARE parameter style can only accept one parameter, but not two?
a sarkar
Ranch Hand

Joined: Aug 05, 2010
Posts: 92
you misunderstood. Read it again.
An ENVELOPE MUST have exactly zero or one child elements of the soap:Body element.

As far as SOAP is concerned, having multiple child elements is valid. WS-I BP 1.1, however, says otherwise.
Himai Minh
Ranch Hand

Joined: Jul 29, 2012
Posts: 720
Well... I understand that an envelop must have at most one body element.
But how about the body element itself?
Can the body element itself have multiple children elements ? I would say Yes.





If a body is allowed to have multiple children, why the Endpoint cannot publish a web method with 2 parameters as the parameter style is defined as parameterStyle=BARE.
Himai Minh
Ranch Hand

Joined: Jul 29, 2012
Posts: 720
To answer my own question, I am reading Ivan' notes p.73, it says "With document style web services, the BP mandates that each message have zero or one part."
He gives an example,

So, that means the parameters are all inside <sd:purchaseOrder> element in the SOAP request.

When the parameter style is wrapped, that makes sense to have all parameters wrapped inside <sd:purchaseOrder> element.
When the parameter style is bare, all parameters are not wrapped inside any element.
Therefore, that makes sense to have this under doc/lit/bare:

But that won't make sense to have this message under doc/lit/bare:

This is not valid as BP mandates that with document style web service, the message must have at most 1 <part> element.

Therefore, this web method won't be deployed:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: When parameterStyle is Bare, web methods should only have 1 parameter
 
Similar Threads
A wrapped parameter style become a bare style
Simple JBoss Web Service With Eclipse
JAX-WS Custom Exception
ParameterStyle.WRAPPED vs ParameterStyle.BARE
Publish a service using SOAPBinding.SOAP12HTTPBinding