我正在尝试使用 wsimport 创建 Web 服务代理,但由于冲突而出现错误。“两个声明导致 ObjectFactory 类发生冲突。”
我在一只耳朵中部署了两个带有 Web 服务的 EJB。两者都有一个具有相同名称和参数的方法。每个 WS 都有自己的目标命名空间。
WS A 的 SEI:
@Local
@SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
@WebService(name = "AService", targetNamespace = "http://example.com/bla/a")
public interface ASEI {
@WebMethod
@WebResult(name = "erpId")
public Long getId(@WebParam(name = "gid")
Long gid);
}
网络服务 A:
@Stateless
@WebService(serviceName = "AWebService",
endpointInterface = "foo.endpointinterfaces.ASEI",
targetNamespace = "http://example.com/bla/a")
@BindingType(SOAPBinding.SOAP12HTTP_BINDING)
public class AWebService implements ASEI {
public Long getId(Long gid) { ... }
}
WS B的SEI:
@Local
@SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
@WebService(name = "BService", targetNamespace = "http://example.com/bla/b")
public interface BSEI {
@WebMethod
@WebResult(name = "erpId")
public Long getId(@WebParam(name = "gid")
Long gid);
}
网络服务 B:
@Stateless
@WebService(serviceName = "BWebService",
endpointInterface = "foo.endpointinterfaces.ASEI",
targetNamespace = "http://example.com/bla/b")
@BindingType(SOAPBinding.SOAP12HTTP_BINDING)
public class BWebService implements BSEI {
public Long getId(Long gid) { ... }
}
当我将应用程序部署到我的 Weblogic 服务器时,第一个 Web 服务会导入 WS B 的 xml 声明并将它们用于消息类型。
A的WSDL:
<definitions targetNamespace="http://example.com/bla/a" name="AWebService" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:tns="http://example.com/bla/a" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/">
<types>
<xsd:schema>
<xsd:import namespace="http://example.com/bla/b" schemaLocation="http://192.168.178.105:7001/BWebService/AWebService?xsd=1"/>
</xsd:schema>
<xsd:schema>
<xsd:import namespace="http://example.com/bla/a" schemaLocation="http://192.168.178.105:7001/AWebService/AWebService?xsd=2"/>
</xsd:schema>
</types>
<message name="getId">
<part name="parameters" element="tns:getId"/>
</message>
...
XSD=1:
<xs:schema version="1.0" targetNamespace="http://example.com/bla/b" xmlns:tns="http://example.com/bla/b" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="getId" type="tns:getId"/>
<xs:complexType name="getId"> ... </xs:complexType>
...
XSD=2:
<xs:schema version="1.0" targetNamespace="http://example.com/bla/a" xmlns:tns="http://example.com/bla/a" xmlns:ns1="http://example.com/bla/b" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import namespace="http://example.com/bla/b" schemaLocation="http://192.168.178.105:7001/AWebService/AWebService?xsd=1"/>
<xs:element name="getId" nillable="true" type="ns1:getId"/>
...
有没有办法让每个 WS 定义它自己的消息类型?或者我还能做什么来创建 WS 代理?(我不想将它们分成不同的 Java EE 应用程序。)