You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Morten Mortensen <MO...@tdc.dk> on 2006/03/30 11:49:58 UTC

How to reproduce "WSDL2Java okay"+"uncompilable code generated"

I can now directly provoke, what I said yesterday: WSDL2Java running
smoothly, but the generated coded in an uncompilable state!

To reproduce, take the "Axis2SampleDocLit.wsdl" from the 0.95
distribution, make the error like I did in my own WSDL by removing the
qualification from the message-elements like this (see the attached
file; slightly modified variant of the original sample):

Change e.g. -

    <message name="echoString">
        <part element="xsd1:echoStringParam" name="a"/>  <- remove
"xsd1"
    </message>

- into -

    <message name="echoString">
        <part element="echoStringParam" name="a"/> <- no "xsd1"
    </message>

Now the WSDL2Java runs without any errors, but the compilation fails
since the code shown in my original message below is produced.

I think, that there ought to be a negative test-case for WSDL2Java with
this type of WSDL!
It is very good, that given correct WSDL, then all is fine - but in real
life, we fiddle with WSDL for a long time, maybe do not get it right for
the first number of times and then it is important to have tools like
WSDL2Java do some aggressive verification of the WSDL...
Having to track down the cause of generated, uncompilable code is too
tough.
Developers - are you listening?

Regards,
Morten Sabroe Mortensen

 

-----Oprindelig meddelelse-----
Fra: Morten Mortensen 
Sendt: 29. marts 2006 17:38
Til: axis-user@ws.apache.org
Emne: Mode "Document/literal" vs. "Document/literal wrapped"


Hi all

With the 0.95 version, how come I can use WSDL2Java to generate
*un-compilable* code?
Apparently, when I write WSDL as "Document/literal wrapped", the
generated "XXXReceiverInOut" has bad "toOM()", "fromOM()" and
"toEnvelope()" (for an example, see the below "toOM()"-implementation;
the parameter does not have the right type!).

Why does this happen? What to do?

Regards,
Morten Sabroe Mortensen

---
   ...
                    private  org.apache.ws.commons.om.OMElement
toOM(org.apache.ws.commons.om.OMElement param){
                        if (param instanceof
org.apache.axis2.databinding.ADBBean){
 
org.apache.ws.commons.om.impl.builder.StAXOMBuilder builder = new
org.apache.ws.commons.om.impl.builder.StAXOMBuilder
 
(org.apache.ws.commons.om.OMAbstractFactory.getOMFactory(),
param.getPullParser(org.apache.ws.commons.om.OMElement.MY_QNAME));
                            org.apache.ws.commons.om.OMElement
documentElement = builder.getDocumentElement();
                            ((org.apache.ws.commons.om.impl.OMNodeEx)
documentElement).setParent(null); // remove the parent link
                            return documentElement;
                        }else{
                           
                           //todo finish this onece the bean serializer
has the necessary methods
                            return null;
                        }
                    }
   ...
---

Re: How to reproduce "WSDL2Java okay"+"uncompilable code generated"

Posted by Ali Sadik Kumlali <as...@yahoo.com>.
Hi,

Eclipse Web Tools Platform (WTP)  comes with XSD and WSDL editors which are able to validate.

For more information please visit http://www.eclipse.org/webtools/

Regards,

Ali Sadik Kumlali

