我试图用wsimport创建Web服务代理,但由于冲突我得到一个错误。 “两个声明导致ObjectFactory类发生冲突。”Java EE Web服务:命名冲突
我有两个EJB,Webservices部署在一个耳朵。两者都有一个具有相同名称和参数的方法。每个WS都有自己的目标名称空间。
WS的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);
}
WebService的一个:
@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的SEI B:
@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);
}
web服务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服务器时,第一个Webservices将导入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定义了它自己的messagetypes?或者我还能做些什么来创建WS代理? (我不想将它们分成不同的Java EE应用程序。)
克里斯,如果我的回答如下是有帮助的,它会如果您单击选中标记和“接受”它是正确的答案是凉爽。当你这样做的时候,我们都得到了Stackoverflow的声望点。 – twindham