1

The application uses spring ws to build a SOAP webservice. The XSD of the payload includes another XSD schema file that includes a reusable component (header, etc...) across multiple schema files.

I am able to successfully generate the corresponding Java objects using JAXB.

The dispatcher servlet is below:

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:sws="http://www.springframework.org/schema/web-services"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="
            http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
            http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services-2.0.xsd">

    <import resource="service-context.xml" />

    <sws:annotation-driven />

    <context:component-scan
        base-package="com.test.service" />

    <!-- SOAP Fault Annotation Exception Resolver -->
    <bean
        class="org.springframework.ws.soap.server.endpoint.SoapFaultAnnotationExceptionResolver" /> 

    <!-- ############## WSDL Definitions ################## -->

    <sws:dynamic-wsdl id="sampleEndpoint"
        portTypeName="sampleEndpoint" locationUri="/sampleEndpoint/">
        <sws:xsd location="/WEB-INF/xsd/samplePayload.xsd" />
    </sws:dynamic-wsdl>

</beans>

A snippet of the main *.xsd file that includes a second schema:

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
    elementFormDefault="qualified" attributeFormDefault="qualified"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:abc="www.example.com">
    <xsd:include schemaLocation="common.xsd"></xsd:include>

      <element name="SampleRequest">    
        <complexType>
            <sequence>
                <element name="MsgRqHdr">
                    <complexType>
                        <sequence>
                            <element name="UID" type="string" minOccurs="1"
                                maxOccurs="1" />
                        </sequence>
                    </complexType>
                </element>
                .........

The application is deployed to an Apache Tomcat v9 server. The wsdl is tested on a browser to be successful; I can spot all the operations provided in this wsdl, and the included *.xsd schema file is visible as well:

<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:sch="www.example.com" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="www.example.com" targetNamespace="www.example.com">
<wsdl:types>
<xsd:schema xmlns="www.example.com" xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="www.example.com">
**<xsd:include schemaLocation="common.xsd"/>**
<xsd:element name="SampleRq" type="SampleRq_Type"/>
<xsd:element name="SampleRs" type="SampleRs_Type"/>
<xsd:annotation>
<xsd:documentation source="DES">
..........

Now to test with SoapUI. The project creation fails with the comment:

Error loading [http://localhost:8080/sample/common.xsd]: org.apache.xmlbeans.XmlException: org.apache.xmlbeans.XmlException: error: Unexpected end of file after nul

I refer to the following issues raised previously:

1- xsd:include exception in soapUI:org.apache.xmlbeans.XmlException: org.apache.xmlbeans.XmlException: error: Unexpected end of file after null

2- soapUI - issue with wsdl that includes xsd

Which indicates that the WSDL fails to find this schema file for some reason. I have searched StackOverflow for similar issues which almost exactly describes my case but there is no definitive answer. At most, the issue has been diagnosed with no additional information on how to properly fix it.

If I try to open the *.xsd file in another browser tab I fail to open it, it cannot be found. So the issue is in defining a correct path to the document which I have no idea how to do it.

Question is, How to properly define and/or include *.xsd schema files inside on another so that it can be identified correctly?

Thank you in advance,

Moe
  • 63
  • 2
  • 14

1 Answers1

0

I'm also using an included . xsd from another, but i'm using the import tag instead. My main .xsd looks like this

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://My_WS_01_00_00.Local"
    xmlns:tns="http://My_WS_01_00_00.Local"
    xmlns:ts="http://jaxb2-commons.dev.java.net/basic/toString"
    elementFormDefault="qualified" xmlns:pref="http://Types_WS_01_00_00">


<import schemaLocation="../../1.0.0/My_WS_Types.xsd" namespace="http://Types_WS_01_00_00"></import>

<element name="LoginRequest">
    <complexType>
        <sequence>              
            <element name="username" type="string" />
            <element name="password" type="string" />
        </sequence>
    </complexType>
</element>
<element name="LoginResponse">
    <complexType>
        <sequence> 
            <element name="answer" type="int" />
            <element name="operator" type="pref:WS_Operator" /> 
        </sequence>
    </complexType>
</element>

And my included .xsd is like this:

<schema xmlns="http://www.w3.org/2001/XMLSchema" 
        targetNamespace="http://Types_WS_01_00_00" 
        xmlns:tns="http://Types_WS_01_00_00" 
        elementFormDefault="qualified">

<complexType name="WS_Operator">
    <sequence>
        <element name="id" type="long" />
        <element name="username" type="string" />
        <element name="name" type="string" />
        <element name="surname" type="string" />
        <element name="language" type="long" />
    </sequence>
</complexType>

Hope it helps you,