File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services Certification (SCDJWS/OCEJWSD) and the fly likes Why do I see different wsdl and xsd generated for webservice through wsgen. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Services Certification (SCDJWS/OCEJWSD)
Bookmark "Why do I see different wsdl and xsd generated for webservice through wsgen." Watch "Why do I see different wsdl and xsd generated for webservice through wsgen." New topic
Author

Why do I see different wsdl and xsd generated for webservice through wsgen.

Kumar Raja
Ranch Hand

Joined: Mar 18, 2010
Posts: 518
    
    2

Hello All,

First of all I apologize for a vague subject line, but I could not think any better


I have several questions related to the WSDL, XSD generated and the SOAP request/response which I would try to put as clear as possible.

I wrote a very simple webservice as below with default settings.



As evident from the above code, the messaging is "DOCUMENT/LITERAL/WRAPPED" mode. I ran wsgen and wsdl and xsd are generated.

CalculatorWSService_schema1.xsd


Question 1) Why the arg0 is having minOccurs="0" where I have not mentioned this anywhere in my code. Does it mean that I can ignore this argument all together as min = 0. Why this setting is not applied for arg1 and arg2. But why again for return.

Snippet from wsdl generated



But when I try to look for wsdl in a browser http://localhost:8080/CalculatorWS/CalculatorWSService?wsdl, I see the below


Question 2) Why there is an extra content in browser view "wsam:Action="http://ws.learning.org/CalculatorWS/calculateRequest" and why not in my generated WSDL. At what point this extra content would be induced and why is it needed. By the way the namespace for this content is

I also see differences in namespace declarations in both the cases

In my generated WSDL,


When browsed in browser


Question 3) Why and how the new additional namespaces were included and again at what point?


In eclipse, using the WebservicExplorer, I tried to test my service and captured the below response



But I try to test my another webservice, which is technically same as my CalculatorWS, the way the response is displayed is different. I see below response.


Question 4) Why there is difference in my response (Please look for <return> element). Why type declaration came into picture. This is not ENCODING format.

The service is defined as below, which is not different from CalculatorWS.


Question 5) Last but not the least, can some body explain me the differences of parameter style WRAPPED and BARE. In the page, it is mentioned as
Parameter Style
Decides whether operation name needs to be part of the SOAP body
Possible values: BARE or WRAPPED
Default: WRAPPED

but I did not understand this.
Could you please clarify me these questions?


Regards
KumarRaja

Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
I only have time for one answer right now, so I'll make an attempt at your first question:
Kumar Raja wrote:
Question 1) Why the arg0 is having minOccurs="0" where I have not mentioned this anywhere in my code. Does it mean that I can ignore this argument all together as min = 0. Why this setting is not applied for arg1 and arg2.

The first argument of the method is a String, which is an object. It can contain a string, which is not a surprise, but it may also contain null. The latter accounts for the case where it is omitted in the XML.
The other parameters are primitive types and thus can only have values and can never be null, so they have the default minOccurs="1".
Whether you can ignore the argument or not depends on the implementation of the web service operation - can it handle a null value for the first parameter?
Best wishes!


My free books and tutorials: http://www.slideshare.net/krizsan
Kumar Raja
Ranch Hand

Joined: Mar 18, 2010
Posts: 518
    
    2

Thank you Ivan for your response to my first question and would be thankful for responses to my other questions.
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
...and now for the other questions:
Kumar Raja wrote:
Question 2) Why there is an extra content in browser view "wsam:Action="http://ws.learning.org/CalculatorWS/calculateRequest" and why not in my generated WSDL. At what point this extra content would be induced and why is it needed.

The wsam:Action attribute is added on the fly when the WSDL is fed back to the browser, I suspect.
This is WS-Addressing metadata, about which you can read here: http://www.w3.org/TR/ws-addr-metadata/




Question 3) Why and how the new additional namespaces were included and again at what point?

