The problem is resolved !
The response given here helps me :
http://www.nabble.com/question-about-http-consumer-tf3756165s12049.html#a10616138
It seems you must test the exchange status before process the exchange.
So, by adding the import import javax.jbi.messaging.ExchangeStatus in the
groovy code, I've added the followin instruction :
if (exchange.status == ExchangeStatus.DONE) return
Here the complete process method :
def void process(MessageExchange exchange) {
if (exchange.status == ExchangeStatus.DONE) return
def inputMessage = new
SourceTransformer().toString(exchange.getInMessage().getContent())
println "Hello, I got an input message "+inputMessage
NormalizedMessage out = exchange.createMessage()
out.setContent(new StringSource("<world>Salut !</world>"))
exchange.setMessage(out, "out")
exchangeHelper.sendExchange(exchange)
}
The groovy code in the page
http://incubator.apache.org/servicemix/servicemix-script.html sould be
changed !
Bertrand Goetzmann.
http://www.odelia-technologies.com/
bgoetzmann wrote:
>
> Hello,
>
> I've succeeded to call my ServiceMix (3.1) service written in Groovy (the
> code and the deployment mode is identical to those from
> http://incubator.apache.org/servicemix/servicemix-script.html), in using
> an HTTP endpoint ; when this endpoint receives an JBI message the message
> is transferred to the Groovy service.
> My client is a simple HTML page that uses AJAX to "post" an XML document
> to the HTTP component.
> I get the response coming from the Groovy service (that displyas "Hello, I
> got an input message <?xml version="1.0" encoding="UTF-8"?><test/>" on the
> concole), but in the console there is an exception :
>
> Hello, I got an input message <?xml version="1.0"
> encoding="UTF-8"?><test/>
> ERROR - ScriptComponent - Error processing exchange InOut[
> id: ID:bgoetzmann-1274-1180891481645-2:0
> status: Done
> role: provider
> service: {urn:test}groovy
> endpoint: endpoint
> in: Unable to display: org.mortbay.jetty.EofException
> out: <?xml version="1.0" encoding="UTF-8"?><world>Salut !</world>
> ]
> javax.xml.transform.TransformerException: org.mortbay.jetty.EofException
> at
> org.apache.xalan.transformer.TransformerIdentityImpl.transform(Transf
> ormerIdentityImpl.java:505)
> at
> org.apache.servicemix.jbi.jaxp.SourceTransformer.toResult(SourceTrans
> former.java:85)
> at
> org.apache.servicemix.jbi.jaxp.SourceTransformer.toString(SourceTrans
> former.java:101)
> at
> gjdk.org.apache.servicemix.jbi.jaxp.SourceTransformer_GroovyReflector
> .invoke(Unknown Source)
> at groovy.lang.MetaMethod.invoke(MetaMethod.java:111)
> at
> org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassH
> elper.java:584)
> at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:345)
> at
> org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:144)
> at
> org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.
> java:104)
> at
> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethod(Script
> BytecodeAdapter.java:85)
> at GroovyExchangeProcessor.process(script1180891489206.groovy:33)
> at
> org.apache.servicemix.script.ScriptExchangeProcessorEndpoint.process(
> ScriptExchangeProcessorEndpoint.java:106)
> at
> org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLi
> feCycle.java:489)
>
> ...
>
> ERROR - ScriptComponent - Error setting exchange status to
> ERROR
> javax.jbi.messaging.MessagingException: illegal call to send / sendSync
> at
> org.apache.servicemix.jbi.messaging.MessageExchangeImpl.handleSend(Me
> ssageExchangeImpl.java:571)
> at
> org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.doSend(Delive
> ryChannelImpl.java:370)
> at
> org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.send(Delivery
> ChannelImpl.java:417)
> at
> org.apache.servicemix.common.BaseLifeCycle.onMessageExchange(BaseLife
> Cycle.java:58)
> at
> org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBoun
> d(DeliveryChannelImpl.java:593)
> at
> org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlo
> w.java:174)
> at
> org.apache.servicemix.jbi.nmr.flow.seda.SedaFlow.doRouting(SedaFlow.j
>
> Any idea of the origine of this exception ? Thank you for any help !
>
>
> Bertrand Goetzmann.
> http://www.odelia-technologies.com/
>
>
--
View this message in context:
http://www.nabble.com/Calling-my-component-Groovy-service-in-AJAX...-tf3861303s12049.html#a10947337
Sent from the ServiceMix - User mailing list archive at Nabble.com.