简体   繁体   中英

Override namespace with empty namespace CXF (JBoss EAP 6.2.4.GA)

I have the following issue with CXF version 2.7.7-redhat-1, that seems like a bug in the library. With the following request:

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

I get the following error:

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

From the request you can clearly see that the namespace of the request is "" overridden from its parent.

If I change the request to:

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

The call works. I need a way to fix this issue server side, the client can't be modified to change the request.

Versions: JBoss AS release: 7.3.4.Final-redhat-1 "Janus" JBoss AS product: EAP 6.2.4.GA java.version: 1.7.0_91

Set the elementFormDefault=qualified in the wsdl, generate the artifacts and redeploy the application.

Qualified means that local element declarations (xs:element within xs:complexType) refers to elements in the target namespace of the schema. Without it, they refer to elements in no namespace.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM