I used jaxb2-maven-plugin
to generate java classes from xsd. Classes are generating. Below is sample of one of my xsd file
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://customer.serviceoperations.lmsapi.message.webservice.lms.vu360.softech.com"
xmlns="http://customer.serviceoperations.lmsapi.message.webservice.lms.vu360.softech.com"
xmlns:cust="http://customer.types.lmsapi.message.webservice.lms.vu360.softech.com"
xmlns:tr="http://transactionresult.types.lmsapi.message.webservice.lms.vu360.softech.com"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xsd:import namespace="http://transactionresult.types.lmsapi.message.webservice.lms.vu360.softech.com" schemaLocation="../types/TransactionResultType.xsd"/>
<xsd:import namespace="http://customer.types.lmsapi.message.webservice.lms.vu360.softech.com" schemaLocation="../types/Customer.xsd"/>
<xsd:element name="AddCustomerRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Customers" type="cust:Customers" minOccurs="1" maxOccurs="1" nillable="false" />
</xsd:sequence>
<xsd:attribute name="key" type="xsd:string" use="required" />
<xsd:attribute name="ResellerId" type="xsd:nonNegativeInteger" use="required" />
</xsd:complexType>
</xsd:element>
<xsd:element name="AddCustomerResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="RegisterCustomers" type="cust:RegisterCustomers" minOccurs="0" maxOccurs="1" nillable="false" />
</xsd:sequence>
<xsd:attribute name="transactionResult" type="tr:TransactionResultType" use="required"/>
<xsd:attribute name="transactionResultMessage" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
</xsd:schema>
After generating classes from xsd. I am trying to set up a spring web service. Here is my web service configuration file for spring
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
...
http://www.springframework.org/schema/web-services/web-services-2.2.xsd ">
<context:component-scan base-package="pk.training.basitmahmood.webservice.endpoints.impl"/>
<bean id="LmsApi" class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition" lazy-init="true">
<property name="schemaCollection" ref="lmsApiSchema" />
<property name="portTypeName" value="LmsApiPortType"/>
<property name="serviceName" value="LmsApiServices" />
<property name="locationUri" value="/endpoints"/>
</bean>
<bean id="lmsApiSchema" class="org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection">
<property name="inline" value="true" />
<property name="xsds">
<list>
<value>schemas/lmsapi/serviceoperations/CustomerServiceOperations.xsd</value>
<value>schemas/lmsapi/serviceoperations/EnrollmentServiceOperations.xsd</value>
...
<value>schemas/lmsapi/types/Address.xsd</value>
...
<value>schemas/lmsapi/utility/OrgGroupUtility.xsd</value>
<value>schemas/lmsapi/utility/utility.xsd</value>
</list>
</property>
</bean>
</beans>
Now when I run my project I get the following error
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lmsApiSchema' defined in ServletContext resource [/WEB-INF/spring/appServlet/webservices-context.xml]: Invocation of init method failed; nested exception is org.springframework.xml.xsd.commons.CommonsXsdSchemaException: Schema [ServletContext resource [/schemas/lmsapi/serviceoperations/CustomerServiceOperations.xsd]] could not be loaded; nested exception is java.lang.IllegalArgumentException: The resource path [/../types/TransactionResultType.xsd] has been normalized to [null] which is not valid
....
Caused by: org.springframework.xml.xsd.commons.CommonsXsdSchemaException: Schema [ServletContext resource [/schemas/lmsapi/serviceoperations/CustomerServiceOperations.xsd]] could not be loaded; nested exception is java.lang.IllegalArgumentException: The resource path [/../types/TransactionResultType.xsd] has been normalized to [null] which is not valid
...
Caused by: java.lang.IllegalArgumentException: The resource path [/../types/TransactionResultType.xsd] has been normalized to [null] which is not valid
In my CustomerServiceOperations.xsd
I am using the following line
<xsd:import namespace="http://transactionresult.types.lmsapi.message.webservice.lms.vu360.softech.com" schemaLocation="../types/TransactionResultType.xsd"/>
Now schemaLocation="../types/TransactionResultType.xsd"
is creating problem. Although it is right because if I click on ../types/TransactionResultType.xsd
, it will open the right file. Now spring is appending /
before path like [/../types/TransactionResultType.xsd]
. How can i resolve this issue ?
Thanks