问题描述
我使用 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 (将#修改为@)