JDOM Stream writer does not properly handle namespace on attributes of element
------------------------------------------------------------------------------
Key: XFIRE-828
URL: http://jira.codehaus.org/browse/XFIRE-828
Project: XFire
Issue Type: Bug
Components: JAXB 2.0
Affects Versions: 1.2.2
Environment: Linux, Eclipse 3.2, xfire 1.2.2
Reporter: Yogesh Chawla
Assigned To: Dan Diephouse
I autogenerated an xfire client using the Eclipse plugin. When I go to invoke
my webservice, I get the following error:
Caused by: org.jdom.IllegalNameException: The name "" is not legal for JDOM/XML
attribute namespaces: An attribute namespace without a prefix can only be the
NO_NAMESPACE namespace.
at org.jdom.Attribute.setNamespace(Attribute.java:456)
at org.jdom.Attribute.<init>(Attribute.java:206)
at
org.codehaus.xfire.util.stax.JDOMStreamWriter.writeAttribute(JDOMStreamWriter.java:124)
The app crashes because the 'namespace' attribute is "". There are two methods
for 'writeAttribute'. One that accepts a prefix and one that does not:
public void writeAttribute(String prefix, String namespace, String local,
String value)
throws XMLStreamException
{
currentNode.setAttribute(new Attribute(local, value,
Namespace.getNamespace(prefix, namespace)));
}
public void writeAttribute(String namespace, String local, String value)
throws XMLStreamException
{
currentNode.setAttribute(new Attribute(local, value,
Namespace.getNamespace(namespace)));
}
Perhaps the XMLStreamWriterOutput.attribute is calling the wrong method. The
two attributes where the failure occurs
should use the default namespace for the element but do not.
To test this, one can generated code from this WSDL:
https://wijis.wisconsin.gov/wsdl/PointerCountService.wsdl
The client can then instantiate a Message Tracking Info object and call the
service like so:
public static final void main(String args[])
{
PointerCountServiceClient myClient = new PointerCountServiceClient();
PointerManagementInvocationType pointerCount = new
PointerManagementInvocationType();
pointerCount.setSubmitterURI("http://wijis.wisconsin.gov/names/operators");
WijisMessageTrackingInfoType messageTrackingInfo = new
WijisMessageTrackingInfoType();
BigInteger convSequence = BigInteger.ZERO;
BigInteger reqInvocationNumber = BigInteger.valueOf(10000);
BigInteger serviceInvocationNumber = BigInteger.valueOf(1);
messageTrackingInfo.setAdHocUserURI("http://[EMAIL
PROTECTED]/names/directories/");
messageTrackingInfo.setBranchStack("0");
messageTrackingInfo.setConvSeq(convSequence);
System.out.println(messageTrackingInfo.getBranchStack());
messageTrackingInfo.setCurrentSendingOperatorURI("http://wijis.wisconsin.gov/names/operators/");
messageTrackingInfo.setCurrentServiceDefURI("http://wijis.wisconsin.gov/gateway/services/Pointer/request/countMyPointers/");
messageTrackingInfo.setCurrentServiceLabel("dont know");
messageTrackingInfo.setCurrentServiceProviderURI("http://wijis.wisconsin.gov/names/operators/");
messageTrackingInfo.setInitialUserURI("http://[EMAIL
PROTECTED]/names/directories/");
messageTrackingInfo.setRequesterInvocationNum(reqInvocationNumber);
messageTrackingInfo.setServiceInvocationNum(serviceInvocationNumber);
messageTrackingInfo.setServiceLabel("dont know");
messageTrackingInfo.setServiceDefURI("http://wijis.wisconsin.gov/gateway/services/Pointer/request/countMyPointers/");
messageTrackingInfo.setServiceProviderURI("http://wijis.wisconsin.gov/names/operators/");
messageTrackingInfo.setServiceRequesterURI("http://wijis.wisconsin.gov/names/operators/");
Holder<WijisMessageTrackingInfoType> messageTrackingInfo2 = new
Holder();
try {
PointerCountResponseType response =
myClient.getPointerCountServiceSOAP("http://localhost:8080/xfire/PointerCount").pointerCount(pointerCount,
messageTrackingInfo, messageTrackingInfo2);
System.out.println(response.getRecordCount());
} catch (PointerCountError e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
After this the error will occur on the attributes: convSeq and branchStack.
Both of these attributes use the default namespace of the element
messageTrackingInfo. The default namespace is:
http://wijis.wisconsin.gov/specs/schemas/message/v1.0/2006-05-25/
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email