You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by allfonsiva <al...@aim.com> on 2006/09/28 07:45:59 UTC

ProcessInOut in HttpInOutBinding Error

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 {@link InOut} exchange with
JBI and returns the response
 * by default but is configurable to be an {@link 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 {@link InOut} request otherwise it
will be assumed to be an {@link InOnly}
     */
    protected boolean isInOutRequest(HttpServletRequest request,
HttpServletResponse response) {
        return isDefaultInOut();
    }


}



The error i am getting is........


:INFO:  Started SocketConnector @ localhost:8555
destination--->null
resolver---->org.apache.servicemix.jbi.resolver.ServiceNameEndpointResolver@d08633
destination---->ServiceEndpoint[service={http://servicemix.org/example/}receiver,endpoint=receiver]
************************************ inside process inout
process inout
Message:org.apache.servicemix.jbi.messaging.NormalizedMessageImpl@785d65{properties:
{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---->org.apache.servicemix.jbi.resolver.ServiceNameEndpointResolver@c39a20
resolver----++>org.apache.servicemix.jbi.resolver.ServiceNameEndpointResolver@c39a20
destinationServiceEndpoint[service={http://servicemix.org/example/}receiver,endpoint=receiver]
-------------->inside receiver on message exchange
11:10:01,288 ERROR [SedaQueue]
org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1@14e3f41 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.


Re: ProcessInOut in HttpInOutBinding Error

Posted by allfonsiva <al...@aim.com>.
hi gnodet,

 thanks now i changed my cod. the problem in my code is done exchange should
not be given there in processInOut method.

 now my http component is sending my xml message from my client to my
receiver component. but while printing that received message i cant able to
reproduce my exact xml.

My onmessageExchange in receiver is:

 public void onMessageExchange(MessageExchange exchange)
      throws MessagingException
   {
       
   	System.out.println("inside receiver on message exchange");
	       
      NormalizedMessage inMessage = exchange.getMessage("in");
      SourceTransformer sourceTransformer= new SourceTransformer();
      
      
      if (inMessage == null)
      {
         throw new MessagingException("Null in message delivered!");
      }
    
      try {
       
System.out.println("\nMessage:"+sourceTransformer.toString(inMessage.getContent()));
    } catch (TransformerException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
      messageList.addMessage(inMessage);
      done(exchange);
     
   }



error i caught is.....



javax.xml.transform.TransformerException: org.mortbay.jetty.EofException
	at
org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:505)
	at
org.apache.servicemix.jbi.jaxp.SourceTransformer.toResult(SourceTransformer.java:84)
	at
org.apache.servicemix.jbi.jaxp.SourceTransformer.toString(SourceTransformer.java:104)
	at
com.jeffhanson.esb.servicemix.ReceiverComponent.onMessageExchange(ReceiverComponent.java:76)
	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)
Caused by: org.mortbay.jetty.EofException
	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:266)
	at org.mortbay.jetty.HttpParser$Input.blockForContent(HttpParser.java:839)
	at org.mortbay.jetty.HttpParser$Input.read(HttpParser.java:897)
	at org.apache.xerces.utils.ChunkyByteArray.fill(ChunkyByteArray.java:222)
	at org.apache.xerces.utils.ChunkyByteArray.<init>(ChunkyByteArray.java:98)
	at
org.apache.xerces.readers.DefaultReaderFactory.createReader(DefaultReaderFactory.java:153)
	at
org.apache.xerces.readers.DefaultEntityHandler.startReadingFromDocument(DefaultEntityHandler.java:493)
	at org.apache.xerces.framework.XMLParser.parseSomeSetup(XMLParser.java:314)
	at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1097)
	at
org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:484)
	... 10 more
Caused by: java.net.SocketException: Socket closed
	at java.net.SocketInputStream.socketRead0(Native Method)
	at java.net.SocketInputStream.read(SocketInputStream.java:147)
	at org.mortbay.io.bio.StreamEndPoint.fill(StreamEndPoint.java:99)
	at
org.mortbay.jetty.bio.SocketConnector$Connection.fill(SocketConnector.java:157)
	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:258)
	... 19 more
---------
org.mortbay.jetty.EofException
	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:266)
	at org.mortbay.jetty.HttpParser$Input.blockForContent(HttpParser.java:839)
	at org.mortbay.jetty.HttpParser$Input.read(HttpParser.java:897)
	at org.apache.xerces.utils.ChunkyByteArray.fill(ChunkyByteArray.java:222)
	at org.apache.xerces.utils.ChunkyByteArray.<init>(ChunkyByteArray.java:98)
	at
org.apache.xerces.readers.DefaultReaderFactory.createReader(DefaultReaderFactory.java:153)
	at
