Announcement Announcement Module
Collapse
No announcement yet.
Problem importing XSDs with different target namespaces. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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="w3.org/2001/XMLSchema"
    elementFormDefault="qualified"
    xmlns="blah.co.uk/common"
    targetNamespace="blah.co.uk/common">

    One of my service-specific XSDs begins with:

    <xs:schema xmlns:xs="w3.org/2001/XMLSchema"
    elementFormDefault="qualified"
    xmlns:cs="blah.co.uk/someservice"
    xmlns:ws="blah.co.uk/common"
    targetNamespace="blah.co.uk/someservice">

    <xs:import namespace="blah.co.uk/common"
    schemaLocation="commonTypes.xsd"/>

    In my spring-ws-servlet.xml I have

    <bean id="someService" class="org.springframework.ws.wsdl.wsdl11.DefaultW sdl11Definition">
    <property name="schema" ref="someServiceSchema"/>
    <property name="portTypeName" value="SomeService"/>
    <property name="locationUri" value="/someService/"/>
    </bean>

    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 "blah.co.uk/someservice".

    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
    Clarification

    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>forum.springframework.org/showthread.php?t=47825&highlight=followIncludeImpo 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.)

    Comment


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

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

      Comment


      • #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

        /services/*

        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"

        and
        schemaLocation="../../commonTypes.xsd"

        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.

        Comment

        Working...
        X