hi all, i tried changing the ProcessInOut method of HttpInOutBinding Component to make my http component route by itself.
the control is going to the receiver component properly but some error in receiving the message. here my receiver just gets the messge on onMessageExchange() and prints it on the console. here is my HttpInOutBinding code.... /* * Copyright 2005-2006 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package ss.servicemix.components.http; import javax.jbi.JBIException; import javax.jbi.component.ComponentContext; import javax.jbi.messaging.ExchangeStatus; import javax.jbi.messaging.InOnly; import javax.jbi.messaging.InOut; import javax.jbi.messaging.MessageExchangeFactory; import javax.jbi.messaging.MessagingException; import javax.jbi.messaging.NormalizedMessage; import javax.jbi.servicedesc.ServiceEndpoint; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.xml.namespace.QName; import javax.xml.transform.TransformerException; import org.apache.servicemix.jbi.jaxp.SourceTransformer; import org.apache.servicemix.jbi.jaxp.StringSource; import org.apache.servicemix.jbi.resolver.EndpointResolver; import org.apache.servicemix.jbi.resolver.NullEndpointFilter; import org.apache.servicemix.jbi.resolver.ServiceNameEndpointResolver; import java.io.IOException; /** * A HTTP Binding Component which performs an [EMAIL PROTECTED] InOut} exchange with JBI and returns the response * by default but is configurable to be an [EMAIL PROTECTED] InOnly} exchange. * * @version $Revision: 368020 $ */ public class HttpInOutBinding extends HttpBindingSupport { private boolean defaultInOut = true; private EndpointResolver resolver; public void process(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, JBIException { processInOut(request, response); } public void processInOut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, JBIException { System.out.println("************************************ inside process inout"); MessageExchangeFactory factory = getExchangeFactory(); InOut exchange = factory.createInOutExchange(); NormalizedMessage inMessage = exchange.createMessage(); try { getMarshaler().toNMS(exchange, inMessage, request); System.out.println("process inout Message:"+inMessage); SourceTransformer sourceTransformer= new SourceTransformer(); System.out.println("\nMessage:"+sourceTransformer.toString(inMessage.getContent())); resolver = new ServiceNameEndpointResolver( new QName("http://servicemix.org/example/", "receiver")); ServiceEndpoint destination = null; System.out.println("resolver---->"+resolver); if (resolver != null) { destination = resolver.resolveEndpoint(getContext(), exchange, NullEndpointFilter.getInstance()); System.out.println("resolver----++>"+resolver); } if (destination != null) { // lets explicitly specify the destination - otherwise // we'll let the container choose for us System.out.println("destination"+destination); exchange.setEndpoint(destination); } exchange.setInMessage(inMessage); // inMessage.setContent(new StringSource(sourceTransformer.toString(inMessage.getContent()))); getDeliveryChannel().sendSync(exchange); getMarshaler().toResponse(exchange, exchange.getOutMessage(), response); done(exchange); response.setStatus(HttpServletResponse.SC_OK); } catch (IOException e) { fail(exchange, e); outputException(response, e); } catch (TransformerException e) { fail(exchange, e); outputException(response, e); } System.out.println("************************************getting out of process inout"); } public void processInOnly(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, JBIException { MessageExchangeFactory factory = getExchangeFactory(); InOnly exchange = factory.createInOnlyExchange(); NormalizedMessage inMessage = exchange.createMessage(); try { HttpMarshaler marshaler = getMarshaler(); marshaler.toNMS(exchange, inMessage, request); exchange.setInMessage(inMessage); // Do a sendSync so that the stream is not closed getDeliveryChannel().sendSync(exchange); response.setStatus(HttpServletResponse.SC_OK); } catch (IOException e) { fail(exchange, e); outputException(response, e); } } // Properties //------------------------------------------------------------------------- public boolean isDefaultInOut() { return defaultInOut; } /** * Sets whether an InOut (the default) or an InOnly message exchange will be used by default. */ public void setDefaultInOut(boolean defaultInOut) { this.defaultInOut = defaultInOut; } // Implementation methods //------------------------------------------------------------------------- /** * Return true if this request is an [EMAIL PROTECTED] InOut} request otherwise it will be assumed to be an [EMAIL PROTECTED] InOnly} */ protected boolean isInOutRequest(HttpServletRequest request, HttpServletResponse response) { return isDefaultInOut(); } } The error i am getting is........ :INFO: Started SocketConnector @ localhost:8555 destination--->null resolver---->[EMAIL PROTECTED] destination---->ServiceEndpoint[service={http://servicemix.org/example/}receiver,endpoint=receiver] ************************************ inside process inout process inout Message:[EMAIL PROTECTED]: {Content-Length=287, Connection=keep-alive, Host=localhost:8555, User-Agent=Java/1.5.0_07, cgi.headers={SCRIPT_NAME=, SERVER_PROTOCOL=HTTP/1.1, SERVER_PORT=8555, PATH_INFO=/, REMOTE_ADDR=127.0.0.1, REQUEST_METHOD=POST, PATH_TRANSLATED=null, REQUEST_URI=http://localhost:8555/, CONTENT_LENGTH=287, AUTH_TYPE=null, QUERY_STRING=null, REMOTE_USER=null, DOCUMENT_ROOT=null, SERVER_NAME=localhost, CONTENT_TYPE=application/x-www-form-urlencoded, REMOTE_HOST=127.0.0.1}, Content-Type=application/x-www-form-urlencoded, Accept=text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2}} Message:<?xml version="1.0" encoding="UTF-8"?><ns1:getQuote xmlns:ns1="urn:xmethods-delayed-quotes" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:se="http://schemas.xmlsoap.org/soap/envelope/" se:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <symbol xsi:type="xsd:string">IBM</symbol> </ns1:getQuote> resolver---->[EMAIL PROTECTED] resolver----++>[EMAIL PROTECTED] destinationServiceEndpoint[service={http://servicemix.org/example/}receiver,endpoint=receiver] -------------->inside receiver on message exchange 11:10:01,288 ERROR [SedaQueue] [EMAIL PROTECTED] got error processing null javax.jbi.messaging.MessagingException: illegal exchange status: done at org.apache.servicemix.jbi.messaging.MessageExchangeImpl.handleSend(MessageExchangeImpl.java:580) at org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.doSend(DeliveryChannelImpl.java:363) at org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.send(DeliveryChannelImpl.java:410) at org.apache.servicemix.components.util.PojoSupport.done(PojoSupport.java:218) at com.jeffhanson.esb.servicemix.ReceiverComponent.onMessageExchange(ReceiverComponent.java:59) at org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(DeliveryChannelImpl.java:622) at org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:168) at org.apache.servicemix.jbi.nmr.flow.seda.SedaFlow.doRouting(SedaFlow.java:176) at org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.java:226) at org.apache.geronimo.connector.work.WorkerContext.run(WorkerContext.java:291) at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Thread.java:595) Can any one help me out in this regard................. -- View this message in context: http://www.nabble.com/ProcessInOut-in-HttpInOutBinding-Error-tf2348880.html#a6540609 Sent from the ServiceMix - User mailing list archive at Nabble.com.
