- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个具有相同操作名称和请求参数名称的 WSDL 文件。当我使用 WSDL 文件生成客户端 stub 时,端口类生成一个具有 void 返回类型的方法。此外,请求参数从单个对象更改为该单个对象的内容。
将 WSDL 文件上的操作名称更改为其他名称是可行的。但是,我认为修改 WSDL 文件是一个不好的做法。此外,我无法访问实际的网络服务。因此,我也无法更改 Web 服务上的实际操作名称。
有没有办法让wsimport
不会与操作名称和请求参数名称混淆?我尝试在 wsimport 中使用 -B-XautoNameResolution
属性,但它没有解决问题。
我的 WSDL 文件如下所示:(如您所见,操作名称和请求参数名称都使用名称“transact”)
<xsd:schema targetNamespace="http://com.example">
<xsd:element name="transact">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="from" type="xsd:string"></xsd:element>
<xsd:element name="to" type="xsd:string"></xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<wsdl:message name="requestdata">
<wsdl:part element="tns:transact" name="parameters"/>
</wsdl:message>
<wsdl:message name="responsedata">
<wsdl:part element="tns:responsedata" name="parameters"/>
</wsdl:message>
<wsdl:portType name="portname">
<wsdl:operation name="transact">
<wsdl:input message="tns:requestdata"/>
<wsdl:output message="tns:responsedata"/>
</wsdl:operation>
</wsdl:portType>
生成的类如下所示:(返回类型为 void,即使在 RequestWrapper
中声明了输入类型,transact 方法内声明的方法也不是对象本身。)
@WebMethod(action = "http://com.example/transact")
@RequestWrapper(localName = "transact", targetNamespace = "http://com.example", className = "com.example.Transact")
@ResponseWrapper(localName = "transactresponse", targetNamespace = "http://com.example", className = "com.example.TransactResponse")
public void transact(
@WebParam(name = "to", targetNamespace = "")
String to,
@WebParam(name = "from", targetNamespace = "")
String from);
最佳答案
该应用程序正在正常工作。您所做的是参数处理的包装样式。另一种风格是裸露风格(单部分争论导致1个java对象)
当输入消息的单个部分的元素名称与操作名称相同时,在将 SOAP 请求解码到 Java 时,它会生成多个参数,而不是 1 个封装的 Java 对象。这称为参数处理的“包装样式”。
<wsdl:part element="tns:transact" name="parameters"/>
<wsdl:operation name="transact">
WSDL 绑定(bind)类型仍然保留“文档样式”,因为我们使用单部分(XSD 中的复杂类型)
引用网址:
https://myarch.com/wrappernon-wrapper-web-service-styles-things-you-need-to-know/ http://www.ibm.com/developerworks/library/ws-usagewsdl/
解决方案是更改以下 2 个 XML 条目
<xsd:element name="transactNew">
<wsdl:part element="tns:transactNew" name="parameters"/>
将transact更改为transactNew将使其与OperationName(transact)不同,从而解决问题,因为操作名称和单个参数名称现在不同。
关于java - 具有相同操作名称和输入类型的 WSDL 会生成不正确的客户端 stub 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16603849/
我有一个像这样的结构: struct S { data: i32, fun: Box, } 并希望使用编码器序列化数据部分。为此,我使用 rustc_serialize 并推导出它的特
我在 tomcat 中使用基于表单的身份验证,实际上我使用的是 j_security_check。代码如下 Login to the Tomcat-Demo applic
我是一名优秀的程序员,十分优秀!