JWS names the attribute parameterStyle because the contrast between wrapped and unwrapped in document-style web services comes down to how parameters are represented in the SOAP body.
What may be surprising is that the structure of the underlying SOAP messages, both the request and the response, remain unchanged.
The key difference is in the Java client code, of course. The simplified client, with the unwrapped parameterStyle, calls invokeSearch with one argument of type ItemSearch and expects a single response of type ItemSearchResponse. So the parameterStyle with a value of BARE eliminates the complicated call to invokeSearch with 10 arguments, 8 of which are arguments bound to the subelements in the @RequestWrapper, and 2 of which are arguments bound to subelements in the @ResponseWrapper.
Determines whether method parameters represent the entire message body, or whether the parameters are elements wrapped inside a top-level element named after the operation
All the examples I have seen about the Unwrapped/BARE style use methods with one parameter, but I can find no explanation on why that is a limitation. And if it is, surely that means the example on page 44 is wrong?
I think you have chosen an excellent book to get started with web services. If after reading and understanding it thoroughly, you work through the tutorials, you will breeze through them. In my view this is the best approach to learn this stuff. All the best
I don't want to progress further through material without getting the basic theory first and this Unrwapped example on page 44 has completely thrown me.
R Srini wrote:Bare vs wrapped:
- What is it that is wrapped? The parameters.
- Where are they wrapped? The parameters are wrapped/enclosed in the XML by the function/method/operation name in the WSDL - not in the Java code.
- The bare and wrapped styles are equivalent. Some people prefer the bare style, while others prefer the wrapped style. The SOAPBinding annotation determine which style of code gets generated.
- When [Java] code is generated for the bare style, it is generated with just one parameter, and the actual multiple parameters are inside it and set using setters before invoking the web service.
- When [Java] code is generated for the wrapped style, it is generated with multiple parameters, one for each parameters. When invoking the web service, all of the parameters are passed explicitly.
- As far as I can tell, bare vs wrapped are merely conventions for different ways of calling a web service. One is not better than the other, generally speaking. It is a matter of preference, and different people will argue differently to suit their preference.
- Whether bare or wrapped, your method signature "public int addNums(int num1, int num2)" remains the same. You can have as many parameters as you like in the bare style.
- Whether a given SOAP message is valid is determined by the WSDL that it conforms to. So, both the examples 2-8 (unwrapped) and 2-9 (wrapped) have to be viewed within the context of their respective WSDLs. Examples 2-8 and 2-9 would have different WSDLs, and I could not find the WSDLs mentioned in the book. So that may be the source of your confusion, but both of the requests are nevertheless valid in their context.
So, really, it has no place in a book about Java Web Services. Would that be fair say?
We will get you past page 45 - by hook or by crook Hang in there. Its just that a lot of this is arcane or not commonly used or simply unfamiliar, and if its not commonly used, its hard to find examples on the web. So it takes some experimenting to get some of it to work. Best of luck!
To be honest if I can't bet past page 45 without being totally confused and lost, there's not much hope for me in ever understanding this!
was incorrect, and made based on the book, before I actually researched this in detail. The bare style seems to be available only with a single parameter for the addNums.
Whether bare or wrapped, your method signature "public int addNums(int num1, int num2)" remains the same. You can have as many parameters as you like in the bare style.
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koophttps://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton