You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Inmaculada Marín <in...@um.es> on 2010/10/01 09:49:12 UTC
Web service generation problem - WSDL2Java
Hi all,
I developed a web service with an old version of JDeveloper some time ago,
but now I have to migrate it to CXF. The WSDL uses elements from an schema
(as operation parameters), but in the implementation the type of the
parameters are org.w3c.dom.Element (that is because of the JDeveloper
version used then).
When I try to generate the service skeleton (using the same WSDL that the
old web service has) using WSDL2Java tool, classes from the schema are
generated, and the web service operations have parameters of these classes
(classes from the schema). Then, several tests has been accomplished:
- if I try to change the type of these parameters to type
org.w3c.dom.Element (so as to include all the web service implementation I
already have, as-is), I have an error when invoking that service, as the
input parameter type is not the one expected.
- If I keep the type of these parameters as generated by WSDL2Java
tool, I marshall the input parameters, so as to obtain an object of type
org.w3c.dom.Element, then I include all my web service implementation, and
then I turn the result (an object of type org.w3c.dom.Element) into an
object of the expected type (from the schema) by unmarshalling the
org.w3c.dom.Element. However, some values of XML elements are lost, and the
object returned is not correct (besides, the prefix namespaces are changed
to ns2, ns3 and so).
Is there is a way of indicating WSDL2Java tool a mapping from schema
elements to java classes, so as to telling which classes has to use for
specific schema element (that is, if an operation has a parameter of type
x:ParameterType defined in the used schema, maybe I could say the WSDL2Java
tool not to generate this element java class, but to use an existing java
class instead)?
I have to keep all the implementation of my old web service, as is a huge
one and it is very expensive to use java classes generated by WSDL2Java tool
within that implementation.
Can you be so kind as to help me, please?
Thank you very much in advance.
Regards,
Inma.
RE: Web service generation problem - WSDL2Java
Posted by Inmaculada Marín <in...@um.es>.
Ok, I will try it.
Thank you very much for helping me.
Regards,
Inma.
-----Mensaje original-----
De: Daniel Kulp [mailto:dkulp@apache.org]
Enviado el: lunes, 04 de octubre de 2010 22:58
Para: users@cxf.apache.org
CC: Inmaculada Marín
Asunto: Re: Web service generation problem - WSDL2Java
On Monday 04 October 2010 10:38:56 am Inmaculada Marín wrote:
> Hello,
>
> I have use the following binding file:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <jxb:bindings version="1.0"
> xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
> xmlns:xs="http://www.w3.org/2001/XMLSchema">
> <jxb:bindings schemaLocation="dss-v1.0-core-schema-cd-r03.xsd"
> node="//xs:element[@name='SignRequest']">
> <jxb:dom/>
> </jxb:bindings>
> </jxb:bindings>
>
>
> But I get the following error:
>
> WSDLToJava Error: Thrown by JAXB : compiler was unable to honor this dom
> customization. It is attached to a wrong place, or its inconsistent with
> other bindings. at line 7 column 24 of schema file:/C:/binding1.xjb
>
>
> The fact is that the element 'SignRequest' is of a complex type which
> includes several elements... could this be the problem? Or is it something
> wrong in my binding file?
Honestly, I have no idea. I've never used the jxb:dom binding thing.
The best bet would be to see if you can just use the "xjc" tool (comes with
java6) and your schema/binding files and see if you can get it to work with
that. If not, send to the jaxb mailing lists. Someone there would DEFINITELY
be in a better possition to help.
https://jaxb.dev.java.net/servlets/ProjectMailingListList
or
http://forums.java.net/jive/forum.jspa?forumID=46&start=0
Dan
>
> Thank you very much in advance.
> Regards,
> Inma.
>
> -----Mensaje original-----
> De: Daniel Kulp [mailto:dkulp@apache.org]
> Enviado el: viernes, 01 de octubre de 2010 16:20
> Para: users@cxf.apache.org
> CC: Inmaculada Marín
> Asunto: Re: Web service generation problem - WSDL2Java
>
>
>
> A JAXB/JAX-WS customization file can be used to have certains parts of the
> schema generated as DOM's instead of types. The problem will come if you
> have a LOT of elements that need this as it's usually applied xpath based.
> You might be able to write an xslt transform or something to generate the
> binding file.
>
> It would look something like:
>
> <jxb:bindings version="1.0"
> xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
> xmlns:xs="http://www.w3.org/2001/XMLSchema">
>
> <jxb:bindings schemaLocation="foo.xsd"
>
> node="/xs:schema/xs:element[name='MyElement']/xs:element[name='field']">
> <jxb:dom/>
> </jxb:bindings>
>
> </jxb:bindings>
>
>
> Dan
>
> On Friday 01 October 2010 3:49:12 am Inmaculada Marín wrote:
> > Hi all,
> >
> >
> >
> > I developed a web service with an old version of JDeveloper some time
> > ago, but now I have to migrate it to CXF. The WSDL uses elements from
> > an schema (as operation parameters), but in the implementation the type
> > of the parameters are org.w3c.dom.Element (that is because of the
> > JDeveloper version used then).
> >
> >
> >
> > When I try to generate the service skeleton (using the same WSDL that the
> > old web service has) using WSDL2Java tool, classes from the schema are
> > generated, and the web service operations have parameters of these
> > classes (classes from the schema). Then, several tests has been
> > accomplished:
> >
> > - if I try to change the type of these parameters to type
> > org.w3c.dom.Element (so as to include all the web service implementation
> > I already have, ‘as-is’), I have an error when invoking that service, as
> > the input parameter type is not the one expected.
> >
> > - If I keep the type of these parameters as generated by
> > WSDL2Java tool, I marshall the input parameters, so as to obtain an
> > object of type org.w3c.dom.Element, then I include all my web service
> > implementation, and then I turn the result (an object of type
> > org.w3c.dom.Element) into an object of the expected type (from the
> > schema) by unmarshalling the org.w3c.dom.Element. However, some values
> > of XML elements are lost, and the object returned is not correct
> > (besides, the prefix namespaces are changed to ns2, ns3 and so).
> >
> >
> >
> > Is there is a way of indicating WSDL2Java tool a mapping from schema
> > elements to java classes, so as to telling which classes has to use for
> > specific schema element (that is, if an operation has a parameter of type
> > x:ParameterType defined in the used schema, maybe I could say the
> > WSDL2Java tool not to generate this element java class, but to use an
> > existing java class instead)?
> >
> >
> >
> > I have to keep all the implementation of my ‘old’ web service, as is a
> > huge one and it is very expensive to use java classes generated by
> > WSDL2Java tool within that implementation.
> >
> >
> >
> > Can you be so kind as to help me, please?
> >
> >
> >
> > Thank you very much in advance.
> >
> >
> >
> > Regards,
> >
> > Inma.
--
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog
Re: Web service generation problem - WSDL2Java
Posted by Daniel Kulp <dk...@apache.org>.
On Monday 04 October 2010 10:38:56 am Inmaculada Marín wrote:
> Hello,
>
> I have use the following binding file:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <jxb:bindings version="1.0"
> xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
> xmlns:xs="http://www.w3.org/2001/XMLSchema">
> <jxb:bindings schemaLocation="dss-v1.0-core-schema-cd-r03.xsd"
> node="//xs:element[@name='SignRequest']">
> <jxb:dom/>
> </jxb:bindings>
> </jxb:bindings>
>
>
> But I get the following error:
>
> WSDLToJava Error: Thrown by JAXB : compiler was unable to honor this dom
> customization. It is attached to a wrong place, or its inconsistent with
> other bindings. at line 7 column 24 of schema file:/C:/binding1.xjb
>
>
> The fact is that the element 'SignRequest' is of a complex type which
> includes several elements... could this be the problem? Or is it something
> wrong in my binding file?
Honestly, I have no idea. I've never used the jxb:dom binding thing.
The best bet would be to see if you can just use the "xjc" tool (comes with
java6) and your schema/binding files and see if you can get it to work with
that. If not, send to the jaxb mailing lists. Someone there would DEFINITELY
be in a better possition to help.
https://jaxb.dev.java.net/servlets/ProjectMailingListList
or
http://forums.java.net/jive/forum.jspa?forumID=46&start=0
Dan
>
> Thank you very much in advance.
> Regards,
> Inma.
>
> -----Mensaje original-----
> De: Daniel Kulp [mailto:dkulp@apache.org]
> Enviado el: viernes, 01 de octubre de 2010 16:20
> Para: users@cxf.apache.org
> CC: Inmaculada Marín
> Asunto: Re: Web service generation problem - WSDL2Java
>
>
>
> A JAXB/JAX-WS customization file can be used to have certains parts of the
> schema generated as DOM's instead of types. The problem will come if you
> have a LOT of elements that need this as it's usually applied xpath based.
> You might be able to write an xslt transform or something to generate the
> binding file.
>
> It would look something like:
>
> <jxb:bindings version="1.0"
> xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
> xmlns:xs="http://www.w3.org/2001/XMLSchema">
>
> <jxb:bindings schemaLocation="foo.xsd"
>
> node="/xs:schema/xs:element[name='MyElement']/xs:element[name='field']">
> <jxb:dom/>
> </jxb:bindings>
>
> </jxb:bindings>
>
>
> Dan
>
> On Friday 01 October 2010 3:49:12 am Inmaculada Marín wrote:
> > Hi all,
> >
> >
> >
> > I developed a web service with an old version of JDeveloper some time
> > ago, but now I have to migrate it to CXF. The WSDL uses elements from
> > an schema (as operation parameters), but in the implementation the type
> > of the parameters are org.w3c.dom.Element (that is because of the
> > JDeveloper version used then).
> >
> >
> >
> > When I try to generate the service skeleton (using the same WSDL that the
> > old web service has) using WSDL2Java tool, classes from the schema are
> > generated, and the web service operations have parameters of these
> > classes (classes from the schema). Then, several tests has been
> > accomplished:
> >
> > - if I try to change the type of these parameters to type
> > org.w3c.dom.Element (so as to include all the web service implementation
> > I already have, ‘as-is’), I have an error when invoking that service, as
> > the input parameter type is not the one expected.
> >
> > - If I keep the type of these parameters as generated by
> > WSDL2Java tool, I marshall the input parameters, so as to obtain an
> > object of type org.w3c.dom.Element, then I include all my web service
> > implementation, and then I turn the result (an object of type
> > org.w3c.dom.Element) into an object of the expected type (from the
> > schema) by unmarshalling the org.w3c.dom.Element. However, some values
> > of XML elements are lost, and the object returned is not correct
> > (besides, the prefix namespaces are changed to ns2, ns3 and so).
> >
> >
> >
> > Is there is a way of indicating WSDL2Java tool a mapping from schema
> > elements to java classes, so as to telling which classes has to use for
> > specific schema element (that is, if an operation has a parameter of type
> > x:ParameterType defined in the used schema, maybe I could say the
> > WSDL2Java tool not to generate this element java class, but to use an
> > existing java class instead)?
> >
> >
> >
> > I have to keep all the implementation of my ‘old’ web service, as is a
> > huge one and it is very expensive to use java classes generated by
> > WSDL2Java tool within that implementation.
> >
> >
> >
> > Can you be so kind as to help me, please?
> >
> >
> >
> > Thank you very much in advance.
> >
> >
> >
> > Regards,
> >
> > Inma.
--
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog
RE: Web service generation problem - WSDL2Java
Posted by Inmaculada Marín <in...@um.es>.
Hello,
I have use the following binding file:
<?xml version="1.0" encoding="UTF-8"?>
<jxb:bindings version="1.0"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<jxb:bindings schemaLocation="dss-v1.0-core-schema-cd-r03.xsd"
node="//xs:element[@name='SignRequest']">
<jxb:dom/>
</jxb:bindings>
</jxb:bindings>
But I get the following error:
WSDLToJava Error: Thrown by JAXB : compiler was unable to honor this dom customization. It is attached to a wrong place, or its inconsistent with other bindings. at line 7 column 24 of schema file:/C:/binding1.xjb
The fact is that the element 'SignRequest' is of a complex type which includes several elements... could this be the problem? Or is it something wrong in my binding file?
Thank you very much in advance.
Regards,
Inma.
-----Mensaje original-----
De: Daniel Kulp [mailto:dkulp@apache.org]
Enviado el: viernes, 01 de octubre de 2010 16:20
Para: users@cxf.apache.org
CC: Inmaculada Marín
Asunto: Re: Web service generation problem - WSDL2Java
A JAXB/JAX-WS customization file can be used to have certains parts of the
schema generated as DOM's instead of types. The problem will come if you
have a LOT of elements that need this as it's usually applied xpath based.
You might be able to write an xslt transform or something to generate the
binding file.
It would look something like:
<jxb:bindings version="1.0"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<jxb:bindings schemaLocation="foo.xsd"
node="/xs:schema/xs:element[name='MyElement']/xs:element[name='field']">
<jxb:dom/>
</jxb:bindings>
</jxb:bindings>
Dan
On Friday 01 October 2010 3:49:12 am Inmaculada Marín wrote:
> Hi all,
>
>
>
> I developed a web service with an old version of JDeveloper some time ago,
> but now I have to migrate it to CXF. The WSDL uses elements from an schema
> (as operation parameters), but in the implementation the type of the
> parameters are org.w3c.dom.Element (that is because of the JDeveloper
> version used then).
>
>
>
> When I try to generate the service skeleton (using the same WSDL that the
> old web service has) using WSDL2Java tool, classes from the schema are
> generated, and the web service operations have parameters of these classes
> (classes from the schema). Then, several tests has been accomplished:
>
> - if I try to change the type of these parameters to type
> org.w3c.dom.Element (so as to include all the web service implementation I
> already have, ‘as-is’), I have an error when invoking that service, as the
> input parameter type is not the one expected.
>
> - If I keep the type of these parameters as generated by WSDL2Java
> tool, I marshall the input parameters, so as to obtain an object of type
> org.w3c.dom.Element, then I include all my web service implementation, and
> then I turn the result (an object of type org.w3c.dom.Element) into an
> object of the expected type (from the schema) by unmarshalling the
> org.w3c.dom.Element. However, some values of XML elements are lost, and the
> object returned is not correct (besides, the prefix namespaces are changed
> to ns2, ns3 and so).
>
>
>
> Is there is a way of indicating WSDL2Java tool a mapping from schema
> elements to java classes, so as to telling which classes has to use for
> specific schema element (that is, if an operation has a parameter of type
> x:ParameterType defined in the used schema, maybe I could say the WSDL2Java
> tool not to generate this element java class, but to use an existing java
> class instead)?
>
>
>
> I have to keep all the implementation of my ‘old’ web service, as is a huge
> one and it is very expensive to use java classes generated by WSDL2Java
> tool within that implementation.
>
>
>
> Can you be so kind as to help me, please?
>
>
>
> Thank you very much in advance.
>
>
>
> Regards,
>
> Inma.
--
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog
Re: Web service generation problem - WSDL2Java
Posted by Daniel Kulp <dk...@apache.org>.
A JAXB/JAX-WS customization file can be used to have certains parts of the
schema generated as DOM's instead of types. The problem will come if you
have a LOT of elements that need this as it's usually applied xpath based.
You might be able to write an xslt transform or something to generate the
binding file.
It would look something like:
<jxb:bindings version="1.0"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<jxb:bindings schemaLocation="foo.xsd"
node="/xs:schema/xs:element[name='MyElement']/xs:element[name='field']">
<jxb:dom/>
</jxb:bindings>
</jxb:bindings>
Dan
On Friday 01 October 2010 3:49:12 am Inmaculada Marín wrote:
> Hi all,
>
>
>
> I developed a web service with an old version of JDeveloper some time ago,
> but now I have to migrate it to CXF. The WSDL uses elements from an schema
> (as operation parameters), but in the implementation the type of the
> parameters are org.w3c.dom.Element (that is because of the JDeveloper
> version used then).
>
>
>
> When I try to generate the service skeleton (using the same WSDL that the
> old web service has) using WSDL2Java tool, classes from the schema are
> generated, and the web service operations have parameters of these classes
> (classes from the schema). Then, several tests has been accomplished:
>
> - if I try to change the type of these parameters to type
> org.w3c.dom.Element (so as to include all the web service implementation I
> already have, as-is), I have an error when invoking that service, as the
> input parameter type is not the one expected.
>
> - If I keep the type of these parameters as generated by WSDL2Java
> tool, I marshall the input parameters, so as to obtain an object of type
> org.w3c.dom.Element, then I include all my web service implementation, and
> then I turn the result (an object of type org.w3c.dom.Element) into an
> object of the expected type (from the schema) by unmarshalling the
> org.w3c.dom.Element. However, some values of XML elements are lost, and the
> object returned is not correct (besides, the prefix namespaces are changed
> to ns2, ns3 and so).
>
>
>
> Is there is a way of indicating WSDL2Java tool a mapping from schema
> elements to java classes, so as to telling which classes has to use for
> specific schema element (that is, if an operation has a parameter of type
> x:ParameterType defined in the used schema, maybe I could say the WSDL2Java
> tool not to generate this element java class, but to use an existing java
> class instead)?
>
>
>
> I have to keep all the implementation of my old web service, as is a huge
> one and it is very expensive to use java classes generated by WSDL2Java
> tool within that implementation.
>
>
>
> Can you be so kind as to help me, please?
>
>
>
> Thank you very much in advance.
>
>
>
> Regards,
>
> Inma.
--
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog