Skip to main content

Forced JAXB to use a specific Namespace prefix, but JAX-WS fails to dispatch SOAP item

No replies
tahicks
Offline
Joined: 2009-04-03
Points: 0

Modifying the package-info.java file (shown below) to contain some namespace prefix binding to the specific URI in question does result in the use of a prefix by JAXB, but only if jaxb-impl.jar is placed in the jre/lib/endorsed directory. This can be seen when the jaxb java object is marshalled to System.out. However, this results in its own set of problems when the jaxb java object is provided to javax.xml.ws.Dispatch.invoke method. The problem when invoke is called in brief is:

javax.xml.ws.WebServiceException: java.lang.ClassCastException: com.sun.xml.bind.v2.runtime.MarshallerImpl cannot be cast to com.sun.xml.internal.bind.v2.runtime.MarshallerImpl
How can I get around this exception and have this item successfully dispatched?
Thanks, Troy
More detail:
This is thrown from DispatchImpl.java:188. The back trace is:
javax.xml.ws.WebServiceException: java.lang.ClassCastException: com.sun.xml.bind.v2.runtime.MarshallerImpl cannot be cast to com.sun.xml.internal.bind.v2.runtime.MarshallerImpl
at com.sun.xml.internal.ws.client.dispatch.DispatchImpl.doInvoke(DispatchImpl.java:188)
at com.sun.xml.internal.ws.client.dispatch.DispatchImpl.invoke(DispatchImpl.java:195)
The package-info.java file that allows this is shown below in case it might be of help.

@javax.xml.bind.annotation.XmlSchema(
xmlns = {
@javax.xml.bind.annotation.XmlNs( prefix = "cwsns", namespaceURI="urn:Navy:C2.tracks:1.0:types")
},
namespace = "urn:Navy:C2.tracks:1.0:types",
elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED
)
package urn.navy.c2.tracks.webservice;