Announcement Announcement Module
No announcement yet.
Problem importing XSDs with different target namespaces. Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem importing XSDs with different target namespaces.

    I have a problem importing an XSD with common types into other XSDs. ("http" and "www" removed from links because it won't let me post with links in!)

    This seems to be because my common types XSD is in one namespace, and each of my service-specific XSDs are in other namespaces.

    My common types XSD begins with:

    <xs:schema xmlns:xs=""

    One of my service-specific XSDs begins with:

    <xs:schema xmlns:xs=""

    <xs:import namespace=""

    In my spring-ws-servlet.xml I have

    <bean id="someService" class=" sdl11Definition">
    <property name="schema" ref="someServiceSchema"/>
    <property name="portTypeName" value="SomeService"/>
    <property name="locationUri" value="/someService/"/>

    Where the schema property references a SimpleXsdSchema bean created from my specific XSD.

    The WSDL generates correctly in the sense that it looks correct. But when I try to call the service, whether from my Visual Studio web app or from a SoapUI test, it fails because it cannot find commonTypes.xsd in the namespace of "".

    I know that if I just used one namespace for everything then it would work, but as my specific services are grouped into sensible namespaces based on "system area" I would like to keep it that way.

    How do I import XSDs with different target namespaces?

  • #2

    Just to clarify, the actual error is when attempting to read the common types XSD

    "Failed to load url [<thisishttpslashslash>localhost:8888/myapp/someservice/commonTypes.xsd]"

    This looks like a similar issue to that discussed in

    <thisishttpslashslash> rt

    but I still haven't had any success.

    (And this "can't post links" business seems a bit "shoot yourself in the foot" considering this is a web services forum.)


    • #3
      Don't know if you like this solution.
      But you can use CommonsXsdSchemaCollection and inline the
      imported schemas.

      <bean id="someService" class="">
        <property name="schemaCollection" ref="schemaCollection"/>
        <property name="portTypeName" value="SomeService"/>
        <property name="locationUri" value="/someService/"/>
      <bean id="schemaCollection" class="org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection">
        <property name="xsds" value="/mySchemaWithImports.xsd"/>
        <property name="inline" value="true"/>


      • #4
        Thanks fgt.

        I did briefly try the schema collection idea yesterday evening. I didn't have the CommonsXsdSchemaCollection on my classpath, but did quickly throw together my own implemention of XsdSchemaCollection, which "seemed" to inline beautifully, but still failed with the same error.

        The CommonsXsdSchemaCollection worked perfectly, and I know see that the airline tutorial does this.

        However I did manage to get it working last night. The aforementioned thread mentioned that using the servlet urlpattern of


        means that any request for the commonTypes.xsd will end up going through that servlet.

        It also mentioned that the commonTypes.xsd would need to be at the web root.

        I used a urlpattern of


        and ensured that commonTypes.xsd existed at the the web root, but this still didn't work.

        I eventually realised that when my someService.xsd (wsdl) was trying to pick up the commonTypes.xsd it was looking in its own namespace of */myapp/someservice/commonTypes.xsd.

        I could get this working by importing with

        namespace="httpslashslashwwwdotblahdotcodotukslash common"


        Which meant the import was essentially pointing to the web root.

        However it is clearly wrong to have to do this.

        Anyway, CommonsXsdSchemaCollection works fine so thanks.