问题说明
-
在使用idea的Tools>WebServices>Generate Wsdl From Java Code…生成WebService客户端时发生了
[ERROR] 无法生成 SEI, 类已存在。请使用 JAX-WS 定制设置重命名 wsdl:portType
-
然后我就使用命令行的方式生成WebService客户端,报错信息一致
wsimport -keep -verbose -encoding utf-8 -s . http://127.0.0.1:8088/services/woIssueReceiveService?wsdl -p com.superlighting.imes.webclient.common.wms.item.receive -B-XautoNameResolution
-
我的WSDL文件如下
<?xml version='1.0' encoding='UTF-8'?><wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://wms.hzero.org" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" name="woIssueReceiveService" targetNamespace="http://test.com.org">
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://wms.hzero.org" elementFormDefault="unqualified" targetNamespace="http://wms.hzero.org" version="1.0">
<xs:element name="woIssueReceiveResponseDTO" type="tns:data"/>
<xs:element name="woIssueReceiveService" type="tns:woIssueReceiveService"/>
<xs:element name="woIssueReceiveServiceResponse" type="tns:woIssueReceiveServiceResponse"/>
<xs:complexType name="woIssueReceiveService">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="WOIssueReceiveDTO" type="tns:woIssueReceiveDTO"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="woIssueReceiveDTO">
<xs:sequence>
<xs:element minOccurs="0" name="containerCode" type="xs:string"/>
<xs:element minOccurs="0" name="personId" type="xs:string"/>
<xs:element minOccurs="0" name="prodLineCode" type="xs:string"/>
<xs:element minOccurs="0" name="siteCode" type="xs:string"/>
<xs:element maxOccurs="unbounded" minOccurs="0" name="woIssueReceiveLineDTOList" nillable="true" type="tns:woIssueReceiveLineDTO"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="woIssueReceiveLineDTO">
<xs:sequence>
<xs:element minOccurs="0" name="acceptationIdetification" type="xs:string"/>
<xs:element minOccurs="0" name="instructionDocNum" type="xs:string"/>
<xs:element minOccurs="0" name="materialLotCode" type="xs:string"/>
<xs:element minOccurs="0" name="taskHeadNum" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="woIssueReceiveServiceResponse">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="WOIssueReceiveResponseDTO" type="tns:data"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="data">
<xs:sequence>
<xs:element minOccurs="0" name="code" type="xs:string"/>
<xs:element minOccurs="0" name="message" type="xs:string"/>
<xs:element minOccurs="0" name="status" type="xs:boolean"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
<wsdl:message name="woIssueReceiveService">
<wsdl:part element="tns:woIssueReceiveService" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="woIssueReceiveServiceResponse">
<wsdl:part element="tns:woIssueReceiveServiceResponse" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="WOIssueReceiveService">
<wsdl:operation name="woIssueReceiveService">
<wsdl:input message="tns:woIssueReceiveService" name="woIssueReceiveService">
</wsdl:input>
<wsdl:output message="tns:woIssueReceiveServiceResponse" name="woIssueReceiveServiceResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="woIssueReceiveServiceSoapBinding" type="tns:WOIssueReceiveService">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="woIssueReceiveService">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="woIssueReceiveService">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="woIssueReceiveServiceResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="woIssueReceiveService">
<wsdl:port binding="tns:woIssueReceiveServiceSoapBinding" name="WOIssueReceiveServiceImpPort">
<soap:address location="http://127.0.0.1:8088/services/woIssueReceiveService"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
解决方法
- 创建v2.xml文件
<bindings
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
wsdlLocation="http://1127.0.0.1:8088/services/woIssueReceiveService?wsdl"
xmlns="http://java.sun.com/xml/ns/jaxws">
<package name="com.superlighting.imes.webclient.common.wms.item.receive"/>
<!-- default settings -->
<enableWrapperStyle>true</enableWrapperStyle>
<enableAsyncMapping>false</enableAsyncMapping>
<!-- wsdl:portType customization -->
<bindings node="wsdl:definitions/wsdl:portType[@name='WOIssueReceiveService']">
<!-- change the generated SEI class -->
<class name="woIssueReceiveServiceV2"/>
<!-- you can also override the following customization settings -->
<enableWrapperStyle>true</enableWrapperStyle>
<enableAsyncMapping>false</enableAsyncMapping>
</bindings>
</bindings>
- 添加-b 命令添加指定 jaxws/jaxb 绑定文件或附加模式 (每个
都必须具有自己的 -b)
wsimport -keep -verbose -encoding utf-8 -s . http://127.0.0.1:8088/services/woIssueReceiveService?wsdl -p com.superlighting.imes.webclient.common.wms.item.receive -b D:\first\wsimport\bind\v2.xml -B-XautoNameResolution
- 生成成功
参考: