You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Igor Lobanov <ig...@ymail.com> on 2010/11/25 06:23:57 UTC

Using elements from "extra" XSD schema for extensions

Hi,

I have WDSL+XSD web service contract for which I need to implement both
client and server sides. There is a bunch of <xsd:any
targetNamespace="##any"> placeholders in server's replies for which I need
to be able to use "extension elements" from other XML namespaces, which are
not known in advance (and not, therefore, hardcoded in WSDL). Nevertheless,
client may be aware of some of the extensions and may have JAXB-driven POJOs
for their schemas. JAXB compiler treats these extension points as List
properties. I would client to find there either DOM elements for unknown
extensions or bound POJOs for known extensions.

It seems that on the server side it works, although, I haven't checked this
out yet. Theoretically I am able to put there both DOM elements or
JABX-bound POJOs and marshaller will determine proper XML encoding from
annotations.

However, on the client's site is looks trickier. Could you explain how
client's unmarshaller can find proper JAXB bindins for encountered elements
from different schemas? I suppose there may be a way to add additional java
packages to unmarshaller's JAXB context, but I haven't found it by browsing
both documentation and code.

Thanks a lot in advance.

--
Best regards,
Igor Lobanov
-- 
View this message in context: http://cxf.547215.n5.nabble.com/Using-elements-from-extra-XSD-schema-for-any-extensions-tp3279551p3279551.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Using elements from

Posted by Igor Lobanov <ig...@ymail.com>.
I've figured this out by tracing invocations of JAXBContext.newInstance(). It
seems that there is a built-in mechanism for this purpose in JAXB. Generated
port interface contains @XmlSeeAlso({ObjectFactory.class}), but you can
refer there to classes for all of your recognized extensions. Having
processed this annotation CXF adds everything you've got there to JAXB
context. You also need to put @XmlRootElement to classes which represent
top-level types of extensions.

The only drawback is that when you generate classes from WSDL you need to
manually edit them afterwards to refer to recognized extensions, which
effectively means that you have to keep generated code under the version
control.
-- 
View this message in context: http://cxf.547215.n5.nabble.com/Using-elements-from-extra-XSD-schema-for-any-extensions-tp3279551p3281003.html
Sent from the cxf-user mailing list archive at Nabble.com.