我创建了一组3个Java JAX-WS Web服务,每个Web服务都生成自己的WSDL文件,但它们都包含在同一个项目& Web应用程序中。Webservice命名空间共享
它们共享许多相同的请求/响应对象。例如,所有请求&响应对象都从BaseRequest和BaseResponse类继承。
当我使用C#.NET创建一个客户端时,它创建了多个BaseRequest和BaseResponse类,每个WSDL文件一个,但我真正喜欢它的只是创建一组共享的BaseRequest和BaseResponse类。
看来,如果我使所有单独的Web服务共享相同的目标名称空间,我就可以完成此操作。我的问题是,这是否可以接受&(在多个生成不同WSDL文件的Web服务中共享相同的名称空间)?
下面是一些例子Java代码,这样你就可以排序得到的我的web服务如何看待的想法:
@WebService(name = "BasicServicePortType", targetNamespace = "http://com.vectren.ws.basic.impl")
public interface BasicService
{
@ResponseWrapper(localName = "LogInResponseWrapper")
public LogInResponse logIn(@WebParam(name="request")LogInRequest request);
@ResponseWrapper(localName = "LogOutResponseWrapper")
public LogOutResponse logOut(@WebParam(name="request")LogOutRequest request);
}
@WebService(name = "ContentServicePortType", targetNamespace = "http://com.vectren.ws.content.impl")
public interface ContentService
{
@ResponseWrapper(localName = "GetContentResponseWrapper")
public GetContentResponse getContentList(@WebParam(name="request")GetContentRequest request);
}
@WebService(name = "OutageServicePortType", targetNamespace = "http://com.vectren.ws.outage.impl")
public interface OutageService
{
@ResponseWrapper(localName = "GetOutageNumbersResponseWrapper")
public GetOutageNumbersResponse getOutageNumbers(@WebParam(name="request")GetOutageNumbersRequest request);
@ResponseWrapper(localName = "GetOutageableAccountsByAccountNumbersResponseWrapper")
public GetOutageableAccountsResponse getOutageableAccountsByAccountNumbers(@WebParam(name="request")GetOutageableAccountsByAccountNumbersRequest request);
}
注:在每一种情况下,请求/响应对象都来自同一个继承“ BaseRequest“/”BaseResponse“类。例如,LogInRequest,LogOutRequest,GetContentRequest,GetOutageNumbersRequest,& GetOutageableAccountsByAccountNumbersRequest 都从BaseRequest继承。响应对象的想法相同。