摆脱 JAX-WS 中的空 xmlns 元素

Get rid of empty xmlns element in JAX-WS

我正在尝试使用 JAX-WS 客户端生成这样的请求:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:alin="http://www.alinma.com" xmlns="http://www.alinma.com"> 
<soapenv:Header/>
<soapenv:Body>
    <alin:CustDtlsInqRq>
        <alin:MsgRqHdr>
            <RqUID>BPM11957T201508101626333904816</RqUID>
            <SCId>BPMP</SCId>
            <FuncId>24000000</FuncId>
            <RqMode>0</RqMode>
            <CustLangPref>En</CustLangPref>
            <CustId>
                <CIF>6060</CIF>
            </CustId>
            <AgentId>OprtSupportReviewer</AgentId>
        </alin:MsgRqHdr>
        <Body>
            <CIF>6060</CIF>
        </Body>
    </alin:CustDtlsInqRq>
</soapenv:Body>

但是请求是这样生成的:

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://www.alinma.com">
<S:Header/>
<S:Body>
    <ns2:CustDtlsInqRq xmlns:ns2="http://www.alinma.com">
        <MsgRqHdr xmlns="">
            <RqUID>OLPM201508261333149660000020</RqUID>
            <SCId>BPMP</SCId>
            <FuncId>24000000</FuncId>
            <CustLangPref>En</CustLangPref>
            <CustId>
                <CIF>6060</CIF>
            </CustId>
        </MsgRqHdr>
        <Body xmlns="">
            <CIF>6060</CIF>
        </Body>
    </ns2:CustDtlsInqRq>
</S:Body>

添加的标签 xmlns="" 在服务器端出现问题 这是我的处理程序的代码,它用 SOAP 信封

包围请求
if (outboundProperty.booleanValue()) {

        try {
            SOAPMessage soapMessage = context.getMessage();

            SOAPEnvelope soapEnvelope = soapMessage.getSOAPPart().getEnvelope();
            soapEnvelope.addNamespaceDeclaration("", "http://www.alinma.com");
            // Grab the header of the SOAP envelop
            SOAPHeader soapHeader = soapEnvelope.getHeader();

            // Attach a new header if there is none...
            if (soapHeader == null) {
                soapHeader = soapEnvelope.addHeader();
            }

            soapMessage.saveChanges();
            soapMessage.writeTo(System.out); //TODO: remove this line (just for debugging)

        } catch (Exception e) {
            logger.error("Error Creating SOAP message", e);
        }  

    }

如何调整空 xmlns 标签?

我可以解决问题。 我错误地删除了生成的文件 package-info.java,其中包含所有包 类

的 header 命名空间定义
@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.alinma.com", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package com.ejada.sadadolp.bkf.mwservices.core;