7 Replies Latest reply on May 29, 2012 9:46 PM by tadayosi

    How to pass <xs:any>  type of element from JBoss ESB to Webservice?

    amandal

      I have an XML that conforms to the attached XS, Sample.xsd. Now the xmlPayload ref can hold any type of schema.
      So ideally the message that I am passing to the ESB looks something like the Sample.xml attached.

       

      I invoke a Webservice from my ESB using the SOAPClient action and pass the xml to the WS by creating a requestMap in a Custom Action class.

      Am populating it as below -

      requestMap.put("Execute.Request.xmlPayload", lmksDoc.xmlText());   where lmksDoc.xmlText() is the String version of the ref type mentioned in the Sample.xsd

       

      The problem that I am facing is that the Webservice is unable to interpret the Element that is of type xs:any i.e. in my case the Landmarks Element.
      Am attaching the jax-ws generated XmlPayload.java class for your reference. The 'any' element in the class should be populated with the String type that am sending in the ESB request map above but its coming as null.

       

      Howdo I make the Webservice runtime understand an any type? Reading uphttp://community.jboss.org/wiki/HowtotransferGenericCollectioninWebService did not help because I want the schema to be generic and hence the introduction of xs:type.

       


      Please help!!

       

      Thanks,
      Aps

        • 1. How to pass <xs:any>  type of element from JBoss ESB to Webservice?
          kcbabo

          Are you saying that the request message coming out of the ESB is wrong in some way?  Or are you looking for help in defining the JAX-WS service implementation for the external web service?

          • 2. How to pass <xs:any>  type of element from JBoss ESB to Webservice?
            amandal

            Hi Keith,

            Thanks for the response. Here's clarifying your question-

            I have my Webservice implentation already in place with the following signature -

             

            @WebMethod(operationName = "Execute", action = "http://sg.com/esb/Execute")

                @WebResult(name = "ExecuteResult", targetNamespace = "http://sg.com/esb/")

                @RequestWrapper(localName = "Execute", targetNamespace = "http://sg.com/esb/", className = "com.sg.esb.Execute")

                @ResponseWrapper(localName = "ExecuteResponse", targetNamespace = "http://sg.com/esb/", className = "com.sg.esb.ExecuteResponse")

                public com.sg.esb.ExecuteResponse.ExecuteResult execute(

                    @WebParam(name = "Request", targetNamespace = "http://sg.com/esb/")

                    com.sg.esb.Execute.Request request)

             

             

            If you have noticed the <xs:choice> element in the Sample.xsd attched in the original post, it is that which is the cause of my problem. Even though I set the Execute.Request.xmlPayload key of the OGNL requestMap in ESB Action class, I cannot unmarshall it back as an XmlPayload class in the Webservice. Please look at the XmlPayload.java from the original post. The getAny() method returns null always. Basically the choice object is goofing it up.

             

            Is there a way by which we could successfuly marshall and unmarshall an xs:any type object from ESB to Webservice?

             

            Thanks for the help,

            Aps

            • 3. How to pass <xs:any>  type of element from JBoss ESB to Webservice?
              kcbabo

              Hi Aps,

               

              What I'm trying to determine is if the SOAP message coming out of the ESB contains the esb:xmlPayload element.  You posted a sample of what it should look like, but it's not clear to me if you have confirmed whether or not that's what is coming out of the ESB as the request content.

               

              cheers,

              keith

              • 4. Re: How to pass <xs:any>  type of element from JBoss ESB to Webservice?
                amandal

                Keith,

                Am attaching a snippet from the server.log that prints the OGNL Request map created in the Action class of the ESB -

                 

                2011-02-14 17:34:04,564 INFO  [STDOUT] (pool-36-thread-1) Method name : createNewLandmark

                2011-02-14 17:34:04,580 INFO  [SvgLogger] (pool-36-thread-1) [com.sg.esb.landmark.action.LandmarkRequestAction] Request map is: {Execute.Request.MethodName=createNewLandmark, Execute.Request.xmlPayload=

                                    <lmk:Landmarks xmlns:lmk="http://sg.com/lmk/UpdateLandmarks/" xmlns:esb="http://sg.com/esb/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">

                                        <lmk:Landmark>

                                            <lmk:startDate>startDate1</lmk:startDate>

                                            <lmk:endDate>endDate1</lmk:endDate>

                                            <lmk:LandmarkAddress>

                                                <lmk:VehicleGeoCode>

                                                    <lmk:latitude>latitude1</lmk:latitude>

                                                    <lmk:longitude>longitude1</lmk:longitude>

                                                </lmk:VehicleGeoCode>

                                                <lmk:line>line1</lmk:line>

                                                <lmk:city>lmk:city1</lmk:city>

                                                <lmk:state>lmk:state1</lmk:state>

                                                <lmk:zip>lmk:zip1</lmk:zip>

                                                <lmk:crossStreet>lmk:crossStreet1</lmk:crossStreet>

                                                <lmk:county>lmk:county1</lmk:county>

                                                <lmk:country>lmk:country1</lmk:country>

                                            </lmk:LandmarkAddress>

                                            <lmk:employeeNumber>lmk:employeeNumber1</lmk:employeeNumber>

                                            <lmk:LandmarkDetail>

                                                <lmk:landmarkID>lmk:landmarkID1</lmk:landmarkID>

                                                <lmk:landmarkType>lmk:landmarkType1</lmk:landmarkType>

                                                <lmk:landmarkTimeZone>lmk:landmarkTimeZone1</lmk:landmarkTimeZone>

                                            </lmk:LandmarkDetail>

                                            <lmk:proximity>lmk:proximity1</lmk:proximity>

                                        </lmk:Landmark>

                                        <!-- lmk:Landmark>

                                            <lmk:startDate>lmk:startDate2</lmk:startDate>

                                            <lmk:endDate>lmk:endDate2</lmk:endDate>

                                            <lmk:LandmarkAddress>

                                                <lmk:VehicleGeoCode>

                                                    <lmk:latitude>lmk:latitude2</lmk:latitude>

                                                    <lmk:longitude>lmk:longitude2</lmk:longitude>

                                                </lmk:VehicleGeoCode>

                                                <lmk:line>lmk:line2</lmk:line>

                                                <lmk:city>lmk:city2</lmk:city>

                                                <lmk:state>lmk:state2</lmk:state>

                                                <lmk:zip>lmk:zip2</lmk:zip>

                                                <lmk:crossStreet>lmk:crossStreet2</lmk:crossStreet>

                                                <lmk:county>lmk:county2</lmk:county>

                                                <lmk:country>lmk:country2</lmk:country>

                                            </lmk:LandmarkAddress>

                                            <lmk:employeeNumber>lmk:employeeNumber2</lmk:employeeNumber>

                                            <lmk:LandmarkDetail>

                                                <lmk:landmarkID>lmk:landmarkID2</lmk:landmarkID>

                                                <lmk:landmarkType>lmk:landmarkType2</lmk:landmarkType>

                                                <lmk:landmarkTimeZone>lmk:landmarkTimeZone2</lmk:landmarkTimeZone>

                                            </lmk:LandmarkDetail>

                                            <lmk:proximity>lmk:proximity2</lmk:proximity>

                                        </lmk:Landmark-->

                                    </lmk:Landmarks>

                                }

                2011-02-14 17:34:04,595

                Even though I am setting the xmlPayoad using

                requestMap.put("Execute.Request.xmlPayload", xmlPayload.xmlText());

                 

                the Webservice cannot interpret it. It is returning the choice object as class com.sg.esb.ParamListType which is the other element in the choice complex type. Actually this is a progress(?) made yesterday after changing the Execute.java class a bit. Execute.Result is the input to my webservice. Am attaching both.

                 

                The sysouts from the webservice are as below -

                2011-02-14 17:34:04,595 INFO  [STDOUT] (http-localhost%2F127.0.0.1-8080-1) Inside execute method in Web service .......

                2011-02-14 17:34:04,611 INFO  [STDOUT] (http-localhost%2F127.0.0.1-8080-1) Message receved : Method createNewLandmark

                2011-02-14 17:34:04,611 INFO  [STDOUT] (http-localhost%2F127.0.0.1-8080-1) ChoiceObj : class com.sg.esb.ParamListType

                2011-02-14 17:34:04,611 INFO  [STDOUT] (http-localhost%2F127.0.0.1-8080-1) Some other instance type

                 

                Thanks again Keith,

                Aps

                • 5. Re: How to pass <xs:any>  type of element from JBoss ESB to Webservice?
                  amandal

                  I figured out a solution that works.

                  The requestMap I created was of type HashMap<String, Object>. When trying to pass the <xs:any>  type of element as an object it was not being detected at the Webservice end (for reasons I donot know!). So I changed the Map instance to a type of HashMap<String, String> and passes the xmltext() version of the xs:any type element as below -

                   

                  requestMap.put("Execute.Request.xmlPayload", lmksDoc.xmlText());

                   

                  At the Webservice end, I removed the choice complex type and instead added xmlPayload as String with minOccurs="0" rendering the Request inner class as

                   

                  public static class Request {
                  
                          @XmlElement(name = "MethodName", required = true)
                          protected String methodName;
                          protected String xmlPayload;
                          @XmlElement(name = "ParameterList")
                          protected ParamListType parameterList;
                  

                   

                  That solved my problem and the lmksDoc gets unmarshalled at the Webservice in the xmlPayload element above.

                   

                  However, why an Object of type choice, at the webservice end does not work I have no clue!

                   

                  Am marking this as 'assumed answered'.

                  • 6. Re: How to pass <xs:any>  type of element from JBoss ESB to Webservice?
                    ramanap

                    I have the same problem in passing xs:any from the ESB to web service using SoapClient.   I am printing the request in the handler before reaching the webservice, and the parameter passed is not sent to the web service. Here the problem looks like mapping OGNL from ESB to xs:any.   When I use SOAP Ui and pass the same XML,  it works fine.

                     

                    If anybody has any clue, Please let me know.

                     

                    Thanks,

                    RamJI

                    • 7. Re: How to pass <xs:any>  type of element from JBoss ESB to Webservice?
                      tadayosi

                      Please see https://issues.jboss.org/browse/JBESB-3809 for the discussion of this issue.