使用空命名空间CXF覆盖命名空间(JBoss EAP 6.2.4.GA)

时间:2016-01-29 12:35:43

标签: java jboss jaxb cxf jboss-eap-6

我对CXF版本2.7.7-redhat-1有以下问题,这似乎是库中的一个错误。 有以下要求:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <authorizePayment xmlns="http://ejb.example.org">
      <request xmlns="">
        <role xmlns:q1="http://to.homepay.example.org" xsi:type="q1:CustomerTO">
          <user>7C742</user>
        </role>
        <error>
          <errorCode>1</errorCode>
          <errorMessage>1</errorMessage>
        </error>
        <status>
          <code>1</code>
        </status>
        <ordAccount>1</ordAccount>
        <logId>374216011815223570893830967949</logId>
        <signMethod>1</signMethod>
        <lang>1</lang>
        <terminalId>1</terminalId>
        <terminalLocation>Earth</terminalLocation>
      </request>
    </authorizePayment>
  </soap:Body>
</soap:Envelope>

我收到以下错误:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <soap:Fault>
         <faultcode>soap:Client</faultcode>
         <faultstring>Unmarshalling Error: unexpected element (uri:"http://ejb.example.org", local:"request"). Expected elements are &lt;{}request></faultstring>
      </soap:Fault>
   </soap:Body>
</soap:Envelope>

从请求中您可以清楚地看到请求的命名空间是&#34;&#34;被父母重写。

如果我将请求更改为:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <aa:authorizePayment xmlns:aa="http://ejb.example.org">
      <request xmlns="">
        <role xmlns:q1="http://to.homepay.example.org" xsi:type="q1:CustomerTO">
          <user>7C742</user>
        </role>
        <error>
          <errorCode>1</errorCode>
          <errorMessage>1</errorMessage>
        </error>
        <status>
          <code>1</code>
        </status>
        <ordAccount>1</ordAccount>
        <logId>374216011815223570893830967949</logId>
        <signMethod>1</signMethod>
        <lang>1</lang>
        <terminalId>1</terminalId>
        <terminalLocation>Earth</terminalLocation>
      </request>
    </aa:authorizePayment>
  </soap:Body>
</soap:Envelope>

通话有效。我需要一种方法来修复此问题服务器端,客户端无法修改以更改请求。

版本: JBoss AS发布:7.3.4.Final-redhat-1&#34; Janus&#34; JBoss AS产品:EAP 6.2.4.GA java.version:1.7.0_91

1 个答案:

答案 0 :(得分:0)

在wsdl中设置elementFormDefault=qualified,生成工件并重新部署应用程序。

Qualified表示局部元素声明(xs:xs:complexType中的元素)引用架构的目标命名空间中的元素。没有它,它们会引用无名称空间中的元素。

相关问题