Again, this is additional data inserted into the WSDL on the fly. Such additional data may also be stored separately from the WSDL and, when the WSDL is requested, inserted into the WSDL. The different namespaces are used for:
wsu: Related to WS-Security. For more info see: http://en.wikipedia.org/wiki/WS-Security
wsp and wsp1_2: Related to WS-Policy. For more info see: http://en.wikipedia.org/wiki/Ws-policy
wsam: Related to WS-Addressing. For more info see: http://en.wikipedia.org/wiki/WS-Addressing


Question 4) Why there is difference in my response (Please look for <return> element). Why type declaration came into picture. This is not ENCODING format.

What webservice stack are you using?
Are you using different web service stack for the different examples?


Question 5) Last but not the least, can some body explain me the differences of parameter style WRAPPED and BARE. In the page, it is mentioned as
Parameter Style
Decides whether operation name needs to be part of the SOAP body
Possible values: BARE or WRAPPED
Default: WRAPPED

This has recently been discussed in this very forum: http://www.coderanch.com/t/514679/java-Web-Services-SCDJWS/certification/Document-Literal-versus-Document-literal
Best wishes!
Kumar Raja
Ranch Hand

Joined: Mar 18, 2010
Posts: 518
    
    2

First of all, I thank you for all the responses and clarifications provided for my questions.

Ivan Krizsan wrote:
Question 4) Why there is difference in my response (Please look for <return> element). Why type declaration came into picture. This is not ENCODING format.

What webservice stack are you using?
Are you using different web service stack for the different examples?


In both the examples, I'm using GlassFish server and its associated Metro stack (Same RI in both the cases).

Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi again!
Kumar Raja wrote:First of all, I thank you for all the responses and clarifications provided for my questions.
Ivan Krizsan wrote:
Question 4) Why there is difference in my response (Please look for <return> element). Why type declaration came into picture. This is not ENCODING format.
What webservice stack are you using?
Are you using different web service stack for the different examples?

In both the examples, I'm using GlassFish server and its associated Metro stack (Same RI in both the cases).

I have never seen a xsi:type attribute in a web service deployed to GlassFish. If you care to, please tell me how you managed to create one!
Best wishes!
Dan Drillich
Ranch Hand

Joined: Jul 09, 2001
Posts: 1180
Kumar,

About question #1 - to supplement Ivan's answer please look at minOccurs="0" on required parameters in WSDL on ASP.NET web service.

Regards,
Dan


William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.
Leon Omk
Ranch Hand

Joined: Aug 17, 2010
Posts: 75

duplicate reply


OK, so that other guy knows Java better than I do, but I bet he can't speak Wuhanese(a Chinese Dialect) like me.
Leon Omk
Ranch Hand

Joined: Aug 17, 2010
Posts: 75


Question 2) Why there is an extra content in browser view "wsam:Action="http://ws.learning.org/CalculatorWS/calculateRequest" and why not in my generated WSDL. At what point this extra content would be induced and why is it needed. By the way the namespace for this content is

I also see differences in namespace declarations in both the cases

In my generated WSDL,
view plaincopy to clipboardprint?

<definitions targetNamespace="http://ws.learning.org/" name="CalculatorWSService"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://ws.learning.org/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">


When browsed in browser
view plaincopy to clipboardprint?

<definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://ws.learning.org/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://ws.learning.org/" name="CalculatorWSService">




Enterprise Application Server provide features like Qof (Quality of Service), which include add ws-addressing, ws-security, ws-transaction, etc on the fly, depending on the policy (configuration of ws_* features) you set on the webservice deployed in your application server.
Leon Omk
Ranch Hand

Joined: Aug 17, 2010
Posts: 75

Question 5) Last but not the least, can some body explain me the differences of parameter style WRAPPED and BARE. In the page, it is mentioned as
Parameter Style
Decides whether operation name needs to be part of the SOAP body
Possible values: BARE or WRAPPED
Default: WRAPPED


For a good article about WSDL styles:
https://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/

It tells the story before WS-I Basic Profile got involved in WebService world.

After combining WS-I Basic Profile 1.0, 1.1, 2.0 + wsdl1.1, we got something quite close to wsdl2.0. And benefits of document/literal bare, rpc/literal , rpc/encoding no longer exist.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why do I see different wsdl and xsd generated for webservice through wsgen.