I have one module where I have my XSD schemas, where one schema can reference an other using relative path within schema location:
<xs:import namespace="http://my.namespace.org" schemaLocation="../mypackage/my.xsd"/>
Here I'm also using xjc to generate Jaxb beans from these xsd schemas.
Now I have a module where is my web-service is implemetented, using spring-ws (2.0.4). And I want to use static WSDL and publish it with the xsd schemas, where the schema locations will be transformed to URL like 'http://myerver.url.com/my.xsd'.
The question is how to elegantly achieve this?
(Alternatively combine the XSDs into one schema and that to WSDL)
(In theory I could transform these XSD using a script and add them to resources (xsd and wsdl) to a (spring dispatcher) servlet but it doesn't seems to me very comfortable)
Spring web service has a way to do it elegantly actually.
All you need to do is to define a SimpleXsdSchema
bean with the right id (which will be used as the xsd name without .xsd) in the bean definition xml file, something like below
<bean id="my"
class="org.springframework.xml.xsd.SimpleXsdSchema">
<property
name="xsd"
value="/mypackage/my.xsd">
</property>
</bean>
More information (including an example) can be found at the following link: Static WSDL with imported XML Schema in Spring Web Service
Here is my solution for static WSDL and XSDs
@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"));
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With