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 Ben Reif <be...@gmail.com> on 2007/12/18 23:34:23 UTC

[Axis2] Java2WSDL with JAX-WS and JAXB annotations

 Hi,

I have a question about generating WSDL and Schema in Axis2. We have been
using Axis 1.4 for quite some time now and are finally ready to upgrade to
Axis2. I've read that a lot of people suggest "starting with the WSDL", but
unfortunately we have a lot of existing Web Services and custom data object
(not quite JavaBean compatible) that we are hoping to re-use.  Previously we
would define <typeMapping> tags in the server-config.xml and then implement
the writeSchema() method on a custom Serializer class to generate out the
correct Schema for the WSDL when we use the Java2WSDL utility.

As I understand it, now the best way to re-use your existing code is to use
the JAX-WS and JAXB annotations and then run your code through the Axis2
Java2WSDL utility passing in the "-sg" argument with the value "
org.apache.axis2.jaxbri.JaxbSchemaGenerator". I *think* I read that you *may
* be able to use JiBX, but we prefer JAX-WS and JAXB because they are
standards and in theory should be portable to other platforms and tools as
well.

Anyway, my Web Service throws a custom Fault that extends
org.apache.axis2.AxisFault. So I've gone through and annotated all the
classes (including the custom Fault class), but when I run Java2WSDL I get
the exception below because it's trying to write the schema for the
AxisFault and it's super classes which aren't JAXB compliant:

com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 8 counts of
IllegalAnnotationExceptions
org.apache.axis2.AxisFault does not have a no-arg default constructor.
 this problem is related to the following location:
  at org.apache.axis2.AxisFault
  at com.ams.core.webservices.exceptions.BaseFault
  at com.ams.core.webservices.exceptions.RecoverableFault
org.apache.axiom.om.OMElement is an interface, and JAXB can't handle
interfaces.
 this problem is related to the following location:
  at org.apache.axiom.om.OMElement
  at public org.apache.axiom.om.OMElement
org.apache.axis2.AxisFault.getDetail()
  at org.apache.axis2.AxisFault
  at com.ams.core.webservices.exceptions.BaseFault
  at com.ams.core.webservices.exceptions.RecoverableFault
org.apache.axiom.om.OMElement does not have a no-arg default constructor.
 this problem is related to the following location:
  at org.apache.axiom.om.OMElement
  at public org.apache.axiom.om.OMElement
org.apache.axis2.AxisFault.getDetail()
  at org.apache.axis2.AxisFault
  at com.ams.core.webservices.exceptions.BaseFault
  at com.ams.core.webservices.exceptions.RecoverableFault
org.apache.axiom.om.OMXMLParserWrapper is an interface, and JAXB can't
handle interfaces.
 this problem is related to the following location:
  at org.apache.axiom.om.OMXMLParserWrapper
  at public abstract org.apache.axiom.om.OMXMLParserWrapper
org.apache.axiom.om.OMElement.getBuilder()
  at org.apache.axiom.om.OMElement
  at public org.apache.axiom.om.OMElement
org.apache.axis2.AxisFault.getDetail()
  at org.apache.axis2.AxisFault
  at com.ams.core.webservices.exceptions.BaseFault
  at com.ams.core.webservices.exceptions.RecoverableFault
..........

My question is, how do you get Java2WSDL or JAXB to ignore Java classes or
certain other classes in the Object hierarchy? I tried to put the JAXB
2.1.5jars in the classpath and use the @XmlTransient annotation at the
class
level  by putting a base class in between AxisFault and my custom Fault, but
that didn't seem to work either. I would think that this would cause a
problem when generating WSDL/Schema for any class that extends certain other
classes.

Has anyone done this before or have any ideas on how to get around this?

