How to remove xmlns="" from xml request

JackTurky

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??

Jon Skeet

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.

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

XML命名空间-xmlns

来自分类Dev

什么是XML属性xmlns:app?

来自分类Dev

使用XSLT从XML删除xmlns

来自分类Dev

什么是XML属性xmlns:app?

来自分类Dev

How to remove � from a String?

来自分类Dev

xmllint:在非根xml元素上的xmlns?

来自分类Dev

如何从xml请求中删除xmlns =“”

来自分类Dev

在我的XML文件中包含xmlns

来自分类Dev

xml.etree.ElementTree-麻烦设置xmlns ='...'

来自分类Dev

将对象编组为xml并删除xmlns

来自分类Dev

XML无法将xmlns写入子节点

来自分类Dev

如何从xml请求中删除xmlns =“”

来自分类Dev

在XSLT中使用XMLNS的输出XML节点

来自分类Dev

由于xmlns而无法转换xml

来自分类Dev

How to send an XML request to a web service

来自分类Dev

删除xml中的xmlns属性,以获取简单的纯xml节点

来自分类Dev

How to remove apostrophe from text?

来自分类Dev

functx:remove-attributes添加一个空的xmlns

来自分类Dev

使用xslt从xml中删除xmlns soap属性

来自分类Dev

解组具有xmlns名称空间的xml文档

来自分类Dev

如何访问xmlns密钥,xml字符串中的val

来自分类Dev

Nokogiri无法在ruby中解析XML-xmlns问题?

来自分类Dev

从输出xml中删除空的xmlns命名空间

来自分类Dev

使用vbscript创建XML元素时如何避免xmlns属性?

来自分类Dev

JAXB生成的xml中的“ xsi:type”和“ xmlns:xsi”

来自分类Dev

当父节点具有XMLNS时读取XML失败

来自分类Dev

Python:在xml.etree元素上指定XMLNS

来自分类Dev

由于命名空间“ xmlns”,无法使用XSLT转换XML

来自分类Dev

使用FOR XML EXPLICIT时删除xmlns =“”名称空间声明