java - 外部 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", targetNamespace = "http://www.xxxx-xxx.com/", 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>
解决方案
推荐阅读
- windows - 终端进程启动失败:shell 可执行文件 ""..\vs-kubernetes\tools\kubectl\kubectl.exe".exe" 的路径不存在
- mysql - MySQL查询一列中具有相同值而另一列中具有不同值的行
- php - 一个将我的 laravel 8 应用程序部署到我遇到的 Heroku 请提供有效的缓存路径
- r - R:将 grob 对象转换为 ggplot/plotly
- spring - Maven 在调用 mvn install 时只运行集成测试
- flutter - 如何通过 Flutter 在 Google Fit 上注册跑步
- css - 不支持 MIME 类型
- javascript - 重复的每日倒计时
- c# - 如何使用 Linq 包含列表
在 selectTableDto 中? - webrtc - 在WebRTC中,当一个用户需要TURN而另一个用户不需要时,他们之间的流量会全部通过TURN服务器吗?