0 Replies Latest reply on Jul 27, 2005 2:47 PM by thomas.diesler

    Question about document/literal

    thomas.diesler

      Paulo wrote:

      I have been working quite intensely with J2EE 1.4 web services in the previous weeks. I'm working mostly with JBoss 4.02 and with WebSphere 6.
      While using rpc/encoded and rpc/literal everything went ok. Everything behaved as expected, and both application servers dealt with my applications in the same way.
      The problem happened when I started to use document/literal. I know that JBoss has some problems when dealing with document/literal applications. I read several messages in the JBoss forums about this subject. I also read the WSDocServiceStepByStep document. But the reason of me sending this email was not these specific problems but the approach you're taking to fully support document/literal. I think that by presenting an example it will be easier to explain my point.
      Let's assume I have the following WSDL:

      <wsdl:types>
       <xsd1:schema attributeFormDefault="qualified"
      elementFormDefault="qualified"
       targetNamespace="http://logic.business.application.rootpackage/types"
      >
       <xsd1:element name="sayHello">
       <xsd1:complexType name="SayHello">
       <xsd1:sequence>
       <xsd1:element name="name" type="Level1Struct"/>
       </xsd1:sequence>
       </xsd1:complexType>
       </xsd1:element>
       <xsd1:element name="sayHelloResponse">
       <xsd1:complexType name="SayHelloResponse">
       <xsd1:sequence>
       <xsd1:element name="sayHelloReturn" type="xsd1:boolean"/>
       </xsd1:sequence>
       </xsd1:complexType>
       </xsd1:element>
       <xsd:complexType name="Level1Struct"> <xsd:all>
       <xsd:element name="id" type="xsd:string"/>
       <xsd:element name="salary" type="xsd:double" nillable="true"/>
       <xsd:element name="level2" type=" Level2Struct"/> </xsd:all>
       </xsd:complexType>
       <xsd:complexType name="Level2Struct">
       <xsd:all>
       <xsd:element name="name" type="xsd:string"/>
       <xsd:element name="age" type="xsd:string"/>
       </xsd:all>
       </xsd:complexType>
       </xsd1:schema>
       </wsdl:types>
       <wsdl:message name="sayHelloMessageResponse">
       <wsdl:part name="sayHello" element="xsd:sayHelloResponse"/>
       </wsdl:message>
       <wsdl:message name="sayHelloMessageRequest">
       <wsdl:part name="sayHello" element="xsd:sayHello"/>
       </wsdl:message>
       <wsdl:portType name="HelloComponentPortType">
       <wsdl:operation name="sayHello" parameterOrder="">
       <wsdl:input name="sayHelloRequest"
      message="tns:sayHelloMessageRequest"/>
       <wsdl:output name="sayHelloResponse"
      message="tns:sayHelloMessageResponse"/>
       </wsdl:operation>
       </wsdl:portType>
      (...)
      


      Basically I have just one operation that is taking one parameter (a
      Level1Struct) and returning a double. For the java to xml mappings I provide the following:

      <java-xml-type-mapping>
      
      <java-type>rootpackage.application.business.common.Level1Struct</java-type>
       <root-type-qname
      xmlns:typeNS="http://common.business.application.rootpackage">typeNS:Level1S
      truct</root-type-qname>
       <qname-scope>complexType</qname-scope>
       <variable-mapping>
       <java-variable-name>id</java-variable-name>
       <xml-element-name>id</xml-element-name>
       </variable-mapping>
       <variable-mapping>
       <java-variable-name>salary</java-variable-name>
       <xml-element-name>salary</xml-element-name>
       </variable-mapping>
       <variable-mapping>
       <java-variable-name>level2</java-variable-name>
       <xml-element-name>level2</xml-element-name>
       </variable-mapping>
       </java-xml-type-mapping>
       <java-xml-type-mapping>
      
      <java-type>rootpackage.application.business.common.Level2Struct</java-type>
       <root-type-qname
      xmlns:typeNS="http://common.business.application.rootpackage">typeNS:Level2S
      truct</root-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>
       <variable-mapping>
       <java-variable-name>age</java-variable-name>
       <xml-element-name>age</xml-element-name>
       </variable-mapping>
       </java-xml-type-mapping>
      


      As you can see I'm just providing mappings for the root complex types. The specification is not very clear about this. They say "there must be java-xml-type-mapping for every root WSDL type". Although it's not clear I would say that I don't have to provide any mapping for the root elements referenced in the element attribute of the wsdl.part of the request/response. Whenever using document/literal I know that there will be an element that has a complex type, with a sequence, with an element for each parameter. Therefore I would expect the application server to guess this mapping and to do deal with it automatically. And WebSphere 6 works like that. If I provide the wsdl/mapping that I presented above everything will work correctly.
      If I try to deploy the same application in JBoss I immediately get two warnings alerting me to the fact that I did not specify a mapping for the two elements (sayHello and sayHelloResponse). But, as I explained, I assume that I don't have to provide this mapping. I don't even know how to map it.
      Both elements have an anonymous complex type, and I have no java class that maps to these complex types. I know that wscompile can generate these classes, but I insist in my point- shouldn't the application server deal with this information automatically? At least that's the way I look at it, that's the way WebSphere works, and although I don't have too much knowledge about Axis, I think it also works like that.

      Many thanks for your attention!

      Paulo