I have one last question. Sun's com.sun.tools.ws.WsGen utility from their
JAX-WS Reference Implementation generates the WSDL and Schema so that they
are broken out into seperate files (WSDL Service/Bindings, WSDL Message and
PortTypes, and then a seperate xsd file to define all of the types for a
given namespace. Is there any way to get the Axis2 Java2WSDL classes to do
this, or does anyone know what I should extend to get this to happen?

Thanks in advance,
Ben

Re: [Axis2] Java2WSDL with JAX-WS and JAXB annotations

Posted by Ben Reif <be...@gmail.com>.
Thanks Dennis, I'll take a look at that as well, that may be our only
choice. I guess at the end of the day, I'm looking to see how I can exclude
certain types from being generated in the WSDL. Using @XmlTransient alone
doesn't do it. In Axis 1.4 I could take advantage of the
org.apache.axis.wsdl.fromJava.Types.getStopClasses() List, so I'm wondering
if there is similar functionality to utilize in the Axis2 infrastructure?

Ben


On 12/20/07, Dennis Sosnoski <dm...@sosnoski.com> wrote:
>
> Hi Ben,
>
> You may have better luck using Jibx2Wsdl:
> http://www.sosnoski.com/jibx-wiki/space/axis2-jibx/jibx2wsdl You can
> also see the article at
> http://www.infoq.com/articles/sosnoski-code-first discussing "code
> first" approaches in general, and Jibx2Wsdl in particular. Jibx2Wsdl
> handles a wider range of inputs than Java2WSDL, and also supports
> customizations to change the default generation process. You may find
> that using the generated JiBX data binding also gives you a way to
> easily use your existing data classes with Axis2.
>
> I'll see about adding some links on this to the download documentation
> for Axis2 1.4. There doesn't seem to be much point in recommending
> people use Java2WSDL when there are many known limitations, and
> Jibx2Wsdl does a better job all around. I'll also try to get the
> documentation finished and a formal release of Jibx2Wsdl soon.
>
> - Dennis
>
> --
> Dennis M. Sosnoski
> SOA and Web Services in Java
> Axis2 Training and Consulting
> http://www.sosnoski.com - http://www.sosnoski.co.nz
> Seattle, WA +1-425-939-0576 - Wellington, NZ +64-4-298-6117
>
>
>
> Ben Reif wrote:
> > Duncan,
> >
> > Thanks for the input. We're trying to incorporate the WSDL generation
> > into another automated process, so manually generating it with the
> > NetBeans IDE probably won't work for us. I have however, tried using
> > the WsGen tool as well, and I noticed a different problem, the
> > generated WSDL didn't indicate that the operations threw any Faults at
> > all. They were missing from the WSDL completely. Does anyone else have
> > any other thoughts or ideas?
> >
> > Ben
> >
> > On 12/20/07, *Thomson, Duncan* <duncant@mitre.org
> > <ma...@mitre.org>> wrote:
> >
> >     >-----Original Message-----
> >     >From: Ben Reif [mailto:ben.reif@gmail.com
> >     <ma...@gmail.com>]
> >     >Sent: Tuesday, December 18, 2007 5:34 PM
> >     >To: axis-user@ws.apache.org <ma...@ws.apache.org>
> >     >Subject: [Axis2] Java2WSDL with JAX-WS and JAXB annotations
> >     >
> >     >Hi,
> >     >
> >     >As I understand it, now the best way to re-use your existing
> >     >code is to use the JAX-WS and JAXB annotations and then run
> >     >your code through the Axis2 Java2WSDL utility passing in the
> >     >"-sg" argument with the value "
> >     >org.apache.axis2.jaxbri.JaxbSchemaGenerator". ....in theory should
> be
> >     >portable to other platforms and tools as well.
> >     >
> >
> >     FYI, Netbeans has very nice JAX-WS and JAXB support, and does a very
> >     nice job of annotation processing.  Note that if you use this you
> >     don't
> >     need Axis at all - instead of Java2WSDL the Netbeans IDE uses a
> >     different set of tools - wsgen and wsimport, if I remember
> correctly.
> >     You can also launch these tools directly yourself, and perhaps
> >     they are
> >     available within other IDEs, I'm not sure.
> >
> >     Anyway, the point is, as far as I can tell, with these tools,
> there's
> >     really no need for Axis2.  Perhaps someone else will explain why
> it's
> >     needed, but I don't see it.
> >
> >     Duncan
> >
> >
> ---------------------------------------------------------------------
> >     To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> >     <ma...@ws.apache.org>
> >     For additional commands, e-mail: axis-user-help@ws.apache.org
> >     <ma...@ws.apache.org>
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>

Re: [Axis2] Java2WSDL with JAX-WS and JAXB annotations

Posted by Dennis Sosnoski <dm...@sosnoski.com>.
Hi Ben,

You may have better luck using Jibx2Wsdl: 
http://www.sosnoski.com/jibx-wiki/space/axis2-jibx/jibx2wsdl You can 
also see the article at 
http://www.infoq.com/articles/sosnoski-code-first discussing "code 
first" approaches in general, and Jibx2Wsdl in particular. Jibx2Wsdl 
handles a wider range of inputs than Java2WSDL, and also supports 
customizations to change the default generation process. You may find 
that using the generated JiBX data binding also gives you a way to 
easily use your existing data classes with Axis2.

I'll see about adding some links on this to the download documentation 
for Axis2 1.4. There doesn't seem to be much point in recommending 
people use Java2WSDL when there are many known limitations, and 
Jibx2Wsdl does a better job all around. I'll also try to get the 
documentation finished and a formal release of Jibx2Wsdl soon.

  - Dennis

-- 
Dennis M. Sosnoski
SOA and Web Services in Java
Axis2 Training and Consulting
http://www.sosnoski.com - http://www.sosnoski.co.nz
Seattle, WA +1-425-939-0576 - Wellington, NZ +64-4-298-6117



Ben Reif wrote:
> Duncan,
>  
> Thanks for the input. We're trying to incorporate the WSDL generation 
> into another automated process, so manually generating it with the 
> NetBeans IDE probably won't work for us. I have however, tried using 
> the WsGen tool as well, and I noticed a different problem, the 
> generated WSDL didn't indicate that the operations threw any Faults at 
> all. They were missing from the WSDL completely. Does anyone else have 
> any other thoughts or ideas?
>  
> Ben
>  
> On 12/20/07, *Thomson, Duncan* <duncant@mitre.org 
> <ma...@mitre.org>> wrote:
>
>     >-----Original Message-----
>     >From: Ben Reif [mailto:ben.reif@gmail.com
>     <ma...@gmail.com>]
>     >Sent: Tuesday, December 18, 2007 5:34 PM
>     >To: axis-user@ws.apache.org <ma...@ws.apache.org>
>     >Subject: [Axis2] Java2WSDL with JAX-WS and JAXB annotations
>     >
>     >Hi,
>     >
>     >As I understand it, now the best way to re-use your existing
>     >code is to use the JAX-WS and JAXB annotations and then run
>     >your code through the Axis2 Java2WSDL utility passing in the
>     >"-sg" argument with the value "
>     >org.apache.axis2.jaxbri.JaxbSchemaGenerator". ....in theory should be
>     >portable to other platforms and tools as well.
>     >
>
>     FYI, Netbeans has very nice JAX-WS and JAXB support, and does a very
>     nice job of annotation processing.  Note that if you use this you
>     don't
>     need Axis at all - instead of Java2WSDL the Netbeans IDE uses a
>     different set of tools - wsgen and wsimport, if I remember correctly.
>     You can also launch these tools directly yourself, and perhaps
>     they are
>     available within other IDEs, I'm not sure.
>
>     Anyway, the point is, as far as I can tell, with these tools, there's
>     really no need for Axis2.  Perhaps someone else will explain why it's
>     needed, but I don't see it.
>
>     Duncan
>
>     ---------------------------------------------------------------------
>     To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>     <ma...@ws.apache.org>
>     For additional commands, e-mail: axis-user-help@ws.apache.org
>     <ma...@ws.apache.org>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: [Axis2] Java2WSDL with JAX-WS and JAXB annotations

Posted by Ben Reif <be...@gmail.com>.
Duncan,

Thanks for the input. We're trying to incorporate the WSDL generation into
another automated process, so manually generating it with the NetBeans IDE
probably won't work for us. I have however, tried using the WsGen tool as
well, and I noticed a different problem, the generated WSDL didn't indicate
that the operations threw any Faults at all. They were missing from the WSDL
completely. Does anyone else have any other thoughts or ideas?

Ben

On 12/20/07, Thomson, Duncan <du...@mitre.org> wrote:
>
> >-----Original Message-----
> >From: Ben Reif [mailto:ben.reif@gmail.com]
> >Sent: Tuesday, December 18, 2007 5:34 PM
> >To: axis-user@ws.apache.org
> >Subject: [Axis2] Java2WSDL with JAX-WS and JAXB annotations
> >
> >Hi,
> >
> >As I understand it, now the best way to re-use your existing
> >code is to use the JAX-WS and JAXB annotations and then run
> >your code through the Axis2 Java2WSDL utility passing in the
> >"-sg" argument with the value "
> >org.apache.axis2.jaxbri.JaxbSchemaGenerator". ....in theory should be
> >portable to other platforms and tools as well.
> >
>
> FYI, Netbeans has very nice JAX-WS and JAXB support, and does a very
> nice job of annotation processing.  Note that if you use this you don't
> need Axis at all - instead of Java2WSDL the Netbeans IDE uses a
> different set of tools - wsgen and wsimport, if I remember correctly.
> You can also launch these tools directly yourself, and perhaps they are
> available within other IDEs, I'm not sure.
>
> Anyway, the point is, as far as I can tell, with these tools, there's
> really no need for Axis2.  Perhaps someone else will explain why it's
> needed, but I don't see it.
>
> Duncan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>

RE: [Axis2] Java2WSDL with JAX-WS and JAXB annotations

Posted by "Thomson, Duncan" <du...@mitre.org>.
>-----Original Message-----
>From: Ben Reif [mailto:ben.reif@gmail.com] 
>Sent: Tuesday, December 18, 2007 5:34 PM
>To: axis-user@ws.apache.org
>Subject: [Axis2] Java2WSDL with JAX-WS and JAXB annotations
>
>Hi, 
> 
>As I understand it, now the best way to re-use your existing 
>code is to use the JAX-WS and JAXB annotations and then run 
>your code through the Axis2 Java2WSDL utility passing in the 
>"-sg" argument with the value " 
>org.apache.axis2.jaxbri.JaxbSchemaGenerator". ....in theory should be 
>portable to other platforms and tools as well. 
> 

FYI, Netbeans has very nice JAX-WS and JAXB support, and does a very
nice job of annotation processing.  Note that if you use this you don't
need Axis at all - instead of Java2WSDL the Netbeans IDE uses a
different set of tools - wsgen and wsimport, if I remember correctly.
You can also launch these tools directly yourself, and perhaps they are
available within other IDEs, I'm not sure.

Anyway, the point is, as far as I can tell, with these tools, there's
really no need for Axis2.  Perhaps someone else will explain why it's
needed, but I don't see it.

Duncan

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org