9 Replies Latest reply on Nov 17, 2005 9:20 AM by thomas.diesler

    Namespace problems invoking document/literal web service

    moebus

      Have created a hello world web service in .NET and want to call it from JBoss 4.0.2 on j2se1.4.2.

      I have encountered following problem:

      org.xml.sax.SAXException: Invalid element in (packagename).HelloWorldResponse - HelloWorldResult


      After looking around a bit in the code I found a place where I could fix this, it is in the class
      TypeMappingDescription.initMetaDataFromJavaXMLTypeMapping(),
      where the xmlName as written into the elementDesc tag, insert

      xmlName = qname.getPrefix() + ":" + xmlName;


      Have already looked through the CVS versions for this file and found that some weeks ago this change was put in and out of this class several times, and is now out in the release version.

      May be I need to have other axis or xml parser class changes since it seems that the sax parser reads this element (HelloWorldResult) with the implied namespace.


      The wsdl is as follows:
      <?xml version="1.0" encoding="utf-8"?>
      <wsdl:definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
       xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
       xmlns:s="http://www.w3.org/2001/XMLSchema"
       xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
       xmlns:tns="http://tempuri.org/"
       xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
       xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
       targetNamespace="http://tempuri.org/"
       xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
       <wsdl:types>
       <s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
       <s:element name="HelloWorld">
       <s:complexType>
       <s:sequence>
       <s:element minOccurs="0" maxOccurs="1" name="name" type="s:string" />
       </s:sequence>
       </s:complexType>
       </s:element>
       <s:element name="HelloWorldResponse">
       <s:complexType>
       <s:sequence>
       <s:element minOccurs="0" maxOccurs="1" name="HelloWorldResult" type="s:string" />
       </s:sequence>
       </s:complexType>
       </s:element>
       </s:schema>
       </wsdl:types>
       <wsdl:message name="HelloWorldSoapIn">
       <wsdl:part name="parameters" element="tns:HelloWorld" />
       </wsdl:message>
       <wsdl:message name="HelloWorldSoapOut">
       <wsdl:part name="parameters" element="tns:HelloWorldResponse" />
       </wsdl:message>
       <wsdl:portType name="Service1Soap">
       <wsdl:operation name="HelloWorld">
       <wsdl:input message="tns:HelloWorldSoapIn" />
       <wsdl:output message="tns:HelloWorldSoapOut" />
       </wsdl:operation>
       </wsdl:portType>
       <wsdl:binding name="Service1Soap" type="tns:Service1Soap">
       <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
       <wsdl:operation name="HelloWorld">
       <soap:operation soapAction="http://tempuri.org/HelloWorld" style="document" />
       <wsdl:input>
       <soap:body use="literal" />
       </wsdl:input>
       <wsdl:output>
       <soap:body use="literal" />
       </wsdl:output>
       </wsdl:operation>
       </wsdl:binding>
       <wsdl:service name="Service1">
       <wsdl:port name="Service1Soap" binding="tns:Service1Soap">
       <soap:address location="http://localhost/MMDotNetTest/Service1.asmx" />
       </wsdl:port>
       </wsdl:service>

      Then I ran wscompile from jwsdp-1.5, with:
      wscompile -gen:client -f:documentliteral -f:wsi -mapping jaxrpc-test.xml -keep config-client.xml


      which produces among other stuff the mapping file and client classes.
      the jaxrpc-test.xml file reads


      <?xml version="1.0" encoding="UTF-8"?>
      <java-wsdl-mapping version="1.1"
       xmlns="http://java.sun.com/xml/ns/j2ee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
       http://www.ibm.com/webservices/xsd/j2ee_jaxrpc_mapping_1_1.xsd">
       <package-mapping>
       <package-type>de.aeb.mm.testwebservice.dotnetJboss</package-type>
       <namespaceURI>http://tempuri.org/</namespaceURI>
       </package-mapping>
       <java-xml-type-mapping>
       <java-type>de.aeb.mm.testwebservice.dotnetJboss.HelloWorld</java-type>
       <anonymous-type-qname>http://tempuri.org/:>HelloWorld</anonymous-type-qname>
       <qname-scope>complexType</qname-scope>
       <variable-mapping>
       <java-variable-name>name</java-variable-name>
       <xml-element-name>name</xml-element-name>
       </variable-mapping>
       </java-xml-type-mapping>
       <java-xml-type-mapping>
       <java-type>de.aeb.mm.testwebservice.dotnetJboss.HelloWorldResponse</java-type>
       <anonymous-type-qname>http://tempuri.org/:>HelloWorldResponse</anonymous-type-qname>
       <qname-scope>complexType</qname-scope>
       <variable-mapping>
       <java-variable-name>helloWorldResult</java-variable-name>
       <xml-element-name>HelloWorldResult</xml-element-name>
       </variable-mapping>
       </java-xml-type-mapping>
       <service-interface-mapping>
       <service-interface>de.aeb.mm.testwebservice.dotnetJboss.Service1</service-interface>
       <wsdl-service-name xmlns:serviceNS="http://tempuri.org/">serviceNS:Service1</wsdl-service-name>
       <port-mapping>
       <port-name>Service1Soap</port-name>
       <java-port-name>Service1Soap</java-port-name>
       </port-mapping>
       </service-interface-mapping>
       <service-endpoint-interface-mapping>
       <service-endpoint-interface>de.aeb.mm.testwebservice.dotnetJboss.Service1Soap</service-endpoint-interface>
       <wsdl-port-type xmlns:portTypeNS="http://tempuri.org/">portTypeNS:Service1Soap</wsdl-port-type>
       <wsdl-binding xmlns:bindingNS="http://tempuri.org/">bindingNS:Service1Soap</wsdl-binding>
       <service-endpoint-method-mapping>
       <java-method-name>helloWorld</java-method-name>
       <wsdl-operation>HelloWorld</wsdl-operation>
       <method-param-parts-mapping>
       <param-position>0</param-position>
       <param-type>de.aeb.mm.testwebservice.dotnetJboss.HelloWorld</param-type>
       <wsdl-message-mapping>
       <wsdl-message xmlns:wsdlMsgNS="http://tempuri.org/">wsdlMsgNS:HelloWorldSoapIn</wsdl-message>
       <wsdl-message-part-name>parameters</wsdl-message-part-name>
       <parameter-mode>IN</parameter-mode>
       </wsdl-message-mapping>
       </method-param-parts-mapping>
       <wsdl-return-value-mapping>
       <method-return-value>de.aeb.mm.testwebservice.dotnetJboss.HelloWorldResponse</method-return-value>
       <wsdl-message xmlns:wsdlMsgNS="http://tempuri.org/">wsdlMsgNS:HelloWorldSoapOut</wsdl-message>
       <wsdl-message-part-name>parameters</wsdl-message-part-name>
       </wsdl-return-value-mapping>
       </service-endpoint-method-mapping>
       </service-endpoint-interface-mapping>
      </java-wsdl-mapping>
      

      The service interface class is as follows (omitting lengthy package names that wscompile writes into every parameter)
      
      public interface Service1Soap extends java.rmi.Remote {
       public HelloWorldResponse helloWorld(HelloWorld parameters) throws
       java.rmi.RemoteException;
      }
      


      I invoke this with the following client code
      String name = "Joe";
      HelloWorld requestArg = new HelloWorld();
      requestArg.setName(name);
      try {
       ServiceFactory factory = ServiceFactory.newInstance();
       ServiceFactoryImpl jbossFactory = (ServiceFactoryImpl)factory;
       Service service = jbossFactory.createService(
       new URL("http://localhost/MMDotNetTest/Service1.asmx?WSDL"),
       new URL("http://localhost/jboss-test/jaxrpc-test.xml"),
       null,
       new QName("http://tempuri.org/", "Service1"),
       null);
      
       Service1Soap serviceSoap = (Service1Soap)service.getPort(new QName("http://tempuri.org/", "Service1Soap")
       ,Service1Soap.class);
       HelloWorldResponse res = serviceSoap.helloWorld(requestArg);
       System.out.println(res.getHelloWorldResult());
      } catch (Exception e2) {
       e2.printStackTrace();
      }
      


      Just to give all information, a sample answer as sent over the wire is as follows:
      <?xml version="1.0" encoding="utf-8"?>
      <soap:Envelope
      xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <soap:Body>
      <HelloWorldResponse xmlns="http://tempuri.org/">
      <HelloWorldResult>
      Hello Joe, here is .NET
      </HelloWorldResult>
      </HelloWorldResponse>
      </soap:Body>
      </soap:Envelope>
      




      b.t.w. the SAX exception is then converted in an UndeclaredThrowableException since the helloWorld() method is declared to only throw RemoteExceptions. so this might also need some fix.


        • 1. Re: Namespace problems invoking document/literal web service
          moebus

          In the meantime I have looked further into this.

          When my hello world web service is hosted in .NET (version 1.1), the xml tags of the answer are assigned to the target namespace.

          When the same service is run from JBoss, the answer tags are not part of the namespace. This latter version is parsed correctly by the jboss client, while the first one is not.

          My question now:
          is .NET using the wrong syntax, or are both versions valid and the client should handle both?

          Here is the two versions of the answer:
          from .NET, does not work correctly:

          <?xml version="1.0" encoding="utf-8"?>
          <soap:Envelope
          xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns:xsd="http://www.w3.org/2001/XMLSchema">
          <soap:Body>
          <HelloWorldResponse xmlns="http://tempuri.org/">
          <HelloWorldResult>Hello , here is assist</HelloWorldResult>
          </HelloWorldResponse>
          </soap:Body>
          </soap:Envelope>


          and here from JBoss server, which works:
          <?xml version="1.0" encoding="utf-8"?>
          <soap:Envelope
          xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns:xsd="http://www.w3.org/2001/XMLSchema">
          <soap:Body>
          <ns1:HelloWorldResponse xmlns:ns1="http://tempuri.org/">
          <HelloWorldResult>Hello , here is assist</HelloWorldResult>
          </ns1:HelloWorldResponse>
          </soap:Body>
          </soap:Envelope>

          And you see that in this latter version the namespace of the HelloWorldResponse tag is named ns1, this namespace is however not prefixed to the HelloWorldResult tag, while in the first example the namespace is globally added to the HelloWorldResponse tag.

          Hope someone can clarify this
          Thanks
          Manfred

          • 2. Re: Namespace problems invoking document/literal web service
            olgeolge

            Hi Manfred!

            I have ran into exactly the same problem( and exactly the same config of environments). Have you found out anything more?

            Thanks
            Ola

            • 3. Re: Namespace problems invoking document/literal web service
              thomas.diesler

              It has to do with

              elementFormDefault="qualified"
              


              Axis uses unqualified as the default, which is also the default in schema. Of course, it shuold use whatever you give in the wsdl, but the axis version we use internally is fundamentally not schema aware.

              You can either use "unqualified" if you can control the schema, or explicitly define the mapping with prefixes in ws4ee-deployment.xml



              • 4. Re: Namespace problems invoking document/literal web service
                moebus

                Thanks for the hint.
                Any comments on when/how this might get fixed.

                • 5. Re: Namespace problems invoking document/literal web service
                  thomas.diesler

                  This is beeing addressed by our new SOAP stack JBossWS, which is available in HEAD and will hopefully get backported to jboss-4.x in Q3/2005

                  • 6. Re: Namespace problems invoking document/literal web service
                    olgeolge

                    Hi Thomas!

                    I also want to thank for hint. Still I haven't come around problem as I'm not the owner of WS. Do you have any knowledge of how to change to unqualified in dotnet so I can send it to the developers there? They say this is automatic and they don't know how to change.

                    Do you now anything more about timeframe when fix is in place (will it be in 4.0.3?)? We have a production of this functionality in end of september and must take decision on how to proceed so all info is appreciated.

                    Thanks in advance
                    Ola

                    • 7. Re: Namespace problems invoking document/literal web service
                      thomas.diesler

                      You can use our propriatary descriptor ws4ee-deployment.xml to explicitly set the wire format.

                      Scan the testsuite for usages of ws4ee-deployment.xml. There are testcases associated with related JIRA issues.

                      • 8. Re: Namespace problems invoking document/literal web service
                        kcp

                        Hi,

                        any news on this problem? I am facing the same situation with a document/literal/qaulified dotNet Webservice that I have to call.

                        I tried to set an explicit mapping using the ws4ee-deployment.xml file. But it did not solve the problem.

                        I am using JB 4.0.2. Upgrading to 4.0.3 is not an option, because various services would have to be ported. Furthermore, an update won't help. I called the service using 4.0.3SP1 locally on my computer. I got the same error message as with 4.0.2.

                        Thanks for the info.
                        Charly

                        • 9. Re: Namespace problems invoking document/literal web service
                          thomas.diesler

                           


                          I tried to set an explicit mapping using the ws4ee-deployment.xml file. But it did not solve the problem.


                          To backup this claim, you would need to show that our test case that shows the contrary is invalid.

                          http://jira.jboss.org/jira/browse/JBWS-474