微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

外部 WSDL - 命名空间

如何解决外部 WSDL - 命名空间

我使用 Apache CXF 2.7.14 从外部 WSDL 生成存根。该请求带有 2 个命名空间,它用不同的命名空间包装参数,该命名空间最终从我正在调用的外部系统中失败。 有没有办法摆脱 2 个命名空间,并且只让请求使用一个(明确)。我需要以下内容来使用 ns2 或 ns3 而不是两者。但是我不知道如何做到这一点,因为它是隐式发生的。请帮忙

请求如下:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
       <soap:Body>
             <ns3:GetMG xmlns:ns2="http://xxxx-xxx.com/" xmlns:ns3="http://www.xxxx-xxx.com/">
                <ns2:msg>hello</ns2:msg>
                <ns2:creator>Creator</ns2:creator>
                <ns2:appid>appid</ns2:appid>
             </ns3:GetMG>
       </soap:Body>
</soap:Envelope>

生成的界面如下

/**
 * This class was generated by Apache CXF 2.7.14
 * 2021-04-12T20:44:12.100+02:00
 * Generated source version: 2.7.14
 * 
 */
@WebService(targetNamespace = "http://www.xxxx-xxx.com/",name = "MessageWSSoap")
@XmlSeeAlso({ObjectFactory.class})
public interface MessageWSSoap{
    
    
    @WebMethod(operationName = "GetMG",action = "http://www.xxxx-xxx.com/GetMG")
    @RequestWrapper(localName = "GetMG",targetNamespace = "http://www.xxxx-xxx.com/",className = "com.xxxx_xxx.GetMG")
    @ResponseWrapper(localName = "GetMGResponse",className = "com.xxxx_xxx.GetMGResponse")
    @WebResult(name = "GetMGResult",targetNamespace = "http://www.xxxx-xxx.com/")
    public com.xxxx_xxx.DeviceWSDL getMG(
        @WebParam(name = "msg",targetNamespace = "http://www.xxxx-xxx.com/")
        java.lang.String msg,@WebParam(name = "creator",targetNamespace = "http://www.xxxx-xxx.com/")
        java.lang.String creator,@WebParam(name = "appid",targetNamespace = "http://www.xxxx-xxx.com/")
        java.lang.String appid
    );
}

WSDL 看起来像这样:

<?xml version="1.0" encoding="utf-8"?>
<wsdl:deFinitions xmlns:s="http://www.w3.org/2001/XMLSchema"
    xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
    xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://www.xxxx-xxx.com/"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
    targetNamespace="http://www.xxxx-xxx.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
    <wsdl:types>
        <s:schema elementFormDefault="qualified" targetNamespace="http://www.xxxx-xxx.com/">
            <s:element name="GetMG">
                <s:complexType>
                    <s:sequence>
                        <s:element minOccurs="0" maxOccurs="1" name="msg" type="s:string" />
                        <s:element minOccurs="0" maxOccurs="1" name="creator"
                            type="s:string" />
                        <s:element minOccurs="0" maxOccurs="1" name="appid"
                            type="s:string" />
                    </s:sequence>
                </s:complexType>
            </s:element>
            <s:element name="GetMGResponse">
                <s:complexType>
                    <s:sequence>
                        <s:element minOccurs="0" maxOccurs="1" name="GetMGResult"
                            type="tns:DeviceWSDL" />
                    </s:sequence>
                </s:complexType>
            </s:element>
            
    </wsdl:types>
    <wsdl:message name="GetMGSoapIn">
        <wsdl:part name="parameters" element="tns:GetMG" />
    </wsdl:message>
    <wsdl:message name="GetMGSoapOut">
        <wsdl:part name="parameters" element="tns:GetMGResponse" />
    </wsdl:message>
    
    <wsdl:portType name="MessageWSSoap">
        <wsdl:operation name="GetMG">
            <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">messgae messag .
            </wsdl:documentation>
            <wsdl:input message="tns:GetMGSoapIn" />
            <wsdl:output message="tns:GetMGSoapOut" />
        </wsdl:operation>
        
    </wsdl:portType>
    <wsdl:binding name="MessageWSSoap" type="tns:MessageWSSoap">
        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
        <wsdl:operation name="GetMG">
            <soap:operation soapAction="http://www.xxxx-xxx.com/GetMG"
                style="document" />
            <wsdl:input>
                <soap:body use="literal" />
            </wsdl:input>
            <wsdl:output>
                <soap:body use="literal" />
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:binding name="MessageWSSoap12" type="tns:MessageWSSoap">
        <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
        <wsdl:operation name="GetMG">
            <soap12:operation soapAction="http://www.xxxx-xxx.com/GetMG"
                style="document" />
            <wsdl:input>
                <soap12:body use="literal" />
            </wsdl:input>
            <wsdl:output>
                <soap12:body use="literal" />
            </wsdl:output>
        </wsdl:operation>

    </wsdl:binding>
    <wsdl:service name="MessageWS">
        <wsdl:port name="MessageWSSoap" binding="tns:MessageWSSoap">
            <soap:address location="http://xxxxxxxx/xxxx/acsws.asmx" />
        </wsdl:port>
        <wsdl:port name="ACSWSSoap12" binding="tns:ACSWSSoap12">
            <soap12:address location="http://xxxxxxxx/xxxx/acsws.asmx" />
        </wsdl:port>
    </wsdl:service>
</wsdl:deFinitions>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?