我使用 wsimport 和给定的第 3 方 WSDL(我无法更改)生成 Java 代码。WSDL 使用 Java 关键字('return'),因此 wsimport 不会生成 JAVA 代码。
为了能够向您展示一个示例,我将名称“return”全局替换为“retParam”。
这是从 WSDL 获取特定消息的生成的 java 代码:
/**
*
* @param retParam
* @param header0
* @param parameters
* @param header
*/
@WebMethod(operationName = "CreatePermissionRequest", action = "http://www.url.be/WSUpdate/v1/CreatePermissionRequest")
public void createPermissionRequest(
@WebParam(name = "CreatePermissionRequestRequest", targetNamespace = "http://www.url2.be/WSUpdate/messages/v1_00", partName = "parameters")
CreatePermissionRequestRequest parameters,
@WebParam(name = "SyncHeader", targetNamespace = "http://www.url.be/v1_00", header = true, partName = "header")
SyncHeader header,
@WebParam(name = "CreatePermissionRequestReply", targetNamespace = "http://www.url2.be/WSUpdate/messages/v1_00", mode = WebParam.Mode.OUT, partName = "retParam")
Holder<CreatePermissionRequestReply> retParam,
@WebParam(name = "SyncResponseHeader", targetNamespace = "http://www.url.be/v1_00", header = true, mode = WebParam.Mode.OUT, partName = "header")
Holder<SyncResponseHeader> header0);
这是 WSDL 中的条目:
<message name="CreatePermissionRequestReply">
<part name="retParam" element="messages:CreatePermissionRequestReply" />
<part name="header" element="fsb:SyncResponseHeader" />
</message>
如您所见,部件名称称为“retParam”,它被转换为 createPermissionRequest - 接口的属性。当我使用 wsimport 生成 Java 代码时,我需要指定哪个自定义绑定,以便将部件名称“retParam”映射到其他东西?
目前我正在使用这个绑定文件,但它不起作用:(:
<?xml version="1.0" encoding="UTF-8"?>
<jaxws:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:jaxws="http://java.sun.com/xml/ns/jaxws" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" version="2.0" wsdlLocation="WSUpdateTAP.wsdl">
<jaxws:bindings node="wsdl:definitions/wsdl:portType[@name='WSUpdate']/wsdl:operation[@name='CreatePermissionRequest']">
<jaxb:parameter part="definitions/message[@name='CreatePermissionRequestReply']/
part[@name='retParam']" element="retParam"
name="ret"/>
</jaxws:bindings>
</jaxws:bindings>
这是一个完整的 WSDL(不是上面提到的更新服务,但对于状态服务,它是一个较小的 WSDL,但有同样的问题:使用 return 关键字):
<types>
<xs:schema
targetNamespace="http://www.url2.be/WSStatus/messages/v1_00"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:import namespace="http://www.url1.be/v1_00"
schemaLocation="fsb/fsb.xsd" />
<xs:include schemaLocation="WSStatus/wsstatus_messages.xsd" />
</xs:schema>
</types>
<message name="checkAvailabilityRequestMessage">
<part name="parameters" element="messages:checkAvailability" />
<part name="header" element="fsb:SyncHeader" />
</message>
<message name="checkAvailabilityResponseMessage">
<part name="return" element="messages:checkAvailabilityReturn" />
<part name="header" element="fsb:SyncResponseHeader" />
</message>
<portType name="WSStatus">
<operation name="checkAvailability">
<input message="tns:checkAvailabilityRequestMessage"></input>
<output message="tns:checkAvailabilityResponseMessage"></output>
</operation>
</portType>
<binding name="WSStatusSOAPBinding" type="tns:WSStatus">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />
<operation name="checkAvailability">
<soap:operation style="document"
soapAction="http://www.url1.be/WSStatus/v1/checkAvailability" />
<input>
<soap:body use="literal" parts="parameters" />
<soap:header use="literal" part="header"
message="tns:checkAvailabilityRequestMessage" />
</input>
<output>
<soap:body use="literal" parts="return" />
<soap:header use="literal" part="header"
message="tns:checkAvailabilityResponseMessage">
</soap:header>
</output>
</operation>
</binding>
<service name="WSStatusService">
<port name="WSStatusSOAP" binding="tns:WSStatusSOAPBinding">
<soap:address location="https://www.url2.be/fsb/WSStatus" />
</port>
</service>
</definitions>
有什么想法有什么问题吗?