1 Reply Latest reply on May 23, 2012 4:10 PM by Kelly Dolan

    How do I upgrade web service using WSDL with multiple schema namespaces?

    Kelly Dolan Newbie

      Hi!  I need some help upgrading a web service.  I'm getting a specific error, found work arounds cited on various sites but am still not working because I must be mis-interpreting something.

       

      I inherited code that runs w/in JBoss 4.0.1sp1 and I need to port it to JBoss 7.  My current issue is with a specific web service.  What I have is:

       

      * MyApp.jar that contains a set of classes

      -- com.myapp.ws.MyPort.java (extends Remote)

      -- com.myapp.ws.MyServiceImpl.java (implements SessionBean, MyPort)

      -- com.myapp.ws.types.<various POJOS>.java (represents input and output types)

      -- com.myapp.ws.operations.<various POJOS>.java (represents operations, request and response objects)

      -- com.myapp.ws.faults.<various POJOS>.java (represents exceptions)

      * webservices.xml

      * jaxrpc-mapping.xml

      * MyService.wsdl

       

      From what I gather, the above is a J2EE 1.4 web service (based on Axis) implemented as an EJB service endpoint.  I do not know how any of the above was generated (e.g., wstools, manually).  There is nothing in a build files...these files must have been generated once and checked into the source code repository.

       

      The key thing to note is in MyService.wsdl, multiple schemas are defined each assigned to a different namespace.  Then in the jaxrpc-mapping.xml file, each namespace is mapped to a different package.

       

      {code:xml}<types>

          <schema targetNamespace="http://my.company.com/types"

                  xmlns="http://www.w3.org/2001/XMLSchema"

                  elementFormDefault="qualified">

          ...

          </schema>

          <schema targetNamespace="http://my.company.com/operations"

                  xmlns="http://www.w3.org/2001/XMLSchema"

                  elementFormDefault="qualified">

          </schema>

          ...{code}

       

      {code:xml}<package-mapping>

          <package-type>com.myapp.ws.types</package-type>

          <namespaceURI>http://my.company.com/types</namespaceURI>

        </package-mapping>

        <package-mapping>

          <package-type>com.myapp.ws.operations</package-type>

          <namespaceURI>http://my.company.com/operations</namespaceURI>

        </package-mapping>

        ...{code}

       

      The general error I'm seeing is...

       

      13:58:46,726 ERROR [org.jboss.ws.metadata.wsdl.xmlschema.JBossXSErrorHandler] (MSC service thread 1-2) JBossWS_xxx_faults7626102231361680514.xsd[domain:http://www.w3.org/TR/xml-schema-1]::[key=src-resolve.4.2]::Message=src-resolve.4.2: Error resolving component 'types:tMyType'. It was detected that 'types:tMyType' is in namespace 'http://my.company.com/types', but components from this namespace are not referenceable from schema document 'file:/C:/jboss-as-7.1.1/standalone/tmp/jbossws/JBossWS_xxx_faults7626102231361680514.xsd'. If this is the incorrect namespace, perhaps the prefix of 'types:tMyType' needs to be changed. If this is the correct namespace, then an appropriate 'import' tag should be added to 'file:/C:/jboss-as-7.1.1/standalone/tmp/jbossws/JBossWS_xxx_faults7626102231361680514.xsd'.

       

      I've searched and searched and pretty much found that JBOSSWS (JAX-WS and tools) does not like multiple schemas/namespaces in the same WSDL.  When the individual XSD files get generated the proper imports are not generated.  Two different work arounds have been suggested.

       

      1. Consolidate everything into one package/namespace.  This would appear to be the easiest.  However, in my case one of the namespaces is mapped to a standard Java package (java.util)...to support using Map as an input/output parameter.

       

      2. Split the WSDLs. (http://metro.1045641.n5.nabble.com/Trouble-compiling-WSDL-with-multiple-schema-namespaces-td1066949.html)

       

      It's option #2 that I'm stuck on and baffled at.  The URL referenced speaks to splitting the WSDL and then running wscompile.  As far as I can tell, I'm not trying to run wscompile because I technically already have my artifacts.  I tried splitting the WSDL by simply breaking it down into separate files (e.g., top-level WSDL imports other WSDL snippets).  This did not work and I can generally see why...it results in one WSDL file parsed. 

       

      What I can't wrap my head around is...I have one service endpoint interface, URL, etc. to access my web service.  This is defined in webservices.xml which points to one WSDL file and one jaxrpc-mapping.xml.  The one WSDL file defines the service URL.  If I should be able to split the WSDLs, what exactly does this mean?  How does it impact those other files?  And while there are multiple namespaces/schemas/packages, there are dependencies across them.  For example, the operations package is dependent on the types package.

       

      Very confused....any and all help is greatly appreciated.

      Kelly

       

       

        • 1. Re: How do I upgrade web service using WSDL with multiple schema namespaces?
          Kelly Dolan Newbie

          Ok, I found some help elsewhere, got something to work so I'm posting my solution for anyone else who might run into the same issue and confusion.

           

          My solution was not to split the WSDL but to split THE SCHEMA defined in the WSDL.  So instead of having...

           

          <definitions targetNamespace="http://my.company.com" ...>

          <types>

              <schema targetNamespace="http://my.company.com/types"

                      xmlns="http://www.w3.org/2001/XMLSchema"

                      elementFormDefault="qualified">

              ...

              // define some simple and complex types in here

              ...

              </schema>

              <schema targetNamespace="http://my.company.com/operations"

                      xmlns="http://www.w3.org/2001/XMLSchema"

                      elementFormDefault="qualified">

              ...

              // define some simple and complex types in here

              ...

              </schema>

          </types>

          ...

           

           

          ...I now have...

           

           

          // my wsdl file

          <definitions targetNamespace="http://my.company.com" ...>

          <types>

              <schema targetNamespace="http://my.company.com"

                      xmlns="http://www.w3.org/2001/XMLSchema"

                      elementFormDefault="qualified">

                  <import namespace="http://my.company.com/types" schemaLocation="types.xsd">

                  <import namespace="http://my.company.com/operations" schemaLocation="operations.xsd">

              </schema>

          </types>

          ...

           

           

          // operations.xsd (whose types are dependent on types.xsd)

          <schema targetNamespace="http://my.company.com/operations"

                  xmlns="http://www.w3.org/2001/XMLSchema"

                  xmlns:operations="http://my.company.com/operations"

                  xmlns:types="http://my.company.com/types"

                  elementFormDefault="qualified">

           

            <import namespace="http://my.company.com/types" schemaLocation="types.xsd"/>

           

            // define some simple and complex types in here           

               

          </schema>

           

           

          Steps for creating the XSD files:

          1. For each schema in the WSDL, create an XSD file

          2. The root <schema> element target namespace is the unique namespace for the simple/complex types it defines

          3. Copied <schema> children as-is from WSDL to XSD file

          4. If the new XSD file referenced one of the other namespaces, add a namespace declaration in <schema> for it and added an <import>

          5. For each <import>, the namespace is the unique namespace for the simple/complex types the imported file defines

           

          Steps for modifying the WSDL file:

          1. Remove all but one <schema> element

          2. Change the <schema> target namespace to the same target namespace for <definitions>

          3. Add an <import> for each XSD file (i.e., original <schema> element)

          4. For each <import>, the namespace is the unique namespace for the simple/complex types the imported file defines

          1 of 1 people found this helpful