4 Replies Latest reply on Nov 29, 2012 6:29 AM by ranajitjana

    Reading Object in the interceptor

    ranajitjana

      CXF interceptor phases starts with INBOUND and ends at POST invoke.

       

      I am able to read the  instream at the READ phase.

       

      I was under impression that In UNMARSHALL phase Message will have inbound object by JAXB unmarshalling. While the same is not true.

       

      I looked into built-in CXF interceptors to see in anyway we can pull the object but every where it is working on stream.

       

      the stream is surely passed to the method in INVOKE phase thus should be unmarshalled.

       

      Any example on web will help me.

        • 1. Re: Reading Object in the interceptor
          ffang

          Hi,

           

          Not really sure what you mean here.

           

          But if you want pull the parameter as Object list, you can add a interceptor after Phase.UNMARSHAL and use code like

          message.getContent(List.class)

           

          Freeman

          • 2. Re: Reading Object in the interceptor
            ranajitjana

            Thank you Freeman,

             

            I want to get the Object which gets passed to the method.

             

            I used the following line in my code for the UNMARSHAL phase

            List lst = message.getContent(List.class);

             

            The value is coming as null when I debug.

             

            Regards,

            Ranajit

            • 3. Re: Reading Object in the interceptor
              ffang

              Hi,

               

              I mean after UNMARSHAL phase, like PRE_INVOKE.

               

              Freeman

              • 4. Re: Reading Object in the interceptor
                ranajitjana

                Thankyou Freeman,

                 

                I got the object in PRE_INVOKE phase.

                 

                currently using the following code.

                 

                MessageContentsList objs = MessageContentsList.getContentsList(message);

                          if (objs != null && objs.size() == 1) {

                              Object responseObj = objs.remove(0);

                             // ... cast the      responseObj  to DomainObject

                          }