csv*_*iri 6 java spring xsd wsdl spring-ws
我有一个模块,我有我的XSD架构,其中一个架构可以使用架构位置中的相对路径引用另一个架构:
<xs:import namespace="http://my.namespace.org" schemaLocation="../mypackage/my.xsd"/>
Run Code Online (Sandbox Code Playgroud)
在这里,我还使用xjc从这些xsd模式生成Jaxb bean.
现在我有一个模块,我的web服务是使用spring-ws(2.0.4)实现的.我想使用静态WSDL并使用xsd模式发布它,其中模式位置将转换为URL,如"http://myerver.url.com/my.xsd".
问题是如何优雅地实现这一目标?
(或者将XSD合并到一个模式中,然后合并到WSDL中)
(理论上我可以使用脚本转换这些XSD并将它们添加到资源(xsd和wsdl)到(spring dispatcher)servlet,但在我看来它并不舒服)
Rob*_*bin 11
Spring Web服务实际上可以优雅地实现它.您需要做的就是SimpleXsdSchema在bean定义xml文件中定义一个具有正确id 的bean(将在没有.xsd的情况下用作xsd名称),如下所示
<bean id="my"
class="org.springframework.xml.xsd.SimpleXsdSchema">
<property
name="xsd"
value="/mypackage/my.xsd">
</property>
</bean>
Run Code Online (Sandbox Code Playgroud)
可以在以下链接中找到更多信息(包括示例): Spring Web Service中导入的XML Schema的静态WSDL
这是我针对静态 WSDL 和 XSD 的解决方案
@Bean(name = "OpportunityAttachmentService")
public Wsdl11Definition getOpportunityAttachmentServiceDefinition() {
SimpleWsdl11Definition wsdl11Definition =
new SimpleWsdl11Definition();
wsdl11Definition.setWsdl(
new ClassPathResource(
"wsdl/getOpportunityAttachment/BeP_getOpportunityAttachment_cuContract.wsdl"));
return wsdl11Definition;
}
@Bean(name = "getOpportunityAttachment_Request_CRM")
public XsdSchema getOpportunityAttachmentServiceRequestXsd() {
return new SimpleXsdSchema(
new ClassPathResource("wsdl/getOpportunityAttachment/getOpportunityAttachment_Request_CRM.xsd"));
}
@Bean(name = "getOpportunityAttachment_Response_CRM")
public XsdSchema getOpportunityAttachmentServiceResponseXsd() {
return new SimpleXsdSchema(
new ClassPathResource("wsdl/getOpportunityAttachment/getOpportunityAttachment_Response_CRM.xsd"));
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11703 次 |
| 最近记录: |