8 Replies Latest reply on Nov 23, 2005 6:23 AM by Thomas Diesler

    How to control generated SOAP request namespace

    Sebastien Roy Newbie


      I'm having a hard time with WS and really appriciate if someone will give me a clue on what's my problem.

      I have develop a WS and it's related client using the procedure described in chapter 12 of the documentation (using wsdl2java and wscompile based on a WSDL). After a couples of days, I was able to make my client and server works properly whit my JUnit tests. Using tcpmonitor, I can see my request and response working properly.

      But, when come time to intregrate with the "real" WS server (BEA WebLo) I fall into namespace problem. I spend days trying to modify my mapping.xml file to change the generated namespace. I want to know what does really control the generated SOAP request?

      Here is the SOAP request that I send to WebLo

       <ns3:CreateLoan xmlns:ns3="urn:BLC:/test/test">

      I just don't understand where does the ns3 come from. The generated code, the WSDL or the mapping.xml?

      Here is what the server is expected:

       <CreateLoan xmlns="urn:BLC:/test/test">
       <ns1:agent xmlns:ns1="urn:BLC:/test/schema/test">

      Any help would really be appreciated.

      I have notice that a bug exist (http://jira.jboss.com/jira/browse/JBWS-430) with the WSDL (elementFormDefault="qualified") argument, but I'm not sure if it is related to my problem.

      -Sebastien Roy

        • 1. Re: How to control generated SOAP request namespace
          Bogdan Solomon Newbie

          Not entirely, although it might be related to the qualified part.

          If you look at

          <ns1:agent xmlns:ns1="urn:BLC:/test/schema/test">

          All the elements have the urn:BLC:/test/schema/test namespace. However in your generated SOAP message that namespace does not exist. Can you post the relavant WSDL part for agent?

          • 2. Re: How to control generated SOAP request namespace
            Sebastien Roy Newbie

            Thanks for taking the time to look at my problem.

            BTW, I forgot the tell that I'm using JBoss 4.0.2

            The WSDL related to the WS a very big and use a lot of XSD (by import), and that's why I did not post the WSDL. But here is the sections that I think is relevant for my problem:

            <?xml version="1.0" encoding="UTF-8"?>
            <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
             <xs:complexType name="AgentType">
             <xs:element name="NO_COURTIER" type="ese:CharVar4Type"/>
             <xs:element name="NO_AGENT" type="ese:CharVar5Type"/>

            I know it's not a standard way use upper case variables, but it's a requirement...

            I dont understand which section of the WSDL is responsable of generated the namespace in the resulting SOAP.

            -Sebastien Roy

            • 3. Re: How to control generated SOAP request namespace
              Bogdan Solomon Newbie

              The ns1, ns2, etc namespaces are generated automatically by the Jboss Axis engine used for serialization. The mapping file should take care of the namespace mapping, however your WSDL declares the schema as unqualified. Because it is unqualified only the parent can have a namespace - CreateLoan in your case. But what you want is to have it qualified because agent should be in a different namespace.

              However JBoss's Axis engine has some issues with the qualified part(it always considers unqualified). This should have been solved in the Jboss 4.0.4 version(JBoss 4.0.x in the cvs I believe). If you ahve to use JBoss 4.0.2 you can have in WEB-INF a file named ws4ee-deployment.xml in which you can set up the mappings to include whatever namespaces you want.


              contains an interesting discussion about elementFormDefault.

              • 4. Re: How to control generated SOAP request namespace
                Sebastien Roy Newbie

                Againt thanks a lot.

                I now have a good idea of what is going wrong. A just have 2 more little question:

                1. Do you have an idea of when JBoss 4.0.4 will be shipped?

                2. If I choose the use the ws4ee-deployment.xml descriptor, how does I overide existing type mapping in this file? For what I understand from the documentation, this file will be merged with the runtime generated JBoss WSDD file. How do I specify in this XML description which namespace to use. Is there a specific attribute that I should use?

                Again, thank you, your help is really appreciated.


                -Sebastien Roy

                • 5. Re: How to control generated SOAP request namespace
                  Bogdan Solomon Newbie

                  1. If I read the JIRA right

                  JBoss 4.0.4 final should be released on 10/Dec/05.

                  2. Yes the ws4ee-deployment file gets merged with the WSDD file. basically if there is a mapping int both the WSDD and the ws4ee-deployment for the same element the ws4ee one will be written over the WSDD one.

                   qname='ns2:CustomerArray' xmlns:ns2='http://com.artisnet.nscp.om.endpoint/types'
                   <elementDesc fieldName='array' xmlName='array'/>
                   <element name='array'/>

                  is an example of a ws4ee entry. What you would need to change in it is the xmlName for elementDesc by adding the namespace before it's name. So something like ns1:array.

                  Note: I did not manage to use this for my needs(did not try extremely hard), after a lot of troubles I managed to compile the webservice module from JBoss 4.0 HEAD and replace it in 4.0.3(which broke some other web service apps due to library dependencies) but the namespace was fixed.

                  This should however work, you will just need to figure exactly how to "tinker" with the xmlName.

                  • 6. Re: How to control generated SOAP request namespace
                    Sebastien Roy Newbie

                    Again, thank you very much for the very good and clear explanation.

                    -Sebastien Roy

                    • 7. Re: How to control generated SOAP request namespace
                      Sebastien Roy Newbie


                      I spend an entire day trying to use the ws4ee-deployment.xml file to add my namespace in the SOAP request. When I take a look in the WSDD, I can see the new type-mapping (with the user defined comment). But, the request does not change at all. Is there something else to change?


                      • 8. Re: How to control generated SOAP request namespace
                        Thomas Diesler Master

                        When the request is generated by a client, that client sould also see the ws4ee-deployment.xml.

                        If you use an J2EE application-client deployment, it can be packaged in the client deployment.

                        If you don't use a preconfigured proxy from JNDI (e.g. with DII) there is a propriatary createService method in ServiceFactoryImpl.

                         * Create a <code>Service</code> instance.
                         * <p/>
                         * Note, this method is not in the {@link ServiceFactory} interface, it provides the service
                         * with additional ws4ee wsdl/java mapping information
                         * @param wsdlLocation URL for the WSDL document location
                         * @param mappingLocation An optional URL for the jaxrpc-mapping.xml location
                         * @param ws4eeMetaData An optional URL for the jboss propriatary deployment descriptor, see wiki for details.
                         * @param serviceName QName for the service.
                         * @param portName An optional port name
                         * @return Service.
                         * @throws ServiceException If any error in creation of the specified service
                         public Service createService(URL wsdlLocation, URL mappingLocation, URL ws4eeMetaData, QName serviceName, String portName) throws ServiceException