I have an interceptor that takes the payload from a REST service and
processes it in the handleMessage. 
After processing the chain continues and enters into the actual web service
business logic.
When i use getContent, the request data is coming to the business logic
empty.

public class LogWriterInterceptor
        extends AbstractLoggingInterceptor




--



@Override
        public void handleMessage( Message message ) 
                        throws Fault
        {
                message.setId( UUID.randomUUID().toString() );
                
                Map<String,String> map = new HashMap<>();
                
                /*InputStream inputStream = message.getContent( 
InputStream.class );*/
                
                BufferedReader reader = new BufferedReader( new 
InputStreamReader(
inputStream ) );
                
                StringBuilder outString = new StringBuilder();
        
                String line;
        
                try 
                {
                     while ( (line = reader.readLine() ) != null )
                     {
                            outString.append( line );
                     }
                  } catch ( IOException ioe )
                  {
                                ioe.printStackTrace();
                  }
             
        
        //adds the payload
        map.put( "PAYLOAD", outString.toString() );
        map.put("ID", message.getId() );
        map.put( Message.REQUEST_URL,
(String)message.get(Message.REQUEST_URL));
        
        
        try
        {
            reader.close();
        } catch ( IOException ioe )
        {
            ioe.printStackTrace();
        }
        
        System.out.println( map.toString() );
        
    }



this works fine and i get the payload, but when my business logic gets it,
the payload is empty
see log:




