8 Replies Latest reply on Feb 23, 2006 1:01 PM by jason.greene

    Understanding Doc/Lit wrapped style response parameter unwra

    anil.saldhana

      Thomas, can you check whether the following method in
      org.jboss.ws.jaxrpc.ParameterWrapping is doing things correctly:

      public static Object unwrapResponseParameter(OperationMetaData opMetaData, Object resStruct)
       {
       assertOperationMetaData(opMetaData);
      
       Object retValue = null;
       if (resStruct != null)
       {
       ParameterMetaData paramMetaData = opMetaData.getReturnParameter();
       List<String> varNames = paramMetaData.getWrappedVariables();
       Class resStructType = resStruct.getClass();
      
       log.debug("unwrapResponseParameter: " + resStructType.getName());
       try
       {
       if (varNames.size() > 0)
       {
       String varName = varNames.get(0);
       PropertyDescriptor pd = new PropertyDescriptor(varName, resStructType);
       Method method = pd.getReadMethod();
       Object value = method.invoke(resStruct, new Object[] {});
       log.debug(" " + method.getName() + ": " + (value != null ? value.getClass().getName() : null));
       retValue = value;
       }
       }
       catch (RuntimeException rte)
       {
       throw rte;
       }
       catch (Exception e)
       {
       throw new IllegalArgumentException("Cannot unwrap request structure: " + e);
       }
       }
       return retValue;
       }
      



      Suppose I have a JavaBean like test.MyWrappedBean
      public class myWrappedBean
      {
       private boolean a;
       private int b;
      }
      


      I suppose the list of wrapped variables will be a,b.. But the method returns just "a". Infact the endresult of the whole operation on the dynamic proxy should be that the "MyWrappedBean" should be returned. But it will return a variable inside the wrapped bean.

      I will create a test case for this in JIRA. Thought I would ask you before.

        • 1. Re: Understanding Doc/Lit wrapped style response parameter u
          anil.saldhana

          I have a usecase for Portal wsrp (Julien asked me to assist) where the response message is:

          <env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>
           <env:Header/>
           <env:Body>
           <ns1:getServiceDescriptionResponse xmlns:ns1='urn:oasis:names:tc:wsrp:v1:types
          ' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
           <ns1:requiresRegistration>false</ns1:requiresRegistration>
           </ns1:getServiceDescriptionResponse>
           </env:Body>
          </env:Envelope>
          


          Now the mapping is:
          <wsdl-return-value-mapping>
          <method-return-value>org.jboss.portal.wsrp.core.ServiceDescription</method-return-value>
          <wsdl-message xmlns:wsdlMsgNS="urn:oasis:names:tc:wsrp:v1:intf">wsdlMsgNS:getServiceDescriptionResponse</wsdl-message>
          <wsdl-message-part-name>getServiceDescriptionResponse</wsdl-message-part-name>
          </wsdl-return-value-mapping>
          
          


          So the response from the WS call is a wrapped bean called ServiceDescription, but JBossWS returns a Boolean after unwrapping, taking into account the value of a variable inside this bean. If JBossWS does not attempt to unwrap the return value (ie. ServiceDescription), then everything is fine.

          From the wsdl.
           <element name="getServiceDescriptionResponse"
           type="types:ServiceDescription"/>
          
           <wsdl:message name="getServiceDescriptionResponse">
           <wsdl:part name="getServiceDescriptionResponse" element="types:getServiceDescriptionResponse"/>
           </wsdl:message>
          


          • 2. Re: Understanding Doc/Lit wrapped style response parameter u
            jason.greene

            I think you are misunderstanding the difference between wrapped and bare styles.

            If the jaxrpc-mapping.xml file has "<wrapped-element>" in the service-endpoint-method-mapping, then the parameters in method-param-parts-mapping will be wrapped in a javabean that is mapped to the single element in the doc/literal message. This also means that when unmarshalling the message it will first be mapped to the javabean, and then unwrapped to build the method signature.

            If "wrapped-element" is not specified, this is called bare style, which means there can only be one parameter and it becomes the full body of the message.

            Take a look at: webservice/test/resources/samples/chap02/wrapped
            webservice/test/resources/samples/chap02/bare

            -Jason

            • 3. Re: Understanding Doc/Lit wrapped style response parameter u
              anil.saldhana

              Some trace:

              2006-02-21 00:48:22,781 TRACE [org.jboss.ws.metadata.OperationMetaData] new OperationMetaData: [xmlName={urn:oasis:names:tc:wsrp:v1:intf}getServiceDescription,javaName=getServiceDescription]
              2006-02-21 00:48:22,781 TRACE [org.jboss.ws.metadata.JSR109MetaDataBuilder] buildParameterMetaDataDoc: {urn:oasis:names:tc:wsrp:v1:intf}getServiceDescription
              2006-02-21 00:48:22,781 TRACE [org.jboss.ws.metadata.JSR109MetaDataBuilder] isWrapParameters based on wrapped-element: false
              2006-02-21 00:48:22,796 TRACE [org.jboss.ws.metadata.JSR109MetaDataBuilder] isWrapParameters based on matching parts: true
              2006-02-21 00:48:22,796 TRACE [org.jboss.ws.metadata.OperationMetaData] addParameter:
              ParameterMetaData:
               xmlName={urn:oasis:names:tc:wsrp:v1:types}getServiceDescription
               xmlType={urn:oasis:names:tc:wsrp:v1:types}>getServiceDescription
               javaType=org.jboss.portal.wsrp.core.GetServiceDescription
               mode=IN
               inHeader=false
              2006-02-21 00:48:22,796 TRACE [org.jboss.ws.metadata.OperationMetaData] setReturnParameter:
              ParameterMetaData:
               xmlName={urn:oasis:names:tc:wsrp:v1:types}getServiceDescriptionResponse
               xmlType={urn:oasis:names:tc:wsrp:v1:types}ServiceDescription
               javaType=org.jboss.portal.wsrp.core.ServiceDescription
               mode=IN
               inHeader=false
              


              My issue is with this:
              [org.jboss.ws.metadata.JSR109MetaDataBuilder] isWrapParameters based on matching parts: true
              


              • 4. Re: Understanding Doc/Lit wrapped style response parameter u
                jason.greene

                Create a jira issue with a test case.

                -Jason

                • 5. Re: Understanding Doc/Lit wrapped style response parameter u
                  anil.saldhana

                   

                  http://jira.jboss.com/jira/browse/JBWS-717
                  


                  The overall problem is the inability to advice the jaxrpc client layer that the response is not a wrapped element. There is no support from jsr109 on this.


                  • 6. Re: Understanding Doc/Lit wrapped style response parameter u
                    jason.greene

                    I spoke with Anil, there was no real issue here. He just needed to switch to bare since the wsdl is not under our control

                    -Jason

                    • 7. Re: Understanding Doc/Lit wrapped style response parameter u
                      anil.saldhana

                      Converting to doc/lit bare solved the issue, but I am told that the wsrp spec mandates the following contract:

                      public ServiceDescription getServiceDescription(RegistrationContext rc,
                       String[] locales)
                      


                      plus the wsdl is unchangable.

                      With the doc/lit wrapped case, this particular wsrp usecase needs that the return value should not be unwrapped. I need to look at the wsrp spec in some detail (will do next week).

                      For the uninitiated,
                      This usecase is not a generalization of JBossWS support of doc/lit wrapped support.



                      • 8. Re: Understanding Doc/Lit wrapped style response parameter u
                        jason.greene

                        By looking at the WSDL it is obvious that they did not design it to follow the wrapped convention.

                        The interface descriptions you are referring to are purely semantic. They are just there to represent the form of the web service request and responses. Remember that a web service and its consumer have no notion of the other's underlying platform or language. For all we know, the language does not even have the concept of parameters.

                        If it is desired that the Java API mirror the semantic descriptions then the solution is to add a simple layer on top of the ws proxy objects.

                        This topic though should be moved to either the WSRP design form or the JBossWS user form.

                        -Jason