我試圖用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