10:03:52.519 [http-nio-8091-exec-47] DEBUG
o.a.cxf.phase.PhaseInterceptorChain - Invoking handleMessage on interceptor
org.apache.cxf.ws.policy.PolicyInInterceptor@47ab1fa6
10:03:52.520 [http-nio-8091-exec-47] DEBUG
o.a.cxf.phase.PhaseInterceptorChain - Invoking handleMessage on interceptor
org.apache.cxf.interceptor.LoggingInInterceptor@5228f590
10:03:52.520 [http-nio-8091-exec-47] INFO  o.a.c.i.LoggingInInterceptor -
Inbound Message
*----------------------------
ID: 2
Address: http://localhost:8091/starterspcxfrestplus/api/person
Encoding: ISO-8859-1
Http-Method: POST
Content-Type: application/json
Headers: {Accept=[*/*], accept-encoding=[gzip,deflate,sdch],
accept-language=[en-US,en;q=0.8], connection=[keep-alive],
consumerid=[Brandon], Content-Length=[70], content-type=[application/json],
cookie=[_ga=GA1.1.1380405775.1443628965], host=[localhost:8091],
origin=[chrome-extension://hgmloofddffdnphfgcellkdfbfbjeloo],
password=[password], subscriberid=[H], token=[], user-agent=[Mozilla/5.0
(Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/32.0.1700.77 Safari/537.36], userid=[userid], version=[1.0]}
Payload: {
 "id": "17",
 "location": "W",
 "name": "B"
}*
--------------------------------------
10:03:52.520 [http-nio-8091-exec-47] DEBUG
o.a.cxf.phase.PhaseInterceptorChain - Invoking handleMessage on interceptor
com.startersprestplus.listeners.LogWriterInterceptor@5c96c1e0
*{org.apache.cxf.request.url=http://localhost:8091/starterspcxfrestplus/api/person,
PAYLOAD={ "id": "17", "location": "W", "name": "B"},
ID=2fa0f243-1745-48d1-8d19-c43e3db1f11e}*
10:03:52.520 [http-nio-8091-exec-47] DEBUG
o.a.cxf.phase.PhaseInterceptorChain - Invoking handleMessage on interceptor
org.apache.cxf.transport.https.CertConstraintsInterceptor@68240256
10:03:52.520 [http-nio-8091-exec-47] DEBUG
o.a.cxf.phase.PhaseInterceptorChain - Invoking handleMessage on interceptor
org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor@56cb42e1
10:03:52.520 [http-nio-8091-exec-47] DEBUG
o.apache.cxf.jaxrs.utils.JAXRSUtils - Trying to select a resource class,
request path : /person
10:03:52.520 [http-nio-8091-exec-47] DEBUG
o.apache.cxf.jaxrs.utils.JAXRSUtils - Resource class
com.implementations.PersonServiceImpl may get selected, request path :
com.implementations.PersonServiceImpl, resource class @Path : /person
10:03:52.520 [http-nio-8091-exec-47] DEBUG
o.apache.cxf.jaxrs.utils.JAXRSUtils - No resource class match for
com.implementations.ExceptionImpl, request path : /person
10:03:52.520 [http-nio-8091-exec-47] DEBUG
o.apache.cxf.jaxrs.utils.JAXRSUtils - Resource class
com.implementations.PersonServiceImpl has been selected, request path :
com.implementations.PersonServiceImpl, resource class @Path : /person
10:03:52.520 [http-nio-8091-exec-47] DEBUG
o.apache.cxf.jaxrs.utils.JAXRSUtils - Trying to select a resource operation
on the resource class com.implementations.PersonServiceImpl
10:03:52.521 [http-nio-8091-exec-47] DEBUG
o.apache.cxf.jaxrs.utils.JAXRSUtils - No method match, method name :
getPersonDetail, request path : /, method @Path : /{id}, HTTP Method : POST,
method HTTP Method : GET, ContentType : application/json, method @Consumes :
*/*,, Accept : */*,, method @Produces : application/json,.
10:03:52.521 [http-nio-8091-exec-47] DEBUG
o.apache.cxf.jaxrs.utils.JAXRSUtils - No method match, method name :
deletePersonDetail, request path : /, method @Path : /{id}, HTTP Method :
POST, method HTTP Method : DELETE, ContentType : application/json, method
@Consumes : */*,, Accept : */*,, method @Produces : application/json,.
10:03:52.521 [http-nio-8091-exec-47] DEBUG
o.apache.cxf.jaxrs.utils.JAXRSUtils - Resource operation postPersonDetail
may get selected
10:03:52.521 [http-nio-8091-exec-47] DEBUG
o.apache.cxf.jaxrs.utils.JAXRSUtils - No method match, method name :
putPersonDetail, request path : /, method @Path : /, HTTP Method : POST,
method HTTP Method : PUT, ContentType : application/json, method @Consumes :
application/json,, Accept : */*,, method @Produces : application/json,.
10:03:52.521 [http-nio-8091-exec-47] DEBUG
o.apache.cxf.jaxrs.utils.JAXRSUtils - No method match, method name :
getPersonHead, request path : /, method @Path : /, HTTP Method : POST,
method HTTP Method : HEAD, ContentType : application/json, method @Consumes
: */*,, Accept : */*,, method @Produces : text/plain,.
10:03:52.521 [http-nio-8091-exec-47] DEBUG
o.apache.cxf.jaxrs.utils.JAXRSUtils - No method match, method name :
getPersonOptions, request path : /, method @Path : /, HTTP Method : POST,
method HTTP Method : OPTIONS, ContentType : application/json, method
@Consumes : */*,, Accept : */*,, method @Produces : */*,.
10:03:52.521 [http-nio-8091-exec-47] DEBUG
o.apache.cxf.jaxrs.utils.JAXRSUtils - Resource operation postPersonDetail on
the resource class com.implementations.PersonServiceImpl has been selected
10:03:52.521 [http-nio-8091-exec-47] DEBUG o.a.c.j.i.JAXRSInInterceptor -
Request path is: /person
10:03:52.521 [http-nio-8091-exec-47] DEBUG o.a.c.j.i.JAXRSInInterceptor -
Request HTTP method is: POST
10:03:52.521 [http-nio-8091-exec-47] DEBUG o.a.c.j.i.JAXRSInInterceptor -
Request contentType is: application/json
10:03:52.521 [http-nio-8091-exec-47] DEBUG o.a.c.j.i.JAXRSInInterceptor -
Accept contentType is: */*
10:03:52.521 [http-nio-8091-exec-47] DEBUG o.a.c.j.i.JAXRSInInterceptor -
Found operation: postPersonDetail
10:03:52.521 [http-nio-8091-exec-47] DEBUG
o.a.cxf.phase.PhaseInterceptorChain - Invoking handleMessage on interceptor
org.apache.cxf.interceptor.OneWayProcessorInterceptor@4de195a5
10:03:52.521 [http-nio-8091-exec-47] DEBUG
o.a.cxf.phase.PhaseInterceptorChain - Invoking handleMessage on interceptor
org.apache.cxf.interceptor.ServiceInvokerInterceptor@81d63b
10:03:52.521 [http-nio-8091-exec-47] DEBUG o.a.c.s.invoker.AbstractInvoker -
Invoking method public javax.ws.rs.core.Response
com.interactors.implementations.PersonServiceImpl.postPersonDetail(javax.ws.rs.core.HttpHeaders,java.lang.String)
on object com.implementations.PersonServiceImpl@39a220c0 with params
[org.apache.cxf.jaxrs.impl.HttpHeadersImpl@491c2e46, ].
*REQUESTTRANSACTION=*
10:03:52.522 [http-nio-8091-exec-47] DEBUG
o.a.cxf.phase.PhaseInterceptorChain - Invoking handleMessage on interceptor
org.apache.cxf.interceptor.OutgoingChainInterceptor@632d2f5c
10:03:52.522 [http-nio-8091-exec-47] DEBUG o.a.c.i.OutgoingChainInterceptor
- Interceptors contributed by bus:
[org.apache.cxf.ws.policy.PolicyOutInterceptor@629ffbfc]
10:03:52.522 [http-nio-8091-exec-47] DEBUG o.a.c.i.OutgoingChainInterceptor
- Interceptors contributed by service: []
10:03:52.522 [http-nio-8091-exec-47] DEBUG o.a.c.i.OutgoingChainInterceptor
- Interceptors contributed by endpoint:
[org.apache.cxf.interceptor.MessageSenderInterceptor@4c7dde8e]
10:03:52.522 [http-nio-8091-exec-47] DEBUG o.a.c.i.OutgoingChainInterceptor
- Interceptors contributed by binding:
[org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor@60fc4c36]
10:03:52.522 [http-nio-8091-exec-47] DEBUG
o.a.cxf.phase.PhaseInterceptorChain - Chain
org.apache.cxf.phase.PhaseInterceptorChain@c1eb901 was created. Current
flow:
  setup [PolicyOutInterceptor]
  prepare-send [MessageSenderInterceptor]
  marshal [JAXRSOutInterceptor]




--
View this message in context: 
http://cxf.547215.n5.nabble.com/Message-content-empty-after-getContent-tp5762102.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to