Hi Dan, i am able to get the response while using the 2nd Option with the hard coded value like (String xml = "<s12:Envelope> ...</s12:Envelope>) in my code. the problem here i am facing while getting the response the following exception is occuring. what is the problem? how could i solve this? i tried with useJBIWrapper="false" but no luck..
Service mix Console -------------------- WARN - PhaseInterceptorChain - Interceptor has thrown exception, unwinding now org.apache.cxf.binding.soap.SoapFault: "http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper", the namespace on the "message" element, i s not a valid SOAP version. at org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:102) at org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:58) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236) at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:104) at org.apache.servicemix.cxfbc.CxfBcConsumer$JbiChainInitiationObserver.onMessage(CxfBcConsumer.java:644) at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.serviceRequest(JettyHTTPDestination.java:302) at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTTPDestination.java:266) at org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandler.java:70) at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766) at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230) at org.mortbay.jetty.handler.HandlerList.handle(HandlerList.java:49) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) at org.mortbay.jetty.Server.handle(Server.java:324) at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:534) at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:879) at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:828) at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:213) at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:403) at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409) at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:522) WARN - PhaseInterceptorChain - Interceptor has thrown exception, unwinding now org.apache.servicemix.cxfbc.interceptors.JbiFault: Fault occured at org.apache.servicemix.cxfbc.CxfBcConsumer$JbiPostInvokerInterceptor.handleMessage(CxfBcConsumer.java:791) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236) at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:104) at org.apache.servicemix.cxfbc.CxfBcConsumer$JbiChainInitiationObserver.onMessage(CxfBcConsumer.java:644) at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.serviceRequest(JettyHTTPDestination.java:302) at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTTPDestination.java:266) at org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandler.java:70) at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766) at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230) at org.mortbay.jetty.handler.HandlerList.handle(HandlerList.java:49) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) at org.mortbay.jetty.Server.handle(Server.java:324) at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:534) at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:879) at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:741) at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:213) at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:403) at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409) at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:522) Thanks & Regards Suresh dkulp wrote: > > > You are kind of munging both approaches.... > > Option 1 would look something like: > > MessageImpl messageImpl = new MessageImpl(); > Exchange exchange = msgContext.getExchange(); > exchange.setInMessage(messageImpl); > exchange.put("exchange.finished", Boolean.TRUE); > messageImpl.setExchange(exchange); > messageImpl.setContent(List.class, Arrays.asList(new Object[] {"Hello"}); > > Which would completely bypass the in interceptor chain. (note: no XML, > just > the return object) > > Otherwise, you would need something like: > > String xml = "<s12:Envelope> "; > byte[] theByteArray = xml.getBytes(); > MessageImpl messageImpl = new MessageImpl(); > Exchange exchange = msgContext.getExchange(); > exchange.setInMessage(messageImpl); > messageImpl.setExchange(exchange); > InputStream in = new ByteArrayInputStream(theByteArray) > messageImpl.setContent(InputStream.class , in); > messageImpl.setContent(XMLStreamReader.class, > StaxUtils.createXMLStreamReader(in)); > messageImpl.put(PhaseInterceptorChain.STARTING_AT_INTERCEPTOR_ID,BaseCXFLiteInterceptor.class.getName()); > Exchange exchange = message.getExchange(); > Conduit conduit = exchange.getConduit(message); > ((AbstractConduit)conduit).getMessageObserver().onMessage(inMessage); > > Basically, you would need to meet any requirements for all the > interceptors up > to the "starting at". That is most likely, at a minimum, creating an > XMLStreamReader. > > Dan > > > > > On Wed October 7 2009 9:34:55 am inalasuresh wrote: >> Hi Dan thanks for your response, >> As of your instructions i added the follwing code in my class. >> myMessage(Message msgContext) >> { >> String xml = "<s12:Envelope> "; >> byte[] theByteArray = xml.getBytes(); >> MessageImpl messageImpl = new MessageImpl(); >> Exchange exchange = msgContext.getExchange(); >> exchange.setInMessage(messageImpl); >> exchange.put("exchange.finished", Boolean.TRUE); >> messageImpl.setExchange(exchange); >> messageImpl.setContent(InputStream.class , new >> ByteArrayInputStream(theByteArray)); >> messageImpl.put(PhaseInterceptorChain.STARTING_AT_INTERCEPTOR_ID,BaseCXFLit >> eInterceptor.class.getName()); } >> it should display the string value in response side like <s12:Envelope>. >> but response is not as expected. >> what is wrong in the above code is there any thing else need to do. >> please >> help me out. >> can you send me an example code if avaliable. Hope your help is >> required.. >> >> dkulp wrote: >> > Well, stopping the current "out" chain is easy. You pretty much just >> > need to >> > grab the chain from the message and "pause" it. >> > >> > The custom response part is the tricky part and depends on how you want >> > to go >> > about it. >> > >> > Easy way, kind of "hacky", but fast as no additional processing >> will/can >> > occur: >> > Create a new MessageImpl and set the exchange.setInMessage() to it. >> > do exchange.put("exchange.finished", Boolean.TRUE); >> > set inMsg.setContent(List.class, .....) to a List which would >> represent >> > the >> > return valued. It should just be a list of length 1. >> > >> > >> > Harder, but more "complete/correct" as it will call the incoming chain >> so >> > things like Holders and wrappers and stuff can be used: >> > You basically need to get the Conduit out of the out message: >> > >> > Exchange exchange = message.getExchange(); >> > Conduit conduit = exchange.getConduit(message); >> > >> > The conduit MOST LIKELY (all of ours except the CorbaConduit do) extend >> > from >> > AbstractConduit (not sure why the Corba one doesn't) which extends >> > AbstractObservable which has a method: MessageObserver >> > getMessageObserver() >> > >> > Basically, you would create a new Message, fill in the details such as >> > the List as above, maybe an InputStream if your response is a stream, >> > fake headers, etc.... and call the handleMessage call on that >> > MessageObserver. >> > >> > That will setup a complete interceptor chain and such for the >> "incoming" >> > message. If you need it to skip things (like not do the stream >> things), >> > you >> > can set >> > message.put(PhaseInterceptorChain.STARTING_AT_INTERCEPTOR_ID, ...) >> > or >> > message.put(PhaseInterceptorChain.STARTING_AFTER_INTERCEPTOR_ID, ...) >> > >> > to have it start at a specific point. >> > >> > >> > Hope that helps a bit! >> > Dan >> > >> > On Wed September 30 2009 2:15:57 am inalasuresh wrote: >> >> Hi One & All >> >> >> >> While we are working on Delegate (for cxfbc:provider) for FUSE, we >> have >> >> some technical issues and need some assistance. >> >> >> >> Problem Description >> >> >> >> In OUT interceptor of a CXF provider, how can we stop the provider >> >> invoking >> >> its endpoint and send a response back? >> >> >> >> Example: >> >> I have a cxfbc:provider with some interceptors configured for both IN >> >> and OUT flows. When the cxf provider is making a request, the OUT >> >> interceptor gets invoked and in this interceptor I would like to stop >> >> invoking actual endpoint and send back my own response. That means I >> >> should be able to tell >> >> the interceptor chain to stop further processing of this flow, set a >> >> response message into message exchange and invoke the IN flow. How do >> I >> >> do >> >> that? >> >> >> >> This kind of mediation/interception is possible in standard >> >> specifications >> >> like JAX-RPC, JAX-WS, Servlets etc… wondering if CXF provides any sort >> >> of this kind. >> >> >> >> Also we would like to know who is invoking a provider endpoint in CXF >> >> stack >> >> in FUSE? Is it an OUT interceptor at the end of interceptor chain or >> >> some other transport component after the interceptor chain? >> >> >> >> Thanks in Advance >> >> Suresh >> > > -- > Daniel Kulp > [email protected] > http://www.dankulp.com/blog > > -- View this message in context: http://www.nabble.com/In-OUT-interceptor-of-a-CXF-provider%2C-how-can-we-stop-the-provider-invoking-its-endpoint-and-send-a-response-back--tp25675554p25869650.html Sent from the cxf-user mailing list archive at Nabble.com.
