Reputation: 13061
i'm trying to remove blank xmlns from the xml request generated from stub that i've auto-generated from a wsdl using the axis wizard.
Axis wizard generates the request class in which there is:
private static org.apache.axis.description.TypeDesc typeDesc =
new org.apache.axis.description.TypeDesc(Request.class, true);
static {
typeDesc.setXmlType(new javax.xml.namespace.QName("http://myNamespace"));
org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc();
elemField.setFieldName("destinationIdsInfo");
elemField.setXmlName(new javax.xml.namespace.QName("", "DestinationIdsInfo"));//IF I REMOVE THIS EVERY ELEMENT INSIDE THAT TAG WILL HAVE xmlns="".
elemField.setXmlType(new javax.xml.namespace.QName("", "DestinationIdInfo"));
elemField.setMinOccurs(0);
elemField.setNillable(false);
elemField.setItemQName(new javax.xml.namespace.QName("", "DestinationIdInfo"));
....
}
This generates me an xml like this:
...
<DestinationIdsInfo xmlns="">
<DestinationIdInfo id="xxxx"/>
</DestinationIdsInfo>
...
But i need
<DestinationIdsInfo>
<DestinationIdInfo id="xxxx"/>
</DestinationIdsInfo>
How can i solve??
Upvotes: 4
Views: 6274
Reputation: 1504122
You should specify the same namespace URI for your nested elements:
elemField.setXmlName(new javax.xml.namespace.QName("http://myNamespace",
"DestinationIdsInfo"))
(Ditto for DestinationIdInfo
.)
It will then inherit the namespace from the containing element, which is why I believe you want.
See the XML namespaces specification section 6.2 for more information about namespace defaulting.
Upvotes: 5