使用 Websphere 和 JAXB 带注释的服务/实体生成 wsdl
我正在尝试生成一个 wsdl。该服务的构造如下所示。其实没什么不寻常的,但我确实有想要抛出的异常,它位于一个单独的包中,因此出现在与生成的 wsdl 中的服务和实体不同的命名空间中。检索 wsdl 文件(通过 http://service.example.com/?wsdl)会生成此文件下面的内容不会验证,因为同样,异常不在同一名称空间中。有没有办法生成一个 wsdl 进行验证,同时将异常放在单独的包中(请记住,我确实想在其他服务和其他命名空间中重用该异常)。
package com.example.exception;
XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace="http://exception.example.com")
public class ServiceException extends Exception {
public ServiceException() {
super();
}
.....
}
package com.example.service;
public interface DoSomethingService {
@ResponseWrapper(localName = "findResponseTag")
public Entity find( @WebParam(name="input") String input ) throws ServiceException;
.....
}
package com.example.service;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace = "http://entity.example.com")
public class Entity {
@XmlAttribute
private String name;
public Entity(){
}
.....
}
生成的wsdl:下面引用的ServiceException位于ns4中,而不是tns中。
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://service.example.com/"
xmlns:SOAP11="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:SOAP="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns4="http://exception.example.com/"
name="DoSomethingServiceService" targetNamespace="http://service.example.com/">
<wsdl:types>
<xs:schema xmlns:ns1="http://service.ancillary.model.vsp.com"
xmlns:tns="http://exception.example.com/" xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://exception.example.com/" version="1.0">
<xs:import namespace="http://exception.example.com" />
<xs:element name="ServiceException" type="tns:ServiceException" />
<xs:complexType name="ServiceException">
.....
</xs:complexType>
</xs:schema>
..........
<wsdl:portType name="DoSomethingService">
<wsdl:operation name="find">
<wsdl:input message="tns:find"></wsdl:input>
<wsdl:output message="tns:findResponse"></wsdl:output>
<wsdl:fault name="ServiceException" message="ns4:ServiceException"></wsdl:fault>
</wsdl:operation>
</wsdl:portType>
</wsdl:types>
.....
</wsdl:definitions>
I'm trying to generate a wsdl. The service is constructed as shown below. Nothing unusual really, but I do have the Exception I want to throw, located in a separate package, thus appearing in a different namespace than the service and the entity in the generated wsdl. Retrieving the wsdl file (by http://service.example.com/?wsdl) produces this file below that does not validate, since, again, the Exception isn't in the same namespace. Is there a way to generate a wsdl that validates while at the same time having the Exception in a separate package (keep in mind that I do want to reuse the exception in other services, in other namespaces also).
package com.example.exception;
XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace="http://exception.example.com")
public class ServiceException extends Exception {
public ServiceException() {
super();
}
.....
}
package com.example.service;
public interface DoSomethingService {
@ResponseWrapper(localName = "findResponseTag")
public Entity find( @WebParam(name="input") String input ) throws ServiceException;
.....
}
package com.example.service;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace = "http://entity.example.com")
public class Entity {
@XmlAttribute
private String name;
public Entity(){
}
.....
}
The generated wsdl: The ServiceException referenced below is in ns4 and not tns.
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://service.example.com/"
xmlns:SOAP11="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:SOAP="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns4="http://exception.example.com/"
name="DoSomethingServiceService" targetNamespace="http://service.example.com/">
<wsdl:types>
<xs:schema xmlns:ns1="http://service.ancillary.model.vsp.com"
xmlns:tns="http://exception.example.com/" xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://exception.example.com/" version="1.0">
<xs:import namespace="http://exception.example.com" />
<xs:element name="ServiceException" type="tns:ServiceException" />
<xs:complexType name="ServiceException">
.....
</xs:complexType>
</xs:schema>
..........
<wsdl:portType name="DoSomethingService">
<wsdl:operation name="find">
<wsdl:input message="tns:find"></wsdl:input>
<wsdl:output message="tns:findResponse"></wsdl:output>
<wsdl:fault name="ServiceException" message="ns4:ServiceException"></wsdl:fault>
</wsdl:operation>
</wsdl:portType>
</wsdl:types>
.....
</wsdl:definitions>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论