Anne Thomas Manes <at...@gmail.com> wrote: There are other problems with this WSDL besides the wrong qnames in your message parts. (Note that they aren't unqualified because there is a default namespace (the wsdl namespace); but these elements are in the xsd1 namespace.)  

When using RPC style, your message parts must reference types, not elements. To fix the WSDL, either change the style to "document" (and remove the namespace attributes from the <soap:body> definitions) or change the message parts to reference types rather than elements. 

I disagree with you that wsdl2java should have a built-in WSDL validator and should be able to catch all WSDL errors. As a best practice, you should validate your WSDL before running wsdl2java. Many WSDL editors provide WSDL validators. I'm not aware of an open source WSDL validator, though. (Perhaps someone would like to volunteer to build one?) I do think that wsdl2java should generate an error when it encounters an unresolvable reference, though.  e.g.,

"http://schemas.xmlsoap.org/wsdl/}echoStringParam is referenced but not defined"


Anne

 On 3/30/06, Morten Mortensen <MO...@tdc.dk> wrote: 
I can now directly provoke, what I said yesterday: WSDL2Java running
smoothly, but the generated coded in an uncompilable state!

To reproduce, take the "Axis2SampleDocLit.wsdl" from the 0.95
distribution, make the error like I did in my own WSDL by removing the 
qualification from the message-elements like this (see the attached
file; slightly modified variant of the original sample):

Change e.g. -

    <message name="echoString">
        <part element="xsd1:echoStringParam" name="a"/>  <- remove 
"xsd1"
    </message>

- into -

    <message name="echoString">
        <part element="echoStringParam" name="a"/> <- no "xsd1" 
    </message>

Now the WSDL2Java runs without any errors, but the compilation fails
since the code shown in my original message below is produced.

I think, that there ought to be a negative test-case for WSDL2Java with 
this type of WSDL!
It is very good, that given correct WSDL, then all is fine - but in real
life, we fiddle with WSDL for a long time, maybe do not get it right for
the first number of times and then it is important to have tools like 
WSDL2Java do some aggressive verification of the WSDL...
Having to track down the cause of generated, uncompilable code is too
tough.
Developers - are you listening?

Regards,
Morten Sabroe Mortensen 



-----Oprindelig meddelelse-----
Fra: Morten Mortensen
Sendt: 29. marts 2006 17:38
Til: axis-user@ws.apache.org
Emne: Mode "Document/literal" vs. "Document/literal wrapped" 


Hi all

With the 0.95 version, how come I can use WSDL2Java to generate
*un-compilable* code?
Apparently, when I write WSDL as "Document/literal wrapped", the
generated "XXXReceiverInOut" has bad "toOM()", "fromOM()" and 
"toEnvelope()" (for an example, see the below "toOM()"-implementation;
the parameter does not have the right type!).

Why does this happen? What to do?

Regards,
Morten Sabroe Mortensen 

---
   ...
                    private  org.apache.ws.commons.om.OMElement
toOM(org.apache.ws.commons.om.OMElement param){
                        if (param instanceof
org.apache.axis2.databinding.ADBBean ){

org.apache.ws.commons.om.impl.builder.StAXOMBuilder builder = new
org.apache.ws.commons.om.impl.builder.StAXOMBuilder

(org.apache.ws.commons.om.OMAbstractFactory.getOMFactory(),
param.getPullParser( org.apache.ws.commons.om.OMElement.MY_QNAME));
                            org.apache.ws.commons.om.OMElement
documentElement = builder.getDocumentElement();
                            ((org.apache.ws.commons.om.impl.OMNodeEx )
documentElement).setParent(null); // remove the parent link
                            return documentElement;
                        }else{

                           //todo finish this onece the bean serializer 
has the necessary methods
                            return null;
                        }
                    }
   ...
---




 

		
---------------------------------
New Yahoo! Messenger with Voice. Call regular phones from your PC and save big.

Re: How to reproduce "WSDL2Java okay"+"uncompilable code generated"

Posted by Anne Thomas Manes <at...@gmail.com>.
There are other problems with this WSDL besides the wrong qnames in your
message parts. (Note that they aren't unqualified because there is a default
namespace (the wsdl namespace); but these elements are in the xsd1
namespace.)

When using RPC style, your message parts must reference types, not elements.
To fix the WSDL, either change the style to "document" (and remove the
namespace attributes from the <soap:body> definitions) or change the message
parts to reference types rather than elements.

I disagree with you that wsdl2java should have a built-in WSDL validator and
should be able to catch all WSDL errors. As a best practice, you should
validate your WSDL before running wsdl2java. Many WSDL editors provide WSDL
validators. I'm not aware of an open source WSDL validator, though. (Perhaps
someone would like to volunteer to build one?) I do think that wsdl2java
should generate an error when it encounters an unresolvable reference,
though. e.g.,

"http://schemas.xmlsoap.org/wsdl/}echoStringParam is referenced but not
defined"

Anne

On 3/30/06, Morten Mortensen <MO...@tdc.dk> wrote:
>
>
> I can now directly provoke, what I said yesterday: WSDL2Java running
> smoothly, but the generated coded in an uncompilable state!
>
> To reproduce, take the "Axis2SampleDocLit.wsdl" from the 0.95
> distribution, make the error like I did in my own WSDL by removing the
> qualification from the message-elements like this (see the attached
> file; slightly modified variant of the original sample):
>
> Change e.g. -
>
>     <message name="echoString">
>         <part element="xsd1:echoStringParam" name="a"/>  <- remove
> "xsd1"
>     </message>
>
> - into -
>
>     <message name="echoString">
>         <part element="echoStringParam" name="a"/> <- no "xsd1"
>     </message>
>
> Now the WSDL2Java runs without any errors, but the compilation fails
> since the code shown in my original message below is produced.
>
> I think, that there ought to be a negative test-case for WSDL2Java with
> this type of WSDL!
> It is very good, that given correct WSDL, then all is fine - but in real
> life, we fiddle with WSDL for a long time, maybe do not get it right for
> the first number of times and then it is important to have tools like
> WSDL2Java do some aggressive verification of the WSDL...
> Having to track down the cause of generated, uncompilable code is too
> tough.
> Developers - are you listening?
>
> Regards,
> Morten Sabroe Mortensen
>
>
>
> -----Oprindelig meddelelse-----
> Fra: Morten Mortensen
> Sendt: 29. marts 2006 17:38
> Til: axis-user@ws.apache.org
> Emne: Mode "Document/literal" vs. "Document/literal wrapped"
>
>
> Hi all
>
> With the 0.95 version, how come I can use WSDL2Java to generate
> *un-compilable* code?
> Apparently, when I write WSDL as "Document/literal wrapped", the
> generated "XXXReceiverInOut" has bad "toOM()", "fromOM()" and
> "toEnvelope()" (for an example, see the below "toOM()"-implementation;
> the parameter does not have the right type!).
>
> Why does this happen? What to do?
>
> Regards,
> Morten Sabroe Mortensen
>
> ---
>    ...
>                     private  org.apache.ws.commons.om.OMElement
> toOM(org.apache.ws.commons.om.OMElement param){
>                         if (param instanceof
> org.apache.axis2.databinding.ADBBean){
>
> org.apache.ws.commons.om.impl.builder.StAXOMBuilder builder = new
> org.apache.ws.commons.om.impl.builder.StAXOMBuilder
>
> (org.apache.ws.commons.om.OMAbstractFactory.getOMFactory(),
> param.getPullParser(org.apache.ws.commons.om.OMElement.MY_QNAME));
>                             org.apache.ws.commons.om.OMElement
> documentElement = builder.getDocumentElement();
>                             ((org.apache.ws.commons.om.impl.OMNodeEx)
> documentElement).setParent(null); // remove the parent link
>                             return documentElement;
>                         }else{
>
>                            //todo finish this onece the bean serializer
> has the necessary methods
>                             return null;
>                         }
>                     }
>    ...
> ---
>
>
>