Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Axis2、XMLBeans和政府服务—处理名称空间_Xml_Axis2_Xmlbeans - Fatal编程技术网

Axis2、XMLBeans和政府服务—处理名称空间

Axis2、XMLBeans和政府服务—处理名称空间,xml,axis2,xmlbeans,Xml,Axis2,Xmlbeans,因此,我使用Axis2从WSDL文件(使用XMLBeans)生成存根类,并从它们的XSD文件生成实体 问题是:生成的envolope如下所示: <?xml version='1.0' encoding='utf-8'?> <soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"> <soapenv:Header> <nfeCabecMsg soapenv

因此,我使用Axis2从WSDL文件(使用XMLBeans)生成存根类,并从它们的XSD文件生成实体

问题是:生成的envolope如下所示:

<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
  <soapenv:Header>
    <nfeCabecMsg soapenv:mustUnderstand="false" xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NfeAutorizacao">
      <versaoDados>3.10</versaoDados>
      <cUF>51</cUF>
    </nfeCabecMsg>
  </soapenv:Header>
  <soapenv:Body>
    <nfeDadosMsg xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NfeAutorizacao">
      <enviNFe versao="3.10" xmlns="http://www.portalfiscal.inf.br/nfe">
        <idLote>1</idLote>
        <indSinc>0</indSinc>
        <NFe>
          <!-- supressed -->
        </NFe>
      </enviNFe>
    </nfeDadosMsg>
  </soapenv:Body>
</soapenv:Envelope>
<enviNFe versao="3.10" xmlns="http://www.portalfiscal.inf.br/nfe">
  <idLote>1</idLote>
  <indSinc>0</indSinc>
  <NFe xmlns="http://www.portalfiscal.inf.br/nfe">
    <!-- supressed -->
  </NFe>
</enviNFe>

3.10
51
1.
0
更具体地说,问题在于这一点:

<enviNFe versao="3.10" xmlns="http://www.portalfiscal.inf.br/nfe">
  <idLote>1</idLote>
  <indSinc>0</indSinc>
  <NFe>
    <!-- supressed -->
  </NFe>
</enviNFe>

1.
0
但是,出于某种随机原因,他们希望它是这样的:

<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
  <soapenv:Header>
    <nfeCabecMsg soapenv:mustUnderstand="false" xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NfeAutorizacao">
      <versaoDados>3.10</versaoDados>
      <cUF>51</cUF>
    </nfeCabecMsg>
  </soapenv:Header>
  <soapenv:Body>
    <nfeDadosMsg xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NfeAutorizacao">
      <enviNFe versao="3.10" xmlns="http://www.portalfiscal.inf.br/nfe">
        <idLote>1</idLote>
        <indSinc>0</indSinc>
        <NFe>
          <!-- supressed -->
        </NFe>
      </enviNFe>
    </nfeDadosMsg>
  </soapenv:Body>
</soapenv:Envelope>
<enviNFe versao="3.10" xmlns="http://www.portalfiscal.inf.br/nfe">
  <idLote>1</idLote>
  <indSinc>0</indSinc>
  <NFe xmlns="http://www.portalfiscal.inf.br/nfe">
    <!-- supressed -->
  </NFe>
</enviNFe>

1.
0
是的,在中仅复制父对象的
xmlns
,我知道这毫无意义,但我无法控制它

为了防止其他疯狂行为,我已经在替换生成的存根类中的代码,更准确地说,我添加了
setUseDefaultNamespace
选项


我尝试了一些假设来解决这个问题,但没有成功。我该怎么做呢?

我最终更改了生成的
.java
文件


问题似乎是提供的
wsdl

作为建议,我建议您转到JAX-WS。我个人喜欢XMLBeans创建XML数据库,但仅此而已。Axis2是一个真正的难题,永远无法使用它管理Web服务。