aspose file tools*
The moose likes Web Services and the fly likes More fun with JAXB, trying to implement Oasis WSN top down - errors genned Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "More fun with JAXB, trying to implement Oasis WSN top down - errors genned " Watch "More fun with JAXB, trying to implement Oasis WSN top down - errors genned " New topic
Author

More fun with JAXB, trying to implement Oasis WSN top down - errors genned

Max Tomlinson
Ranch Hand

Joined: Jul 17, 2001
Posts: 365
Hi all (and hopefully Ivan):

I'm using wsconsume to generate artifacts for a JBoss 4.2 JAX-WS service (this is mentioned in one other post where I encountered JAXB errors)

There are JAXB errors related to the WSN Notification spec. The issue seems to be that some types are defined as QName with no parms and the generated code can't handle these.
It can't instantiate QName. If I modify the generated code to make it a String, it loads.

Here's a sample of what wsconsume gens:

@XmlAttribute
protected List<QName> messageTypes;

public List<QName> getMessageTypes() {
if (messageTypes == null) {
messageTypes = new ArrayList<QName>();
}
return this.messageTypes;
}

the new ArrayList<QName>() is the problem - it causes a JAXB exception - no default constructor


And here is what AXIS2 gens:


public java.util.List getMessageTypes()
{

synchronized (monitor())

{

check_orphaned();

org.apache.xmlbeans.SimpleValue target = null;

target = (org.apache.xmlbeans.SimpleValue)get_store().find_attribute_user(MESSAGETYPES$6);

if (target == null)

{

return null;

and

private static final javax.xml.namespace.QName MESSAGETYPES$6 = new javax.xml.namespace.QName("", "messageTypes");


So you can see AXIS2 creates the List with a QName("", "messageTypes")

and wsconsume (JAXB) does not


JAXB err
e.g.

# java.lang.IllegalStateException: Cannot build JAXB context
# at org.jboss.ws.metadata.builder.jaxws.JAXWSMetaDataBuilder.createJAXBContext(JAXWSMetaDataBuilder.java:925)
# @XmlAttribute/@XmlValue need to reference a Java type that maps to text in XML.
# this problem is related to the following location:
# at protected java.util.List org.oasis_open.docs.wsn.t_1.TopicType.messageTypes
#

So the problem is that the generated wsconsume stubs define messageTypes as List<QName>. If I change it to List<String> I get past the problem.
But obviously, this is not good. I want to implement the Oasis WSN spec and generate working stubs and go from there.

From the spec for this (Oasis WSN spec):

<xsd:attribute name="messageTypes">
<xsd:simpleType>
<xsd:list itemType="xsd:QName"/>
</xsd:simpleType>
</xsd:attribute>

Do I need to create JAXB binding files to somehow change the type of xsd:QName to something else? e.g. QName("", "messageTypes")
(I can pass binding files into the wsconsume process)
How can I do this?
Can I get a sample?

any help greatly appreciated.

Max



Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Can you provide a link to the complete XML schema containing the data structure you have problems with?
I do not use Axis, but I am regardless curious to see what JAXB makes out of that schema.
I come to think of using a JAXB mapping file to map QName to String, but I will take a look and let you know.
Best wishes!


My free books and tutorials: http://www.slideshare.net/krizsan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: More fun with JAXB, trying to implement Oasis WSN top down - errors genned
 
Similar Threads
JAXB annotation error
Error creatin Top down web service with Eclipse Helios
Apache Axis versus JbossWS
Passing Set<java.lang.Object> and List<java.lang.Object> in Axis 2.0
Top-Down approach: WSDL, JAX-WS and JAXB