org.apache.xerces.readers.DefaultEntityHandler.startReadingFromDocument(DefaultEntityHandler.java:493)
	at org.apache.xerces.framework.XMLParser.parseSomeSetup(XMLParser.java:314)
	at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1097)
	at
org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:484)
	at
org.apache.servicemix.jbi.jaxp.SourceTransformer.toResult(SourceTransformer.java:84)
	at
org.apache.servicemix.jbi.jaxp.SourceTransformer.toString(SourceTransformer.java:104)
	at
com.jeffhanson.esb.servicemix.ReceiverComponent.onMessageExchange(ReceiverComponent.java:76)
	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)
Caused by: java.net.SocketException: Socket closed
	at java.net.SocketInputStream.socketRead0(Native Method)
	at java.net.SocketInputStream.read(SocketInputStream.java:147)
	at org.mortbay.io.bio.StreamEndPoint.fill(StreamEndPoint.java:99)
	at
org.mortbay.jetty.bio.SocketConnector$Connection.fill(SocketConnector.java:157)




gnodet wrote:
> 
> The "illegal exchange status: done" means that
> the messages / status for the exchange are wrong.
> For example, if the example is in ERROR satus,
> you can not send a DONE status.
> 
> The origianl processInOut method was handling
> error properly.  I suggest you take a new look
> at it and rewrite your code according to it.
> 
> On 9/28/06, allfonsiva <al...@aim.com> wrote:
>>
>> 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 {@link InOut} exchange with
>> JBI and returns the response
>>  * by default but is configurable to be an {@link 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 {@link InOut} request otherwise
>> it
>> will be assumed to be an {@link InOnly}
>>      */
>>     protected boolean isInOutRequest(HttpServletRequest request,
>> HttpServletResponse response) {
>>         return isDefaultInOut();
>>     }
>>
>>
>> }
>>
>>
>>
>> The error i am getting is........
>>
>>
>> :INFO:  Started SocketConnector @ localhost:8555
>> destination--->null
>> resolver---->org.apache.servicemix.jbi.resolver.ServiceNameEndpointResolver@d08633
>> destination---->ServiceEndpoint[service={http://servicemix.org/example/}receiver,endpoint=receiver]
>> ************************************ inside process inout
>> process inout
>> Message:org.apache.servicemix.jbi.messaging.NormalizedMessageImpl@785d65{properties:
>> {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---->org.apache.servicemix.jbi.resolver.ServiceNameEndpointResolver@c39a20
>> resolver----++>org.apache.servicemix.jbi.resolver.ServiceNameEndpointResolver@c39a20
>> destinationServiceEndpoint[service={http://servicemix.org/example/}receiver,endpoint=receiver]
>> -------------->inside receiver on message exchange
>> 11:10:01,288 ERROR [SedaQueue]
>> org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1@14e3f41 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.
>>
>>
> 
> 
> -- 
> Cheers,
> Guillaume Nodet
> 
> 

-- 
View this message in context: http://www.nabble.com/ProcessInOut-in-HttpInOutBinding-Error-tf2348880.html#a6542499
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: ProcessInOut in HttpInOutBinding Error

Posted by Guillaume Nodet <gn...@gmail.com>.
The "illegal exchange status: done" means that
the messages / status for the exchange are wrong.
For example, if the example is in ERROR satus,
you can not send a DONE status.

The origianl processInOut method was handling
error properly.  I suggest you take a new look
at it and rewrite your code according to it.

On 9/28/06, allfonsiva <al...@aim.com> wrote:
>
> 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 {@link InOut} exchange with
> JBI and returns the response
>  * by default but is configurable to be an {@link 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 {@link InOut} request otherwise it
> will be assumed to be an {@link InOnly}
>      */
>     protected boolean isInOutRequest(HttpServletRequest request,
> HttpServletResponse response) {
>         return isDefaultInOut();
>     }
>
>
> }
>
>
>
> The error i am getting is........
>
>
> :INFO:  Started SocketConnector @ localhost:8555
> destination--->null
> resolver---->org.apache.servicemix.jbi.resolver.ServiceNameEndpointResolver@d08633
> destination---->ServiceEndpoint[service={http://servicemix.org/example/}receiver,endpoint=receiver]
> ************************************ inside process inout
> process inout
> Message:org.apache.servicemix.jbi.messaging.NormalizedMessageImpl@785d65{properties:
> {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---->org.apache.servicemix.jbi.resolver.ServiceNameEndpointResolver@c39a20
> resolver----++>org.apache.servicemix.jbi.resolver.ServiceNameEndpointResolver@c39a20
> destinationServiceEndpoint[service={http://servicemix.org/example/}receiver,endpoint=receiver]
> -------------->inside receiver on message exchange
> 11:10:01,288 ERROR [SedaQueue]
> org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1@14e3f41 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.
>
>


-- 
Cheers,
Guillaume Nodet