如何更改根xml元素wsimport的xmlns命名空间?

时间:2019-09-15 13:17:27

标签: java web-services soap jax-ws wsimport

嗨,我收到了一个错误的请求,因为AuthActionRequest前缀为ns2,并且在soap ui中将前缀从ns2手动更改为ns4时,我得到了很好的响应。这些类是使用wsimport生成的,我如何将打开和关闭标签的AuthActionRequest前缀都更改为ns4,而又不影响其他前缀?

这是wsimport生成的错误请求:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
  <SOAP-ENV:Header/>
  <SOAP-ENV:Body>
    <ns2:AuthActionRequest xmlns:ns2="http://www.foo.co.za/gts/shared/enterpriseMessage/v2" xmlns:ns3="http://www.foo.co.za/gts/cdm/auth/v1" xmlns:ns4="http://www.foo.co.za/gts/auth/AuthActionService/AuthAction/v1">
      <ns2:header>
        <ns2:senderID>foo</ns2:senderID>
        <ns2:messageID>1536328380819</ns2:messageID>
        <ns2:timestamp>2019-09-15T14:59:52.755+02:00</ns2:timestamp>
        <ns2:correlationID>1536328380819</ns2:correlationID>
        <ns2:originatingMessageID>1536328380819</ns2:originatingMessageID>
        <ns2:referenceID>1536328380819</ns2:referenceID>
        <ns2:messageDescription>Request</ns2:messageDescription>
      </ns2:header>
      <ns4:authorisorDetails>
        <ns3:authDeviceID>ABCD</ns3:authDeviceID>
        <ns3:authUserReference>0000</ns3:authUserReference>
        <ns3:authorisationTime>1736328380819</ns3:authorisationTime>
        <ns3:mechanism>OTP</ns3:mechanism>
        <ns3:rfn>0</ns3:rfn>
        <ns3:signedData/>
        <ns3:action>AUTHORIZE</ns3:action>
        <ns3:authoriserName/>
      </ns4:authorisorDetails>
      <ns4:token>ABCD</ns4:token>
      <ns4:action>AUTHORIZE</ns4:action>
      <ns4:signedData/>
    </ns2:AuthActionRequest>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

这是我需要将请求更改为我手动更改的内容:

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
  <SOAP-ENV:Header/>
  <SOAP-ENV:Body>
    <ns4:AuthActionRequest xmlns:ns2="http://www.foo.co.za/gts/shared/enterpriseMessage/v2" xmlns:ns3="http://www.foo.co.za/gts/cdm/auth/v1" xmlns:ns4="http://www.foo.co.za/gts/auth/AuthActionService/AuthAction/v1">
      <ns2:header>
        <ns2:senderID>FOO</ns2:senderID>
        <ns2:messageID>1536328380819</ns2:messageID>
        <ns2:timestamp>2019-09-15T14:59:52.755+02:00</ns2:timestamp>
        <ns2:correlationID>1536328380819</ns2:correlationID>
        <ns2:originatingMessageID>1536328380819</ns2:originatingMessageID>
        <ns2:referenceID>1536328380819</ns2:referenceID>
        <ns2:messageDescription>Request</ns2:messageDescription>
      </ns2:header>
      <ns4:authorisorDetails>
        <ns3:authDeviceID>94120FAD-6B16-440F-A393-F2E8D5BFADFE</ns3:authDeviceID>
        <ns3:authUserReference>0000</ns3:authUserReference>
        <ns3:authorisationTime>1736328380819</ns3:authorisationTime>
        <ns3:mechanism>OTP</ns3:mechanism>
        <ns3:rfn>0</ns3:rfn>
        <ns3:signedData/>
        <ns3:action>AUTHORIZE</ns3:action>
        <ns3:authoriserName/>
      </ns4:authorisorDetails>
      <ns4:token>ABCD</ns4:token>
      <ns4:action>AUTHORIZE</ns4:action>
      <ns4:signedData/>
    </ns4:AuthActionRequest>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

下面是我的package-info.java文件:

@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.foo.co.za/gts/shared/enterpriseMessage/v2", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package za.co.fnb.connect.fester.wsimport;

要使用正确的前缀自动生成请求,我需要做什么?

0 个答案:

没有答案