You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Liav Ezer <li...@gmail.com> on 2009/01/08 13:46:25 UTC

How do i call an HTTP Provider end-pont from the process method?

Hi,

Here is my camel-context:

  <camelContext id="camel"
xmlns="http://activemq.apache.org/camel/schema/spring">
    <package>org.apache.servicemix.tutorial.camel</package>
  </camelContext>
  
  <bean id="myProcessor"
class="org.apache.servicemix.tutorial.camel.MyProcessor"/>

Here is my RouteBuilder java file:

public class MyRouteBuilder extends RouteBuilder {
	public void configure() {
    	from("timer://tutorial?fixedRate=true&delay=3000&period=10000")  
        	.setBody(constant(".....................Liav Camel
POC......................."))
        		.to("myProcessor");
    	
    }
}

Here is my processor java file:
public class MyProcessor implements Processor {
	  public void process(Exchange exchange) throws Exception {
	      //WANT TO INITIATE A CALL TO http pROVIDER END POINT & PASS THE
'FROM'
                  // PARAMETRS RECIEVED PROIRE TO THE PROCESSOR INVOKE.	  }
}

Thanks.
-- 
View this message in context: http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21351142.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: How do i call an HTTP Provider end-pont from the process method?

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

On Fri, Jan 9, 2009 at 3:25 AM, Willem Jiang <wi...@gmail.com> wrote:
> Hi ,
>
> How about using the camel http producer directly ?
>
>  from("timer://tutorial?fixedRate=true&delay=3000&period=10000")
>                .setBody(constant(".....................Liav Camel
>  POC.......................")).to("http://YourHttpEndpointAddress");
>
> Willem
>
> Claus Ibsen wrote:
>> Hi
>>
>> You can use the producer template to call an external http server and
>> get the response.
>>
>> See this tutorial:
>> http://activemq.apache.org/camel/tutorial-axis-camel.html
>>
>>>>From the section - integrating Camel
>>
>> Its kinda the same but its just uses the producer template to save a
>> file. Its the same API for using any of the camel components.
>>
>> Little sidenote:
>> And since you use InOut you should use: requestBody instread of
>> sendBody. However Camel is not to stricky about this yet so if you use
>> a send instead of request then it should work as well.
>>
>> The demo shows how to inject a producer template from spring into your
>> bean class = your processor. when you have this template you can call
>> the external http server and get the response using the requestBody
>> method.
>>
>>
>>
>>
>>
>>
>>
>> On Thu, Jan 8, 2009 at 1:46 PM, Liav Ezer <li...@gmail.com> wrote:
>>> Hi,
>>>
>>> Here is my camel-context:
>>>
>>>  <camelContext id="camel"
>>> xmlns="http://activemq.apache.org/camel/schema/spring">
>>>    <package>org.apache.servicemix.tutorial.camel</package>
>>>  </camelContext>
>>>
>>>  <bean id="myProcessor"
>>> class="org.apache.servicemix.tutorial.camel.MyProcessor"/>
>>>
>>> Here is my RouteBuilder java file:
>>>
>>> public class MyRouteBuilder extends RouteBuilder {
>>>        public void configure() {
>>>        from("timer://tutorial?fixedRate=true&delay=3000&period=10000")
>>>                .setBody(constant(".....................Liav Camel
>>> POC......................."))
>>>                        .to("myProcessor");
>>>
>>>    }
>>> }
>>>
>>> Here is my processor java file:
>>> public class MyProcessor implements Processor {
>>>          public void process(Exchange exchange) throws Exception {
>>>              //WANT TO INITIATE A CALL TO http pROVIDER END POINT & PASS THE
>>> 'FROM'
>>>                  // PARAMETRS RECIEVED PROIRE TO THE PROCESSOR INVOKE.   }
>>> }
>>>
>>> Thanks.
>>> --
>>> View this message in context: http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21351142.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>
>



-- 

/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/

Re: How do i call an HTTP Provider end-pont from the process method?

Posted by Willem Jiang <wi...@gmail.com>.
Hi ,

How about using the camel http producer directly ?

 from("timer://tutorial?fixedRate=true&delay=3000&period=10000")
                .setBody(constant(".....................Liav Camel
 POC.......................")).to("http://YourHttpEndpointAddress");

Willem

Claus Ibsen wrote:
> Hi
> 
> You can use the producer template to call an external http server and
> get the response.
> 
> See this tutorial:
> http://activemq.apache.org/camel/tutorial-axis-camel.html
> 
>>>From the section - integrating Camel
> 
> Its kinda the same but its just uses the producer template to save a
> file. Its the same API for using any of the camel components.
> 
> Little sidenote:
> And since you use InOut you should use: requestBody instread of
> sendBody. However Camel is not to stricky about this yet so if you use
> a send instead of request then it should work as well.
> 
> The demo shows how to inject a producer template from spring into your
> bean class = your processor. when you have this template you can call
> the external http server and get the response using the requestBody
> method.
> 
> 
> 
> 
> 
> 
> 
> On Thu, Jan 8, 2009 at 1:46 PM, Liav Ezer <li...@gmail.com> wrote:
>> Hi,
>>
>> Here is my camel-context:
>>
>>  <camelContext id="camel"
>> xmlns="http://activemq.apache.org/camel/schema/spring">
>>    <package>org.apache.servicemix.tutorial.camel</package>
>>  </camelContext>
>>
>>  <bean id="myProcessor"
>> class="org.apache.servicemix.tutorial.camel.MyProcessor"/>
>>
>> Here is my RouteBuilder java file:
>>
>> public class MyRouteBuilder extends RouteBuilder {
>>        public void configure() {
>>        from("timer://tutorial?fixedRate=true&delay=3000&period=10000")
>>                .setBody(constant(".....................Liav Camel
>> POC......................."))
>>                        .to("myProcessor");
>>
>>    }
>> }
>>
>> Here is my processor java file:
>> public class MyProcessor implements Processor {
>>          public void process(Exchange exchange) throws Exception {
>>              //WANT TO INITIATE A CALL TO http pROVIDER END POINT & PASS THE
>> 'FROM'
>>                  // PARAMETRS RECIEVED PROIRE TO THE PROCESSOR INVOKE.   }
>> }
>>
>> Thanks.
>> --
>> View this message in context: http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21351142.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 


Re: How do i call an HTTP Provider end-pont from the process method?

Posted by Gert Vanthienen <ge...@skynet.be>.
Liav,

The <ns1:hostname> bit is the detail message for the SOAP fault.  Could 
you check the Tomcat logs to see if you can find any additional 
information about why the SOAP call failed?
If there's nothing there, we can also try to use WireShark or a similar 
tool to check what the HTTP request and response look like -- there 
should be more information there.
Looking at it again, you might need to specify a SOAPAction or 
operation, but we should learn more from the logging and/or network trace.

Regards,

Gert

Liav Ezer schreef:
> Hi Gert,
>
> My WS is LiavHelloImplSvc deployed under Tomcat 6.0 at 8080 port.
> Well i thought that my WS is causing the problem & inserted a breakpoint but
> it's not even invoked hence no output what so ever in my Tomcat console.
>
> Something "configi" is wrong here.
>
> By the way, i tried adding the below bolded attribute (after reading some
> thread) & got an exception of other type:
>
> <http:endpoint service="wsn:LiavHelloImplSvcService"
>                  endpoint="wsn:LiavHelloImplSvc"
>                  role="provider"
>                 
> locationURI="http://localhost:8080/LiavHello2/services/LiavHelloImplSvc"
>                 
> wsdlResource="c:/HTTPReceiverServices/LiavHelloImplSvc.wsdl"
>                  defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>                  soap="true" 
>                  soapVersion="1.1"/>
>
> Exception:
> DEBUG - SedaQueue                      -
> org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1@1f55780 dequeued
> exchange: InOut[
>   id: ID:10.236.11.194-11eca7dd5b2-2:39
>   status: Active
>   role: consumer
>   service: {http://com.liav.oxp/esb}LiavHelloImplSvcService
>   endpoint: wsn:LiavHelloImplSvc
>   in: <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:q0="http://service.app.esb.oxp.liav.com" xmlns:xsd="
> http://www.w3.org/2001/XMLSchema"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><q0:sayHello><q0:name>LiavFromRouterBuilder</q0:name></q0:sayHello></soapenv:B
> ody></soapenv:Envelope>
>   fault: <?xml version="1.0" encoding="UTF-8"?><ns1:hostname
> xmlns:ns1="http://xml.apache.org/axis/">LIAVE02</ns1:hostname>]
>
>
>
> Gert Vanthienen wrote:
>   
>> Liav,
>>
>> It looks like the HTTP provider endpoint did invoke you remote (i.e. 
>> http://localhost:8080/...) web service now, but it got some unexpected 
>> exception back.  Could you check the log for the Jetty or whatever 
>> server that is running the web service to see what went wrong there?
>>
>> Regards,
>>
>> Gert
>>
>> Liav Ezer schreef:
>>     
>>> Hi Claus,
>>>
>>> I noticed that i use an InOnly & tries changing it via the original
>>> Exchange
>>> object with no success.
>>>
>>> Using you methode (requestBody), i get the following exception:
>>>
>>> ERROR - HttpComponent                  - Error processing exchange InOut[
>>>   id: ID:10.236.11.194-11eca7dd5b2-2:24
>>>   status: Active
>>>   role: provider
>>>   service: {http://com.liav.oxp/esb}LiavHelloImplSvcService
>>>   endpoint: wsn:LiavHelloImplSvc
>>>   in: <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
>>> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
>>> xmlns:q0="http://service.app.esb.oxp.liav.com" xmlns:xsd="
>>> http://www.w3.org/2001/XMLSchema"
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><q0:sayHello><q0:name>LiavFromRouterBuilder</q0:name></q0:sayHello></soapenv:B
>>> ody></soapenv:Envelope>
>>> ]
>>> org.apache.servicemix.soap.SoapFault: Unexpected fault code:
>>> {http://www.w3.org/2003/05/soap-envelope}Server.userException        at
>>> org.apache.servicemix.soap.marshalers.SoapReader.readFaultUsingDom(SoapReader.java:259)
>>>         at
>>> org.apache.servicemix.soap.marshalers.SoapReader.readFaultUsingStax(SoapReader.java:341)
>>>         at
>>> org.apache.servicemix.soap.marshalers.SoapReader.readSoapUsingStax(SoapReader.java:203)
>>>         at
>>> org.apache.servicemix.soap.marshalers.SoapReader.read(SoapReader.java:89)
>>>         at
>>> org.apache.servicemix.soap.marshalers.SoapReader.read(SoapReader.java:76)
>>>         at
>>> org.apache.servicemix.http.processors.ProviderProcessor.process(ProviderProcessor.java:182)
>>>         at
>>> org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLifeCycle.java:540)
>>>         at
>>> org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(AsyncBaseLifeCycle.java:492)
>>>         at
>>> org.apache.servicemix.common.BaseLifeCycle.onMessageExchange(BaseLifeCycle.java:46)
>>>         at
>>> org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(DeliveryChannelImpl.java:610)
>>>         at
>>> org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:172)
>>>         at
>>> org.apache.servicemix.jbi.nmr.flow.seda.SedaFlow.doRouting(SedaFlow.java:167)
>>>         at
>>> org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.java:134)
>>>         at
>>> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
>>>         at
>>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
>>>         at java.lang.Thread.run(Thread.java:595)
>>>
>>> My Code:
>>>
>>> ProducerTemplate producerTemplate =
>>> exchange.getContext().createProducerTemplate();
>>>
>>> String body = "<soapenv:Envelope
>>> xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'
>>> xmlns:q0='http://service.app.esb.oxp.liav.com'
>>> xmlns:xsd='http://www.w3.org/2001/XMLSchema'
>>> xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><soapenv:Body><q0:sayHello><q0:name>LIAV</q0:name></q0:sayHello></soapenv:Body></soapenv:Envelope>";
>>>
>>> Object response =
>>> producerTemplate.requestBody("jbi:service:http://com.liav.oxp/esb/LiavHelloImplSvcService",
>>> body);
>>>
>>> Is it related again to my API or maybe it's a wrong use of my 'body'
>>> string?
>>>
>>> Thanks.
>>>
>>> Claus Ibsen-2 wrote:
>>>   
>>>       
>>>> Hi
>>>>
>>>> SMX is more strict with setting the correct exchange pattern
>>>> - InOnly
>>>> - InOut
>>>> etc
>>>>
>>>> We get this from the log
>>>>     
>>>>         
>>>>> Error processing exchange InOnly
>>>>>       
>>>>>           
>>>> So you should use InOut from Camel as its a http component that
>>>> expects an InOut exchange pattern
>>>>
>>>> This is done by using the requestBody method instread of sendBody in
>>>> the producer template
>>>>
>>>> So it should be:
>>>> producer.requestBody("jbi:service:http://com.liav.oxp/esb/LiavHelloImplSvcService",
>>>> request);
>>>>
>>>>
>>>>
>>>> On Mon, Jan 12, 2009 at 12:03 PM, Liav Ezer <li...@gmail.com> wrote:
>>>>     
>>>>         
>>>>> Hi Claus,
>>>>>
>>>>> Ok, I progressed a bit but still has the a problem consuming my WS.
>>>>>
>>>>> Here is my Processor code (producer.sendBody() first arg' has changed).
>>>>>
>>>>> public void process(Exchange exchange) throws Exception {
>>>>>          ProducerTemplate producer =
>>>>> exchange.getContext().createProducerTemplate();
>>>>>          String payload = exchange.getIn().getBody(String.class); // ==
>>>>> liav
>>>>>          String request = "<?xml version=\"1.0\"
>>>>> encoding=\"UTF-8\"?><soapenv:Body><sayHello><name>"+payload+"</name></sayHello></soapenv:Body>";
>>>>>          Object response =
>>>>> producer.sendBody("jbi:service:http://com.liav.oxp/esb/LiavHelloImplSvcService",
>>>>> request);
>>>>> }
>>>>>
>>>>> This is the xbean of the SMX http Provider:
>>>>>
>>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>>> <beans xmlns:http="http://servicemix.apache.org/http/1.0"
>>>>>       xmlns:wsn="http://com.liav.oxp/esb"
>>>>>       xmlns="http://www.springframework.org/schema/beans"
>>>>>       xmlns:xsi="http://http://www.w3.org/2001/XMLSchema-instance"
>>>>>       xsi:schemaLocation="http://servicemix.apache.org/http/1.0
>>>>> http://servicemix.apache.org/schema/servicemix-http-3.3.1.3-fuse.xsd
>>>>>       http://www.springframework.org/schema/beans
>>>>> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
>>>>>
>>>>>           <http:endpoint service="wsn:LiavHelloImplSvcService"
>>>>>                 endpoint="wsn:LiavHelloImplSvc"
>>>>>                 role="provider"
>>>>>
>>>>> locationURI="http://localhost:8080/LiavHello2/services/LiavHelloImplSvc"
>>>>>
>>>>> wsdlResource="c:/HTTPReceiverServices/LiavHelloImplSvc.wsdl"
>>>>>                 defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>>>>                 soap="true" />
>>>>> </beans>
>>>>>
>>>>> My question:
>>>>>
>>>>> By looking at the end-point invoke (via the producerTemplate) & at the
>>>>> end-point config (xbean file),
>>>>>
>>>>> do you see a reason why my WS (LiavHelloImplSvcService) isn't consumed?
>>>>>
>>>>> Here is the current SMX log after deployment:
>>>>>
>>>>> ERROR - HttpComponent                  - Error processing exchange
>>>>> InOnly[
>>>>>  id: ID:10.236.11.194-11eca7dd5b2-2:8
>>>>>  status: Active
>>>>>  role: provider
>>>>>  service: {http://com.liav.oxp/esb}LiavHelloImplSvcService
>>>>>  endpoint: wsn:LiavHelloImplSvc
>>>>>  in: <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
>>>>> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
>>>>> xmlns:q0="http://service.app.esb.oxp.liav.com" xmlns:xsd="
>>>>> http://www.w3.org/2001/XMLSchema"
>>>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><q0:sayHello><q0:name>LiavFromRouterBuilder</q0:name></q0:sayHello></soapenv:B
>>>>> ody></soapenv:Envelope>
>>>>> ]
>>>>> java.lang.Exception: Invalid status response: 500
>>>>> Thanks.
>>>>>
>>>>> Liav Ezer wrote:
>>>>>       
>>>>>           
>>>>>> Hi Claus,
>>>>>>
>>>>>> What i managed to accomplish is that my producer is 'familiar' with my
>>>>>> Provider end-point but from some reason it doesn't invoke my service
>>>>>> (WS)
>>>>>> & hence report an invalide status response (500).
>>>>>>
>>>>>> ERROR - HttpComponent                  - Error processing exchange
>>>>>> InOnly[
>>>>>>   id: ID:10.236.11.194-11ec622522e-2:96
>>>>>>   status: Active
>>>>>>   role: provider
>>>>>>   service: {http://com.liav.oxp/esb}LiavHelloImplSvcService
>>>>>>   endpoint: wsn:LiavHelloImplSvc
>>>>>>   in: <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
>>>>>> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
>>>>>> xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http
>>>>>> ://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><sayHello><name>Liav</name></sayHello></soapenv:Body></soapenv:Envelope>
>>>>>> ]
>>>>>>
>>>>>> This is my xbean.xml (it must be related to the end-point
>>>>>> configuration):
>>>>>>
>>>>>> <http:endpoint service="wsn:LiavHelloImplSvcService"
>>>>>>                  endpoint="wsn:LiavHelloImplSvc"
>>>>>>                  role="provider"
>>>>>>
>>>>>> locationURI="http://localhost:8080/LiavHello2/services/LiavHelloImplSvc"
>>>>>>
>>>>>> wsdlResource="c:/HTTPReceiverServices/LiavHelloImplSvc.wsdl"
>>>>>>                  defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>>>>>                  soap="true" />
>>>>>>
>>>>>> Thanks.
>>>>>> java.lang.Exception: Invalid status response: 500
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> Liav Ezer wrote:
>>>>>>         
>>>>>>             
>>>>>>> Hi Claus,
>>>>>>>
>>>>>>> I'm stuck with a problem that my servixmix is reporting a try to send
>>>>>>> a
>>>>>>> request to the provider but appearantly it's not able to consume the
>>>>>>> Provider's WS.
>>>>>>>
>>>>>>> Here is the console:
>>>>>>>
>>>>>>> ERROR - DeadLetterChannel              - Failed delivery for
>>>>>>> exchangeId:
>>>>>>> ID-LIAVE02/1441-1231673232762/0-2. On delivery attempt: 0 caught:
>>>>>>> org.apache.camel.RuntimeCamelException: o
>>>>>>> rg.apache.servicemix.camel.JbiException:
>>>>>>> javax.jbi.messaging.MessagingException: Could not find route for
>>>>>>> exchange: InOnly[
>>>>>>>   id: ID:10.236.11.194-11ec5713753-2:7
>>>>>>>   status: Active
>>>>>>>   role: provider
>>>>>>> in: <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
>>>>>>> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
>>>>>>> xmlns:q0="http://service.app.esb.oxp.liav.com" xmlns:xsd="
>>>>>>> http://www.w3.org/2001/XMLSchema"
>>>>>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><q0:sayHello><q0:name>liav-name</q0:name>
>>>>>>> </q0:sayHello></soapenv:Body></soape
>>>>>>> nv:Envelope>
>>>>>>> ] for service: null and interface: null
>>>>>>>
>>>>>>> When i develpoed the WS i tested it via eclipse with success.
>>>>>>>
>>>>>>> Here is the xbean definition:
>>>>>>>
>>>>>>> <http:endpoint service="wsn:LiavHelloImplSvcService"
>>>>>>>                  endpoint="wsn:LiavHelloImplSvc"
>>>>>>>                  role="provider"
>>>>>>>
>>>>>>> locationURI="http://localhost:8080/LiavHello2/services/LiavHelloImplSvc"
>>>>>>>
>>>>>>> wsdlResource="c:/HTTPReceiverServices/LiavHelloImplSvc.wsdl"
>>>>>>>                  defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>>>>>>                  soap="true" />
>>>>>>>
>>>>>>> Why does it report null for the service & interface?
>>>>>>>
>>>>>>> Thanks.
>>>>>>>
>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>           
>>>>>>>               
>>>>>>>> On Sun, Jan 11, 2009 at 9:19 AM, Liav Ezer <li...@gmail.com>
>>>>>>>> wrote:
>>>>>>>>             
>>>>>>>>                 
>>>>>>>>> Hi Claus,
>>>>>>>>>
>>>>>>>>> Yes, i changed the body (arg2 in the sendBody method) to be a SOAP
>>>>>>>>> request
>>>>>>>>> like the following:
>>>>>>>>>
>>>>>>>>> String request = "<soapenv:Envelope
>>>>>>>>> xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'
>>>>>>>>> xmlns:q0='http://service.app.esb.oxp.liav.com'
>>>>>>>>> xmlns:xsd='http://www.w3.org/2001/XMLSchema'
>>>>>>>>> xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><soapenv:Body><q0:sayHello><q0:name>liav-name</q0:name>
>>>>>>>>> </q0:sayHello></soapenv:Body></soapenv:Envelope>";
>>>>>>>>>
>>>>>>>>> 1. Is it a correct payload to send a request?
>>>>>>>>>               
>>>>>>>>>                   
>>>>>>>> Yeah it should be something like that. You might need the <?xml
>>>>>>>> version...> header. But try with and without it.
>>>>>>>>
>>>>>>>>
>>>>>>>>             
>>>>>>>>                 
>>>>>>>>> 2. Does this method will return the provider response - The API
>>>>>>>>> shows
>>>>>>>>> that
>>>>>>>>> it returns an Object - should i cast it to be an 'Exchange' &
>>>>>>>>> extract
>>>>>>>>> the
>>>>>>>>> response from the provider?
>>>>>>>>>               
>>>>>>>>>                   
>>>>>>>> When you use Camel's producer template to do a request/reply then
>>>>>>>> Camel will extract the response from the Exchange/IN or OUT/Message,
>>>>>>>> so you just get the payload. The type is Object but it can be what
>>>>>>>> SMX
>>>>>>>> returns, so it could be some sort of XML holder such as
>>>>>>>> org.w3c.Document. But try and see what kind of Object you get back.
>>>>>>>>
>>>>>>>> There are type converters in Camel that can convert it back to a
>>>>>>>> String if you want to use that, or what else there is
>>>>>>>> http://activemq.apache.org/camel/type-converter.html
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>             
>>>>>>>>                 
>>>>>>>>> Thanks.
>>>>>>>>>
>>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>>               
>>>>>>>>>                   
>>>>>>>>>> On Sat, Jan 10, 2009 at 8:51 PM, Liav Ezer <li...@gmail.com>
>>>>>>>>>> wrote:
>>>>>>>>>>                 
>>>>>>>>>>                     
>>>>>>>>>>> Hi Claus,
>>>>>>>>>>>
>>>>>>>>>>> I changed the notation as needed to:
>>>>>>>>>>>
>>>>>>>>>>> producer.sendBody("jbi:endpoint:http://localhost:8080/LiavHello/services/LiavHelloImpl",
>>>>>>>>>>> "Netania");
>>>>>>>>>>>
>>>>>>>>>>>  SMX console now output some wierd error - googling it comes up
>>>>>>>>>>> with
>>>>>>>>>>> some
>>>>>>>>>>> xml parsing error:
>>>>>>>>>>>
>>>>>>>>>>> [Fatal Error] :1:1: Content is not allowed in prolog.DEBUG -
>>>>>>>>>>> DeliveryChannelImpl            - Exception processing:
>>>>>>>>>>> ID:10.236.11.194-11ec1f3a450-2:291 in
>>>>>>>>>>> DeliveryChannel{servicemix-camel}
>>>>>>>>>>> ERROR - DeadLetterChannel              - Failed delivery for
>>>>>>>>>>> exchangeId:
>>>>>>>>>>> ID-LIAVE02/4519-1231614935663/0-50. On delivery attempt: 0
>>>>>>>>>>> caught:
>>>>>>>>>>> org.apache
>>>>>>>>>>> org.apache.servicemix.camel.JbiException:
>>>>>>>>>>> javax.jbi.messaging.MessagingException: Could not find route for
>>>>>>>>>>> exchange:
>>>>>>>>>>> InOnly[
>>>>>>>>>>>  id: ID:10.236.11.194-11ec1f3a450-2:291
>>>>>>>>>>>  status: Active
>>>>>>>>>>>  role: provider
>>>>>>>>>>>                   
>>>>>>>>>>>                       
>>>>>>>>>> Yeah when you send data to SMX you must remember that its
>>>>>>>>>> expecting
>>>>>>>>>> the payload to be according to the JBI spec. in XML format. So you
>>>>>>>>>> should send the data as XML.
>>>>>>>>>>
>>>>>>>>>> "Content is not allowed in prolog" is a bit cryptical XML parser
>>>>>>>>>> error
>>>>>>>>>> stating that it could not find the <?xml ... ?> declaration in top
>>>>>>>>>> of
>>>>>>>>>> the content it was parsing.
>>>>>>>>>>
>>>>>>>>>> So you should send the payload as XML.
>>>>>>>>>>
>>>>>>>>>> BTW: Which version of SMX and Camel are you using? I think the
>>>>>>>>>> missing
>>>>>>>>>> method from X mails back could be because we added it in Camel
>>>>>>>>>> 1.4.0
>>>>>>>>>> (I think).
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                 
>>>>>>>>>>                     
>>>>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>>>>                   
>>>>>>>>>>>                       
>>>>>>>>>>>> This is the SMX Provider xbean:
>>>>>>>>>>>>
>>>>>>>>>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>>>>>>>>>> <beans xmlns:http="http://servicemix.apache.org/http/1.0"
>>>>>>>>>>>>        xmlns:wsn="http://com.liav.oxp/esb"
>>>>>>>>>>>>        xmlns="http://www.springframework.org/schema/beans"
>>>>>>>>>>>>       
>>>>>>>>>>>> xmlns:xsi="http://http://www.w3.org/2001/XMLSchema-instance"
>>>>>>>>>>>>        xsi:schemaLocation="http://servicemix.apache.org/http/1.0
>>>>>>>>>>>> http://servicemix.apache.org/schema/servicemix-http-3.3.1.3-fuse.xsd
>>>>>>>>>>>>        http://www.springframework.org/schema/beans
>>>>>>>>>>>> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
>>>>>>>>>>>>
>>>>>>>>>>>>                 <http:endpoint
>>>>>>>>>>>> service="wsn:LiavHelloImplService"
>>>>>>>>>>>>                  endpoint="wsn:LiavHelloImpl"
>>>>>>>>>>>>                  role="provider"
>>>>>>>>>>>>
>>>>>>>>>>>> locationURI="http://localhost:8080/LiavHello/services/LiavHelloImpl"
>>>>>>>>>>>>
>>>>>>>>>>>> wsdlResource="c:/HTTPReceiverServices/LiavHelloImpl.wsdl"
>>>>>>>>>>>>                 
>>>>>>>>>>>> defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>>>>>>>>>>>                  soap="true" />
>>>>>>>>>>>> </beans>
>>>>>>>>>>>> Any clue?
>>>>>>>>>>>> On Sat, Jan 10, 2009 at 4:17 PM, Liav Ezer <li...@gmail.com>
>>>>>>>>>>>> wrote:
>>>>>>>>>>>>                     
>>>>>>>>>>>>                         
>>>>>>>>>>>>> Hi Claus,
>>>>>>>>>>>>>
>>>>>>>>>>>>> Well i'll stick with the Http SMX provider end-point. I guess
>>>>>>>>>>>>> it's
>>>>>>>>>>>>> should
>>>>>>>>>>>>> integrate with camel routing with no problem.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Ok what i did is the advise you gave me a few answers ago:
>>>>>>>>>>>>>
>>>>>>>>>>>>> ProducerTemplate producer =
>>>>>>>>>>>>> exchange.getContext().createProducerTemplate();
>>>>>>>>>>>>> Object response =
>>>>>>>>>>>>> producer.sendBody("http://localhost:8080/LiavHello/services/LiavHelloImpl",
>>>>>>>>>>>>> "Daviv");
>>>>>>>>>>>>>                       
>>>>>>>>>>>>>                           
>>>>>>>>>>>> See below
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                     
>>>>>>>>>>>>                         
>>>>>>>>>>>>> And got this exception (SMX console after deply):
>>>>>>>>>>>>>
>>>>>>>>>>>>> : No endpoint could be found for:
>>>>>>>>>>>>> http://localhost:8080/LiavHello/services/LiavHelloImpl
>>>>>>>>>>>>> org.apache.camel.NoSuchEndpointException: No endpoint could be
>>>>>>>>>>>>> found
>>>>>>>>>>>>> for:
>>>>>>>>>>>>> http://localhost:8080/LiavHello/services/LiavHelloImpl
>>>>>>>>>>>>>
>>>>>>>>>>>>> LiavHelloImpl is the wsdlsoap:address location of the wsdl file
>>>>>>>>>>>>> representing
>>>>>>>>>>>>> the LiavHelloImp web project (under a running tomcat 6.0).
>>>>>>>>>>>>>
>>>>>>>>>>>>> Can you advise? It seems that the routing trying to be
>>>>>>>>>>>>> accomplished
>>>>>>>>>>>>> but
>>>>>>>>>>>>> something "configi" is messed up.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Here is my provider xbean:
>>>>>>>>>>>>>
>>>>>>>>>>>>> <http:endpoint service="wsn:LiavHelloImplService"
>>>>>>>>>>>>>                 endpoint="wsn:LiavHelloImpl"
>>>>>>>>>>>>>                 role="provider"
>>>>>>>>>>>>>
>>>>>>>>>>>>> locationURI="http://localhost:8080/LiavHello/services/LiavHelloImpl"
>>>>>>>>>>>>>
>>>>>>>>>>>>> wsdlResource="c:/HTTPReceiverServices/LiavHelloImpl.wsdl"
>>>>>>>>>>>>>                
>>>>>>>>>>>>> defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>>>>>>>>>>>>                 soap="true" />
>>>>>>>>>>>>>                       
>>>>>>>>>>>>>                           
>>>>>>>>>>>> When you want from Camel to call service on SMX then you must
>>>>>>>>>>>> use
>>>>>>>>>>>> the
>>>>>>>>>>>> camel-jbi component that delegates to the SU in SMX.
>>>>>>>>>>>> So you need to add the jbi prefix in front.
>>>>>>>>>>>> See: http://activemq.apache.org/camel/jbi.html
>>>>>>>>>>>>
>>>>>>>>>>>> It should be something like this. By by all means I am not SMX
>>>>>>>>>>>> expert
>>>>>>>>>>>> (yet):
>>>>>>>>>>>> producer.sendBody("jbi:service:wsn:LiavHelloImplService",
>>>>>>>>>>>> "Daviv");
>>>>>>>>>>>>
>>>>>>>>>>>> The jbi component have different notation so please check it
>>>>>>>>>>>> out.
>>>>>>>>>>>>
>>>>>>>>>>>> If you manage to get it working, then please write back how to,
>>>>>>>>>>>> so
>>>>>>>>>>>> we
>>>>>>>>>>>> can improve the documentation and help others in the future.
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                     
>>>>>>>>>>>>                         
>>>>>>>>>>>>> Thanks!
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>>>>>>                       
>>>>>>>>>>>>>                           
>>>>>>>>>>>>>> On Sat, Jan 10, 2009 at 3:02 PM, Liav Ezer
>>>>>>>>>>>>>> <li...@gmail.com>
>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>                         
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>>>> Hi Claus,
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> I did follow this camel example & set up a timer 'from'
>>>>>>>>>>>>>>> end-point
>>>>>>>>>>>>>>> which
>>>>>>>>>>>>>>> my
>>>>>>>>>>>>>>> processor 'catched'.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> My will is to query this 'catched' data by sending it to a
>>>>>>>>>>>>>>> different
>>>>>>>>>>>>>>> end-point such as a service provider.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Therefore, i deployed two SU's in my servicemix: One for the
>>>>>>>>>>>>>>> camel
>>>>>>>>>>>>>>> routing
>>>>>>>>>>>>>>> (timer example) & two is for
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> the HTTP servicemix provider which i want to invoke in the
>>>>>>>>>>>>>>> proceesor.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> My question seems simple as long as an API exists for it:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> When my Processor class is instansiated than the process()
>>>>>>>>>>>>>>> method
>>>>>>>>>>>>>>> is
>>>>>>>>>>>>>>> invoked:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> public void process(Exchange exchange) throws Exception {
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> The exchange.getIn() consist my 'from' end-point data (=the
>>>>>>>>>>>>>>> timer).
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> I need the API to fetch the Http servicemix provider
>>>>>>>>>>>>>>> end-point
>>>>>>>>>>>>>>> &
>>>>>>>>>>>>>>> to
>>>>>>>>>>>>>>> send
>>>>>>>>>>>>>>> hime a request with this data.
>>>>>>>>>>>>>>>                           
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> If you want to send FROM Camel to SMX then you need to use the
>>>>>>>>>>>>>> camel-jbi component. That is you get endpoints FROM Camel
>>>>>>>>>>>>>> starting
>>>>>>>>>>>>>> with the "jbi:" prefix. See camel-jbi component.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                         
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>>>> One extra small question: Do i need to replace my provider SU
>>>>>>>>>>>>>>> with a
>>>>>>>>>>>>>>> camel
>>>>>>>>>>>>>>> http producer SU?
>>>>>>>>>>>>>>>                           
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> If you are using SMX 3.x then you dont as SMX has one SU for
>>>>>>>>>>>>>> Camel.
>>>>>>>>>>>>>> However if you need to use any of the other camel components
>>>>>>>>>>>>>> from
>>>>>>>>>>>>>> SMX
>>>>>>>>>>>>>> you need to have them in the classpath as well, such as
>>>>>>>>>>>>>> camel-http.jar.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> (In SMX 4.x its all OSGi land and you need to install features
>>>>>>>>>>>>>> into
>>>>>>>>>>>>>> SMX.)
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> A bit confused now. Which http provider do you want to use?
>>>>>>>>>>>>>> - SMX Http provider
>>>>>>>>>>>>>> - Camel http provider
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                         
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>>>> Thanks.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>>>>>>>>                           
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>>>> Hi
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Yeah its a bit mixed up since Camel and ServiceMix have
>>>>>>>>>>>>>>>> classes
>>>>>>>>>>>>>>>> with
>>>>>>>>>>>>>>>> common name: Endpoint, Exchange etc.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> All the code I have shown assumes pure Camel code.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> I advice to check the ServceMix docu about using Camel in
>>>>>>>>>>>>>>>> ServiceMix.
>>>>>>>>>>>>>>>> And get a basic example running. Such as this example
>>>>>>>>>>>>>>>> http://servicemix.apache.org/camel-example.html
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> You could use that as a starting point to get Camel invoking
>>>>>>>>>>>>>>>> your
>>>>>>>>>>>>>>>> HTTP
>>>>>>>>>>>>>>>> server. Just let the timer start it.
>>>>>>>>>>>>>>>> Then later your can connect using SMX instead of the camel
>>>>>>>>>>>>>>>> timer.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> On Sat, Jan 10, 2009 at 12:53 PM, Liav Ezer
>>>>>>>>>>>>>>>> <li...@gmail.com>
>>>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>>                             
>>>>>>>>>>>>>>>>                                 
>>>>>>>>>>>>>>>>> Hi Claus again,
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> I addition to what i asked in my previouse response here is
>>>>>>>>>>>>>>>>> a
>>>>>>>>>>>>>>>>> question
>>>>>>>>>>>>>>>>> regarding the producer snippet which you gave in your last
>>>>>>>>>>>>>>>>> answer:
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> I indeed wrote the following in my process() method:
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> ProducerTemplate producer =
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> exchange.getCamelContext().createProducerTemplate();
>>>>>>>>>>>>>>>>>                            Object response =
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> producer.sendBody("http://myserver.com/myapp?foo=bar",
>>>>>>>>>>>>>>>>> "Liav
>>>>>>>>>>>>>>>>> Camel
>>>>>>>>>>>>>>>>> POC");
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> but i don't have the camel context at hand (saying "The
>>>>>>>>>>>>>>>>> method
>>>>>>>>>>>>>>>>> getCamelContext() is undefined for the type Exchange").
>>>>>>>>>>>>>>>>>  & also do i need to deploy a camel http producer su
>>>>>>>>>>>>>>>>> instead
>>>>>>>>>>>>>>>>> of
>>>>>>>>>>>>>>>>> an
>>>>>>>>>>>>>>>>> http
>>>>>>>>>>>>>>>>> service mix provider?
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>>>>>                                   
>>>>>>>>>>>>>>>>>> Hi
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> When you are working with ServiceMix you must use the JBI
>>>>>>>>>>>>>>>>>> component
>>>>>>>>>>>>>>>>>> in
>>>>>>>>>>>>>>>>>> Camel
>>>>>>>>>>>>>>>>>> http://activemq.apache.org/camel/jbi.html
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> So your endpoints should starting with "jbi:XXXX"
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> And ServiceMix has some Camel docu here:
>>>>>>>>>>>>>>>>>> http://servicemix.apache.org/servicemix-camel.html
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> Could you take a look at this docu a bit. There might be
>>>>>>>>>>>>>>>>>> some
>>>>>>>>>>>>>>>>>> help
>>>>>>>>>>>>>>>>>> there.
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> Try to get something more easier working with SMX and
>>>>>>>>>>>>>>>>>> Camel
>>>>>>>>>>>>>>>>>> and
>>>>>>>>>>>>>>>>>> then
>>>>>>>>>>>>>>>>>> later do the stuff you want with the dynamic add a camel
>>>>>>>>>>>>>>>>>> context.
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> On Sat, Jan 10, 2009 at 12:39 PM, Liav Ezer
>>>>>>>>>>>>>>>>>> <li...@gmail.com>
>>>>>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>>>>                                 
>>>>>>>>>>>>>>>>>>                                     
>>>>>>>>>>>>>>>>>>> Hi Claus,
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> I read your tutorial & learnt from it. Thanks. I adopted
>>>>>>>>>>>>>>>>>>> the
>>>>>>>>>>>>>>>>>>> cxf
>>>>>>>>>>>>>>>>>>> framework
>>>>>>>>>>>>>>>>>>> for now.
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> Regarding my project (as stated above in snippets):
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> I planted the following camel routing logic at my
>>>>>>>>>>>>>>>>>>> processor
>>>>>>>>>>>>>>>>>>> class:
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> process method - with camel:
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> public void process(Exchange exchange) throws Exception {
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>  CamelContext camel = new DefaultCamelContext();
>>>>>>>>>>>>>>>>>>>  camel.start();
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>  Component component = (Component)
>>>>>>>>>>>>>>>>>>> camel.getComponent("http-provider-su");
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>  Endpoint endpoint = (Endpoint)
>>>>>>>>>>>>>>>>>>> ((org.apache.camel.Component)
>>>>>>>>>>>>>>>>>>> component).createEndpoint("provider:com.liav.oxp.esb");
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>  exchange.getIn().setBody("Liav testing here!");
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>  Producer producer = ((org.apache.camel.Endpoint)
>>>>>>>>>>>>>>>>>>> endpoint).createProducer();
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>  producer.start();
>>>>>>>>>>>>>>>>>>>  producer.process(exchange);
>>>>>>>>>>>>>>>>>>>  producer.stop();
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>  //System.out.println(exchange.getIn().toString() +
>>>>>>>>>>>>>>>>>>> "process
>>>>>>>>>>>>>>>>>>> activated
>>>>>>>>>>>>>>>>>>> by
>>>>>>>>>>>>>>>>>>> SU");
>>>>>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> And got the following exception while SA's jar was
>>>>>>>>>>>>>>>>>>> deployed:
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> ERROR - DeadLetterChannel              - Failed delivery
>>>>>>>>>>>>>>>>>>> for
>>>>>>>>>>>>>>>>>>> exchangeId:
>>>>>>>>>>>>>>>>>>> ID-LIAVE02/1885-1231586726193/0-0. On delivery attemp
>>>>>>>>>>>>>>>>>>> java.lang.NullPointerException
>>>>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>>>>> org.apache.servicemix.tutorial.camel.MyProcessor.process(MyProcessor.java:33)
>>>>>>>>>>>>>>>>>>> at
>>>>>>>>>>>>>>>>>>> org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:92)
>>>>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>>>>> org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:66)
>>>>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>>>>> org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorT
>>>>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>>>>> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:75)
>>>>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>>>>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:146)
>>>>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>>>>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:90)
>>>>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>>>>> org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
>>>>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>>>>> org.apache.camel.processor.Pipeline.process(Pipeline.java:85)
>>>>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>>>>> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:39)
>>>>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>>>>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
>>>>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>>>>> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
>>>>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>>>>> org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:91)
>>>>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>>>>> org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:48)
>>>>>>>>>>>>>>>>>>>        at java.util.TimerThread.mainLoop(Timer.java:512)
>>>>>>>>>>>>>>>>>>>        at java.util.TimerThread.run(Timer.java:462)
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> Be advise that line 33 is:Endpoint endpoint = (Endpoint)
>>>>>>>>>>>>>>>>>>> ((org.apache.camel.Component)
>>>>>>>>>>>>>>>>>>> component).createEndpoint("provider:com.liav.oxp.esb");
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> My questions:
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> 1. As bolded above i "fetched" my provider su component
>>>>>>>>>>>>>>>>>>> by
>>>>>>>>>>>>>>>>>>> staing
>>>>>>>>>>>>>>>>>>> it's
>>>>>>>>>>>>>>>>>>> name
>>>>>>>>>>>>>>>>>>> - is it correct?
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> 2. I used the following servicemix object (not camel's)
>>>>>>>>>>>>>>>>>>> since
>>>>>>>>>>>>>>>>>>> i
>>>>>>>>>>>>>>>>>>> work
>>>>>>>>>>>>>>>>>>> with
>>>>>>>>>>>>>>>>>>> servicemix provider endpoint. That's the reason for all
>>>>>>>>>>>>>>>>>>> the
>>>>>>>>>>>>>>>>>>> casting
>>>>>>>>>>>>>>>>>>> in
>>>>>>>>>>>>>>>>>>> my
>>>>>>>>>>>>>>>>>>> code:
>>>>>>>>>>>>>>>>>>> import org.apache.servicemix.jbi.deployment.Component;
>>>>>>>>>>>>>>>>>>> import org.apache.servicemix.jbi.framework.Endpoint;
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> Is it correct?
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> Thank again,
>>>>>>>>>>>>>>>>>>> Liav Ezer.
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>>>>>>>>>>>>                                   
>>>>>>>>>>>>>>>>>>>                                       
>>>>>>>>>>>>>>>>>>>> Hi
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>> You can use the producer template to call an external
>>>>>>>>>>>>>>>>>>>> http
>>>>>>>>>>>>>>>>>>>> server
>>>>>>>>>>>>>>>>>>>> and
>>>>>>>>>>>>>>>>>>>> get the response.
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>> See this tutorial:
>>>>>>>>>>>>>>>>>>>> http://activemq.apache.org/camel/tutorial-axis-camel.html
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>> From the section - integrating Camel
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>> Its kinda the same but its just uses the producer
>>>>>>>>>>>>>>>>>>>> template
>>>>>>>>>>>>>>>>>>>> to
>>>>>>>>>>>>>>>>>>>> save
>>>>>>>>>>>>>>>>>>>> a
>>>>>>>>>>>>>>>>>>>> file. Its the same API for using any of the camel
>>>>>>>>>>>>>>>>>>>> components.
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>> Little sidenote:
>>>>>>>>>>>>>>>>>>>> And since you use InOut you should use: requestBody
>>>>>>>>>>>>>>>>>>>> instread
>>>>>>>>>>>>>>>>>>>> of
>>>>>>>>>>>>>>>>>>>> sendBody. However Camel is not to stricky about this yet
>>>>>>>>>>>>>>>>>>>> so
>>>>>>>>>>>>>>>>>>>> if
>>>>>>>>>>>>>>>>>>>> you
>>>>>>>>>>>>>>>>>>>> use
>>>>>>>>>>>>>>>>>>>> a send instead of request then it should work as well.
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>> The demo shows how to inject a producer template from
>>>>>>>>>>>>>>>>>>>> spring
>>>>>>>>>>>>>>>>>>>> into
>>>>>>>>>>>>>>>>>>>> your
>>>>>>>>>>>>>>>>>>>> bean class = your processor. when you have this template
>>>>>>>>>>>>>>>>>>>> you
>>>>>>>>>>>>>>>>>>>> can
>>>>>>>>>>>>>>>>>>>> call
>>>>>>>>>>>>>>>>>>>> the external http server and get the response using the
>>>>>>>>>>>>>>>>>>>> requestBody
>>>>>>>>>>>>>>>>>>>> method.
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>> On Thu, Jan 8, 2009 at 1:46 PM, Liav Ezer
>>>>>>>>>>>>>>>>>>>> <li...@gmail.com>
>>>>>>>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>>>>>>                                     
>>>>>>>>>>>>>>>>>>>>                                         
>>>>>>>>>>>>>>>>>>>>> Hi,
>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>> Here is my camel-context:
>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>  <camelContext id="camel"
>>>>>>>>>>>>>>>>>>>>> xmlns="http://activemq.apache.org/camel/schema/spring">
>>>>>>>>>>>>>>>>>>>>>   
>>>>>>>>>>>>>>>>>>>>> <package>org.apache.servicemix.tutorial.camel</package>
>>>>>>>>>>>>>>>>>>>>>  </camelContext>
>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>  <bean id="myProcessor"
>>>>>>>>>>>>>>>>>>>>> class="org.apache.servicemix.tutorial.camel.MyProcessor"/>
>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>> Here is my RouteBuilder java file:
>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>> public class MyRouteBuilder extends RouteBuilder {
>>>>>>>>>>>>>>>>>>>>>        public void configure() {
>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>> from("timer://tutorial?fixedRate=true&delay=3000&period=10000")
>>>>>>>>>>>>>>>>>>>>>               
>>>>>>>>>>>>>>>>>>>>> .setBody(constant(".....................Liav
>>>>>>>>>>>>>>>>>>>>> Camel
>>>>>>>>>>>>>>>>>>>>> POC......................."))
>>>>>>>>>>>>>>>>>>>>>                        .to("myProcessor");
>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>    }
>>>>>>>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>> Here is my processor java file:
>>>>>>>>>>>>>>>>>>>>> public class MyProcessor implements Processor {
>>>>>>>>>>>>>>>>>>>>>          public void process(Exchange exchange) throws
>>>>>>>>>>>>>>>>>>>>> Exception
>>>>>>>>>>>>>>>>>>>>> {
>>>>>>>>>>>>>>>>>>>>>              //WANT TO INITIATE A CALL TO http pROVIDER
>>>>>>>>>>>>>>>>>>>>> END
>>>>>>>>>>>>>>>>>>>>> POINT
>>>>>>>>>>>>>>>>>>>>> &
>>>>>>>>>>>>>>>>>>>>> PASS
>>>>>>>>>>>>>>>>>>>>> THE
>>>>>>>>>>>>>>>>>>>>> 'FROM'
>>>>>>>>>>>>>>>>>>>>>                  // PARAMETRS RECIEVED PROIRE TO THE
>>>>>>>>>>>>>>>>>>>>> PROCESSOR
>>>>>>>>>>>>>>>>>>>>> INVOKE.
>>>>>>>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>> Thanks.
>>>>>>>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>>>>>>> View this message in context:
>>>>>>>>>>>>>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21351142.html
>>>>>>>>>>>>>>>>>>>>> Sent from the Camel - Users mailing list archive at
>>>>>>>>>>>>>>>>>>>>> Nabble.com.
>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>                                       
>>>>>>>>>>>>>>>>>>>>>                                           
>>>>>>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>> /Claus Ibsen
>>>>>>>>>>>>>>>>>>>> Apache Camel Committer
>>>>>>>>>>>>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>                                     
>>>>>>>>>>>>>>>>>>>>                                         
>>>>>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>>>>> View this message in context:
>>>>>>>>>>>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21387207.html
>>>>>>>>>>>>>>>>>>> Sent from the Camel - Users mailing list archive at
>>>>>>>>>>>>>>>>>>> Nabble.com.
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>                                   
>>>>>>>>>>>>>>>>>>>                                       
>>>>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> /Claus Ibsen
>>>>>>>>>>>>>>>>>> Apache Camel Committer
>>>>>>>>>>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>                                 
>>>>>>>>>>>>>>>>>>                                     
>>>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>>> View this message in context:
>>>>>>>>>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21387318.html
>>>>>>>>>>>>>>>>> Sent from the Camel - Users mailing list archive at
>>>>>>>>>>>>>>>>> Nabble.com.
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>>>>>                                   
>>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> /Claus Ibsen
>>>>>>>>>>>>>>>> Apache Camel Committer
>>>>>>>>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>                             
>>>>>>>>>>>>>>>>                                 
>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>> View this message in context:
>>>>>>>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21388391.html
>>>>>>>>>>>>>>> Sent from the Camel - Users mailing list archive at
>>>>>>>>>>>>>>> Nabble.com.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                           
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> /Claus Ibsen
>>>>>>>>>>>>>> Apache Camel Committer
>>>>>>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                         
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>> --
>>>>>>>>>>>>> View this message in context:
>>>>>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21389069.html
>>>>>>>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                       
>>>>>>>>>>>>>                           
>>>>>>>>>>>> --
>>>>>>>>>>>>
>>>>>>>>>>>> /Claus Ibsen
>>>>>>>>>>>> Apache Camel Committer
>>>>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                     
>>>>>>>>>>>>                         
>>>>>>>>>>> --
>>>>>>>>>>> View this message in context:
>>>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21390941.html
>>>>>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                   
>>>>>>>>>>>                       
>>>>>>>>>> --
>>>>>>>>>>
>>>>>>>>>> /Claus Ibsen
>>>>>>>>>> Apache Camel Committer
>>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                 
>>>>>>>>>>                     
>>>>>>>>> --
>>>>>>>>> View this message in context:
>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21396985.html
>>>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>               
>>>>>>>>>                   
>>>>>>>> --
>>>>>>>>
>>>>>>>> /Claus Ibsen
>>>>>>>> Apache Camel Committer
>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>
>>>>>>>>
>>>>>>>>             
>>>>>>>>                 
>>>>>>>           
>>>>>>>               
>>>>>>         
>>>>>>             
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21412377.html
>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>>       
>>>>>           
>>>> -- 
>>>>
>>>> /Claus Ibsen
>>>> Apache Camel Committer
>>>> Blog: http://davsclaus.blogspot.com/
>>>>
>>>>
>>>>     
>>>>         
>>>   
>>>       
>>
>> -----
>> ---
>> Gert Vanthienen
>> http://gertvanthienen.blogspot.com
>>
>>     
>
>   


Re: How do i call an HTTP Provider end-pont from the process method?

Posted by Liav Ezer <li...@gmail.com>.
Hi Gert,

My WS is LiavHelloImplSvc deployed under Tomcat 6.0 at 8080 port.
Well i thought that my WS is causing the problem & inserted a breakpoint but
it's not even invoked hence no output what so ever in my Tomcat console.

Something "configi" is wrong here.

By the way, i tried adding the below bolded attribute (after reading some
thread) & got an exception of other type:

<http:endpoint service="wsn:LiavHelloImplSvcService"
                 endpoint="wsn:LiavHelloImplSvc"
                 role="provider"
                
locationURI="http://localhost:8080/LiavHello2/services/LiavHelloImplSvc"
                
wsdlResource="c:/HTTPReceiverServices/LiavHelloImplSvc.wsdl"
                 defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
                 soap="true" 
                 soapVersion="1.1"/>

Exception:
DEBUG - SedaQueue                      -
org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1@1f55780 dequeued
exchange: InOut[
  id: ID:10.236.11.194-11eca7dd5b2-2:39
  status: Active
  role: consumer
  service: {http://com.liav.oxp/esb}LiavHelloImplSvcService
  endpoint: wsn:LiavHelloImplSvc
  in: <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:q0="http://service.app.esb.oxp.liav.com" xmlns:xsd="
http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><q0:sayHello><q0:name>LiavFromRouterBuilder</q0:name></q0:sayHello></soapenv:B
ody></soapenv:Envelope>
  fault: <?xml version="1.0" encoding="UTF-8"?><ns1:hostname
xmlns:ns1="http://xml.apache.org/axis/">LIAVE02</ns1:hostname>]



Gert Vanthienen wrote:
> 
> Liav,
> 
> It looks like the HTTP provider endpoint did invoke you remote (i.e. 
> http://localhost:8080/...) web service now, but it got some unexpected 
> exception back.  Could you check the log for the Jetty or whatever 
> server that is running the web service to see what went wrong there?
> 
> Regards,
> 
> Gert
> 
> Liav Ezer schreef:
>> Hi Claus,
>>
>> I noticed that i use an InOnly & tries changing it via the original
>> Exchange
>> object with no success.
>>
>> Using you methode (requestBody), i get the following exception:
>>
>> ERROR - HttpComponent                  - Error processing exchange InOut[
>>   id: ID:10.236.11.194-11eca7dd5b2-2:24
>>   status: Active
>>   role: provider
>>   service: {http://com.liav.oxp/esb}LiavHelloImplSvcService
>>   endpoint: wsn:LiavHelloImplSvc
>>   in: <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
>> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
>> xmlns:q0="http://service.app.esb.oxp.liav.com" xmlns:xsd="
>> http://www.w3.org/2001/XMLSchema"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><q0:sayHello><q0:name>LiavFromRouterBuilder</q0:name></q0:sayHello></soapenv:B
>> ody></soapenv:Envelope>
>> ]
>> org.apache.servicemix.soap.SoapFault: Unexpected fault code:
>> {http://www.w3.org/2003/05/soap-envelope}Server.userException        at
>> org.apache.servicemix.soap.marshalers.SoapReader.readFaultUsingDom(SoapReader.java:259)
>>         at
>> org.apache.servicemix.soap.marshalers.SoapReader.readFaultUsingStax(SoapReader.java:341)
>>         at
>> org.apache.servicemix.soap.marshalers.SoapReader.readSoapUsingStax(SoapReader.java:203)
>>         at
>> org.apache.servicemix.soap.marshalers.SoapReader.read(SoapReader.java:89)
>>         at
>> org.apache.servicemix.soap.marshalers.SoapReader.read(SoapReader.java:76)
>>         at
>> org.apache.servicemix.http.processors.ProviderProcessor.process(ProviderProcessor.java:182)
>>         at
>> org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLifeCycle.java:540)
>>         at
>> org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(AsyncBaseLifeCycle.java:492)
>>         at
>> org.apache.servicemix.common.BaseLifeCycle.onMessageExchange(BaseLifeCycle.java:46)
>>         at
>> org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(DeliveryChannelImpl.java:610)
>>         at
>> org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:172)
>>         at
>> org.apache.servicemix.jbi.nmr.flow.seda.SedaFlow.doRouting(SedaFlow.java:167)
>>         at
>> org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.java:134)
>>         at
>> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
>>         at
>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
>>         at java.lang.Thread.run(Thread.java:595)
>>
>> My Code:
>>
>> ProducerTemplate producerTemplate =
>> exchange.getContext().createProducerTemplate();
>>
>> String body = "<soapenv:Envelope
>> xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'
>> xmlns:q0='http://service.app.esb.oxp.liav.com'
>> xmlns:xsd='http://www.w3.org/2001/XMLSchema'
>> xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><soapenv:Body><q0:sayHello><q0:name>LIAV</q0:name></q0:sayHello></soapenv:Body></soapenv:Envelope>";
>>
>> Object response =
>> producerTemplate.requestBody("jbi:service:http://com.liav.oxp/esb/LiavHelloImplSvcService",
>> body);
>>
>> Is it related again to my API or maybe it's a wrong use of my 'body'
>> string?
>>
>> Thanks.
>>
>> Claus Ibsen-2 wrote:
>>   
>>>
>>>
>>> Hi
>>>
>>> SMX is more strict with setting the correct exchange pattern
>>> - InOnly
>>> - InOut
>>> etc
>>>
>>> We get this from the log
>>>     
>>>> Error processing exchange InOnly
>>>>       
>>> So you should use InOut from Camel as its a http component that
>>> expects an InOut exchange pattern
>>>
>>> This is done by using the requestBody method instread of sendBody in
>>> the producer template
>>>
>>> So it should be:
>>> producer.requestBody("jbi:service:http://com.liav.oxp/esb/LiavHelloImplSvcService",
>>> request);
>>>
>>>
>>>
>>> On Mon, Jan 12, 2009 at 12:03 PM, Liav Ezer <li...@gmail.com> wrote:
>>>     
>>>> Hi Claus,
>>>>
>>>> Ok, I progressed a bit but still has the a problem consuming my WS.
>>>>
>>>> Here is my Processor code (producer.sendBody() first arg' has changed).
>>>>
>>>> public void process(Exchange exchange) throws Exception {
>>>>          ProducerTemplate producer =
>>>> exchange.getContext().createProducerTemplate();
>>>>          String payload = exchange.getIn().getBody(String.class); // ==
>>>> liav
>>>>          String request = "<?xml version=\"1.0\"
>>>> encoding=\"UTF-8\"?><soapenv:Body><sayHello><name>"+payload+"</name></sayHello></soapenv:Body>";
>>>>          Object response =
>>>> producer.sendBody("jbi:service:http://com.liav.oxp/esb/LiavHelloImplSvcService",
>>>> request);
>>>> }
>>>>
>>>> This is the xbean of the SMX http Provider:
>>>>
>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>> <beans xmlns:http="http://servicemix.apache.org/http/1.0"
>>>>       xmlns:wsn="http://com.liav.oxp/esb"
>>>>       xmlns="http://www.springframework.org/schema/beans"
>>>>       xmlns:xsi="http://http://www.w3.org/2001/XMLSchema-instance"
>>>>       xsi:schemaLocation="http://servicemix.apache.org/http/1.0
>>>> http://servicemix.apache.org/schema/servicemix-http-3.3.1.3-fuse.xsd
>>>>       http://www.springframework.org/schema/beans
>>>> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
>>>>
>>>>           <http:endpoint service="wsn:LiavHelloImplSvcService"
>>>>                 endpoint="wsn:LiavHelloImplSvc"
>>>>                 role="provider"
>>>>
>>>> locationURI="http://localhost:8080/LiavHello2/services/LiavHelloImplSvc"
>>>>
>>>> wsdlResource="c:/HTTPReceiverServices/LiavHelloImplSvc.wsdl"
>>>>                 defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>>>                 soap="true" />
>>>> </beans>
>>>>
>>>> My question:
>>>>
>>>> By looking at the end-point invoke (via the producerTemplate) & at the
>>>> end-point config (xbean file),
>>>>
>>>> do you see a reason why my WS (LiavHelloImplSvcService) isn't consumed?
>>>>
>>>> Here is the current SMX log after deployment:
>>>>
>>>> ERROR - HttpComponent                  - Error processing exchange
>>>> InOnly[
>>>>  id: ID:10.236.11.194-11eca7dd5b2-2:8
>>>>  status: Active
>>>>  role: provider
>>>>  service: {http://com.liav.oxp/esb}LiavHelloImplSvcService
>>>>  endpoint: wsn:LiavHelloImplSvc
>>>>  in: <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
>>>> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
>>>> xmlns:q0="http://service.app.esb.oxp.liav.com" xmlns:xsd="
>>>> http://www.w3.org/2001/XMLSchema"
>>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><q0:sayHello><q0:name>LiavFromRouterBuilder</q0:name></q0:sayHello></soapenv:B
>>>> ody></soapenv:Envelope>
>>>> ]
>>>> java.lang.Exception: Invalid status response: 500
>>>> Thanks.
>>>>
>>>> Liav Ezer wrote:
>>>>       
>>>>> Hi Claus,
>>>>>
>>>>> What i managed to accomplish is that my producer is 'familiar' with my
>>>>> Provider end-point but from some reason it doesn't invoke my service
>>>>> (WS)
>>>>> & hence report an invalide status response (500).
>>>>>
>>>>> ERROR - HttpComponent                  - Error processing exchange
>>>>> InOnly[
>>>>>   id: ID:10.236.11.194-11ec622522e-2:96
>>>>>   status: Active
>>>>>   role: provider
>>>>>   service: {http://com.liav.oxp/esb}LiavHelloImplSvcService
>>>>>   endpoint: wsn:LiavHelloImplSvc
>>>>>   in: <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
>>>>> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
>>>>> xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http
>>>>> ://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><sayHello><name>Liav</name></sayHello></soapenv:Body></soapenv:Envelope>
>>>>> ]
>>>>>
>>>>> This is my xbean.xml (it must be related to the end-point
>>>>> configuration):
>>>>>
>>>>> <http:endpoint service="wsn:LiavHelloImplSvcService"
>>>>>                  endpoint="wsn:LiavHelloImplSvc"
>>>>>                  role="provider"
>>>>>
>>>>> locationURI="http://localhost:8080/LiavHello2/services/LiavHelloImplSvc"
>>>>>
>>>>> wsdlResource="c:/HTTPReceiverServices/LiavHelloImplSvc.wsdl"
>>>>>                  defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>>>>                  soap="true" />
>>>>>
>>>>> Thanks.
>>>>> java.lang.Exception: Invalid status response: 500
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Liav Ezer wrote:
>>>>>         
>>>>>> Hi Claus,
>>>>>>
>>>>>> I'm stuck with a problem that my servixmix is reporting a try to send
>>>>>> a
>>>>>> request to the provider but appearantly it's not able to consume the
>>>>>> Provider's WS.
>>>>>>
>>>>>> Here is the console:
>>>>>>
>>>>>> ERROR - DeadLetterChannel              - Failed delivery for
>>>>>> exchangeId:
>>>>>> ID-LIAVE02/1441-1231673232762/0-2. On delivery attempt: 0 caught:
>>>>>> org.apache.camel.RuntimeCamelException: o
>>>>>> rg.apache.servicemix.camel.JbiException:
>>>>>> javax.jbi.messaging.MessagingException: Could not find route for
>>>>>> exchange: InOnly[
>>>>>>   id: ID:10.236.11.194-11ec5713753-2:7
>>>>>>   status: Active
>>>>>>   role: provider
>>>>>> in: <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
>>>>>> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
>>>>>> xmlns:q0="http://service.app.esb.oxp.liav.com" xmlns:xsd="
>>>>>> http://www.w3.org/2001/XMLSchema"
>>>>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><q0:sayHello><q0:name>liav-name</q0:name>
>>>>>> </q0:sayHello></soapenv:Body></soape
>>>>>> nv:Envelope>
>>>>>> ] for service: null and interface: null
>>>>>>
>>>>>> When i develpoed the WS i tested it via eclipse with success.
>>>>>>
>>>>>> Here is the xbean definition:
>>>>>>
>>>>>> <http:endpoint service="wsn:LiavHelloImplSvcService"
>>>>>>                  endpoint="wsn:LiavHelloImplSvc"
>>>>>>                  role="provider"
>>>>>>
>>>>>> locationURI="http://localhost:8080/LiavHello2/services/LiavHelloImplSvc"
>>>>>>
>>>>>> wsdlResource="c:/HTTPReceiverServices/LiavHelloImplSvc.wsdl"
>>>>>>                  defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>>>>>                  soap="true" />
>>>>>>
>>>>>> Why does it report null for the service & interface?
>>>>>>
>>>>>> Thanks.
>>>>>>
>>>>>> Claus Ibsen-2 wrote:
>>>>>>           
>>>>>>> On Sun, Jan 11, 2009 at 9:19 AM, Liav Ezer <li...@gmail.com>
>>>>>>> wrote:
>>>>>>>             
>>>>>>>> Hi Claus,
>>>>>>>>
>>>>>>>> Yes, i changed the body (arg2 in the sendBody method) to be a SOAP
>>>>>>>> request
>>>>>>>> like the following:
>>>>>>>>
>>>>>>>> String request = "<soapenv:Envelope
>>>>>>>> xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'
>>>>>>>> xmlns:q0='http://service.app.esb.oxp.liav.com'
>>>>>>>> xmlns:xsd='http://www.w3.org/2001/XMLSchema'
>>>>>>>> xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><soapenv:Body><q0:sayHello><q0:name>liav-name</q0:name>
>>>>>>>> </q0:sayHello></soapenv:Body></soapenv:Envelope>";
>>>>>>>>
>>>>>>>> 1. Is it a correct payload to send a request?
>>>>>>>>               
>>>>>>> Yeah it should be something like that. You might need the <?xml
>>>>>>> version...> header. But try with and without it.
>>>>>>>
>>>>>>>
>>>>>>>             
>>>>>>>> 2. Does this method will return the provider response - The API
>>>>>>>> shows
>>>>>>>> that
>>>>>>>> it returns an Object - should i cast it to be an 'Exchange' &
>>>>>>>> extract
>>>>>>>> the
>>>>>>>> response from the provider?
>>>>>>>>               
>>>>>>> When you use Camel's producer template to do a request/reply then
>>>>>>> Camel will extract the response from the Exchange/IN or OUT/Message,
>>>>>>> so you just get the payload. The type is Object but it can be what
>>>>>>> SMX
>>>>>>> returns, so it could be some sort of XML holder such as
>>>>>>> org.w3c.Document. But try and see what kind of Object you get back.
>>>>>>>
>>>>>>> There are type converters in Camel that can convert it back to a
>>>>>>> String if you want to use that, or what else there is
>>>>>>> http://activemq.apache.org/camel/type-converter.html
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>             
>>>>>>>> Thanks.
>>>>>>>>
>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>               
>>>>>>>>> On Sat, Jan 10, 2009 at 8:51 PM, Liav Ezer <li...@gmail.com>
>>>>>>>>> wrote:
>>>>>>>>>                 
>>>>>>>>>> Hi Claus,
>>>>>>>>>>
>>>>>>>>>> I changed the notation as needed to:
>>>>>>>>>>
>>>>>>>>>> producer.sendBody("jbi:endpoint:http://localhost:8080/LiavHello/services/LiavHelloImpl",
>>>>>>>>>> "Netania");
>>>>>>>>>>
>>>>>>>>>>  SMX console now output some wierd error - googling it comes up
>>>>>>>>>> with
>>>>>>>>>> some
>>>>>>>>>> xml parsing error:
>>>>>>>>>>
>>>>>>>>>> [Fatal Error] :1:1: Content is not allowed in prolog.DEBUG -
>>>>>>>>>> DeliveryChannelImpl            - Exception processing:
>>>>>>>>>> ID:10.236.11.194-11ec1f3a450-2:291 in
>>>>>>>>>> DeliveryChannel{servicemix-camel}
>>>>>>>>>> ERROR - DeadLetterChannel              - Failed delivery for
>>>>>>>>>> exchangeId:
>>>>>>>>>> ID-LIAVE02/4519-1231614935663/0-50. On delivery attempt: 0
>>>>>>>>>> caught:
>>>>>>>>>> org.apache
>>>>>>>>>> org.apache.servicemix.camel.JbiException:
>>>>>>>>>> javax.jbi.messaging.MessagingException: Could not find route for
>>>>>>>>>> exchange:
>>>>>>>>>> InOnly[
>>>>>>>>>>  id: ID:10.236.11.194-11ec1f3a450-2:291
>>>>>>>>>>  status: Active
>>>>>>>>>>  role: provider
>>>>>>>>>>                   
>>>>>>>>> Yeah when you send data to SMX you must remember that its
>>>>>>>>> expecting
>>>>>>>>> the payload to be according to the JBI spec. in XML format. So you
>>>>>>>>> should send the data as XML.
>>>>>>>>>
>>>>>>>>> "Content is not allowed in prolog" is a bit cryptical XML parser
>>>>>>>>> error
>>>>>>>>> stating that it could not find the <?xml ... ?> declaration in top
>>>>>>>>> of
>>>>>>>>> the content it was parsing.
>>>>>>>>>
>>>>>>>>> So you should send the payload as XML.
>>>>>>>>>
>>>>>>>>> BTW: Which version of SMX and Camel are you using? I think the
>>>>>>>>> missing
>>>>>>>>> method from X mails back could be because we added it in Camel
>>>>>>>>> 1.4.0
>>>>>>>>> (I think).
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                 
>>>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>>>                   
>>>>>>>>>>>
>>>>>>>>>>> This is the SMX Provider xbean:
>>>>>>>>>>>
>>>>>>>>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>>>>>>>>> <beans xmlns:http="http://servicemix.apache.org/http/1.0"
>>>>>>>>>>>        xmlns:wsn="http://com.liav.oxp/esb"
>>>>>>>>>>>        xmlns="http://www.springframework.org/schema/beans"
>>>>>>>>>>>       
>>>>>>>>>>> xmlns:xsi="http://http://www.w3.org/2001/XMLSchema-instance"
>>>>>>>>>>>        xsi:schemaLocation="http://servicemix.apache.org/http/1.0
>>>>>>>>>>> http://servicemix.apache.org/schema/servicemix-http-3.3.1.3-fuse.xsd
>>>>>>>>>>>        http://www.springframework.org/schema/beans
>>>>>>>>>>> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
>>>>>>>>>>>
>>>>>>>>>>>                 <http:endpoint
>>>>>>>>>>> service="wsn:LiavHelloImplService"
>>>>>>>>>>>                  endpoint="wsn:LiavHelloImpl"
>>>>>>>>>>>                  role="provider"
>>>>>>>>>>>
>>>>>>>>>>> locationURI="http://localhost:8080/LiavHello/services/LiavHelloImpl"
>>>>>>>>>>>
>>>>>>>>>>> wsdlResource="c:/HTTPReceiverServices/LiavHelloImpl.wsdl"
>>>>>>>>>>>                 
>>>>>>>>>>> defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>>>>>>>>>>                  soap="true" />
>>>>>>>>>>> </beans>
>>>>>>>>>>> Any clue?
>>>>>>>>>>> On Sat, Jan 10, 2009 at 4:17 PM, Liav Ezer <li...@gmail.com>
>>>>>>>>>>> wrote:
>>>>>>>>>>>                     
>>>>>>>>>>>> Hi Claus,
>>>>>>>>>>>>
>>>>>>>>>>>> Well i'll stick with the Http SMX provider end-point. I guess
>>>>>>>>>>>> it's
>>>>>>>>>>>> should
>>>>>>>>>>>> integrate with camel routing with no problem.
>>>>>>>>>>>>
>>>>>>>>>>>> Ok what i did is the advise you gave me a few answers ago:
>>>>>>>>>>>>
>>>>>>>>>>>> ProducerTemplate producer =
>>>>>>>>>>>> exchange.getContext().createProducerTemplate();
>>>>>>>>>>>> Object response =
>>>>>>>>>>>> producer.sendBody("http://localhost:8080/LiavHello/services/LiavHelloImpl",
>>>>>>>>>>>> "Daviv");
>>>>>>>>>>>>                       
>>>>>>>>>>> See below
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                     
>>>>>>>>>>>> And got this exception (SMX console after deply):
>>>>>>>>>>>>
>>>>>>>>>>>> : No endpoint could be found for:
>>>>>>>>>>>> http://localhost:8080/LiavHello/services/LiavHelloImpl
>>>>>>>>>>>> org.apache.camel.NoSuchEndpointException: No endpoint could be
>>>>>>>>>>>> found
>>>>>>>>>>>> for:
>>>>>>>>>>>> http://localhost:8080/LiavHello/services/LiavHelloImpl
>>>>>>>>>>>>
>>>>>>>>>>>> LiavHelloImpl is the wsdlsoap:address location of the wsdl file
>>>>>>>>>>>> representing
>>>>>>>>>>>> the LiavHelloImp web project (under a running tomcat 6.0).
>>>>>>>>>>>>
>>>>>>>>>>>> Can you advise? It seems that the routing trying to be
>>>>>>>>>>>> accomplished
>>>>>>>>>>>> but
>>>>>>>>>>>> something "configi" is messed up.
>>>>>>>>>>>>
>>>>>>>>>>>> Here is my provider xbean:
>>>>>>>>>>>>
>>>>>>>>>>>> <http:endpoint service="wsn:LiavHelloImplService"
>>>>>>>>>>>>                 endpoint="wsn:LiavHelloImpl"
>>>>>>>>>>>>                 role="provider"
>>>>>>>>>>>>
>>>>>>>>>>>> locationURI="http://localhost:8080/LiavHello/services/LiavHelloImpl"
>>>>>>>>>>>>
>>>>>>>>>>>> wsdlResource="c:/HTTPReceiverServices/LiavHelloImpl.wsdl"
>>>>>>>>>>>>                
>>>>>>>>>>>> defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>>>>>>>>>>>                 soap="true" />
>>>>>>>>>>>>                       
>>>>>>>>>>> When you want from Camel to call service on SMX then you must
>>>>>>>>>>> use
>>>>>>>>>>> the
>>>>>>>>>>> camel-jbi component that delegates to the SU in SMX.
>>>>>>>>>>> So you need to add the jbi prefix in front.
>>>>>>>>>>> See: http://activemq.apache.org/camel/jbi.html
>>>>>>>>>>>
>>>>>>>>>>> It should be something like this. By by all means I am not SMX
>>>>>>>>>>> expert
>>>>>>>>>>> (yet):
>>>>>>>>>>> producer.sendBody("jbi:service:wsn:LiavHelloImplService",
>>>>>>>>>>> "Daviv");
>>>>>>>>>>>
>>>>>>>>>>> The jbi component have different notation so please check it
>>>>>>>>>>> out.
>>>>>>>>>>>
>>>>>>>>>>> If you manage to get it working, then please write back how to,
>>>>>>>>>>> so
>>>>>>>>>>> we
>>>>>>>>>>> can improve the documentation and help others in the future.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                     
>>>>>>>>>>>> Thanks!
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>>>>>                       
>>>>>>>>>>>>> On Sat, Jan 10, 2009 at 3:02 PM, Liav Ezer
>>>>>>>>>>>>> <li...@gmail.com>
>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>                         
>>>>>>>>>>>>>> Hi Claus,
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> I did follow this camel example & set up a timer 'from'
>>>>>>>>>>>>>> end-point
>>>>>>>>>>>>>> which
>>>>>>>>>>>>>> my
>>>>>>>>>>>>>> processor 'catched'.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> My will is to query this 'catched' data by sending it to a
>>>>>>>>>>>>>> different
>>>>>>>>>>>>>> end-point such as a service provider.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Therefore, i deployed two SU's in my servicemix: One for the
>>>>>>>>>>>>>> camel
>>>>>>>>>>>>>> routing
>>>>>>>>>>>>>> (timer example) & two is for
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> the HTTP servicemix provider which i want to invoke in the
>>>>>>>>>>>>>> proceesor.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> My question seems simple as long as an API exists for it:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> When my Processor class is instansiated than the process()
>>>>>>>>>>>>>> method
>>>>>>>>>>>>>> is
>>>>>>>>>>>>>> invoked:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> public void process(Exchange exchange) throws Exception {
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> The exchange.getIn() consist my 'from' end-point data (=the
>>>>>>>>>>>>>> timer).
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> I need the API to fetch the Http servicemix provider
>>>>>>>>>>>>>> end-point
>>>>>>>>>>>>>> &
>>>>>>>>>>>>>> to
>>>>>>>>>>>>>> send
>>>>>>>>>>>>>> hime a request with this data.
>>>>>>>>>>>>>>                           
>>>>>>>>>>>>> If you want to send FROM Camel to SMX then you need to use the
>>>>>>>>>>>>> camel-jbi component. That is you get endpoints FROM Camel
>>>>>>>>>>>>> starting
>>>>>>>>>>>>> with the "jbi:" prefix. See camel-jbi component.
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                         
>>>>>>>>>>>>>> One extra small question: Do i need to replace my provider SU
>>>>>>>>>>>>>> with a
>>>>>>>>>>>>>> camel
>>>>>>>>>>>>>> http producer SU?
>>>>>>>>>>>>>>                           
>>>>>>>>>>>>> If you are using SMX 3.x then you dont as SMX has one SU for
>>>>>>>>>>>>> Camel.
>>>>>>>>>>>>> However if you need to use any of the other camel components
>>>>>>>>>>>>> from
>>>>>>>>>>>>> SMX
>>>>>>>>>>>>> you need to have them in the classpath as well, such as
>>>>>>>>>>>>> camel-http.jar.
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> (In SMX 4.x its all OSGi land and you need to install features
>>>>>>>>>>>>> into
>>>>>>>>>>>>> SMX.)
>>>>>>>>>>>>>
>>>>>>>>>>>>> A bit confused now. Which http provider do you want to use?
>>>>>>>>>>>>> - SMX Http provider
>>>>>>>>>>>>> - Camel http provider
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                         
>>>>>>>>>>>>>> Thanks.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>>>>>>>                           
>>>>>>>>>>>>>>> Hi
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Yeah its a bit mixed up since Camel and ServiceMix have
>>>>>>>>>>>>>>> classes
>>>>>>>>>>>>>>> with
>>>>>>>>>>>>>>> common name: Endpoint, Exchange etc.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> All the code I have shown assumes pure Camel code.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> I advice to check the ServceMix docu about using Camel in
>>>>>>>>>>>>>>> ServiceMix.
>>>>>>>>>>>>>>> And get a basic example running. Such as this example
>>>>>>>>>>>>>>> http://servicemix.apache.org/camel-example.html
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> You could use that as a starting point to get Camel invoking
>>>>>>>>>>>>>>> your
>>>>>>>>>>>>>>> HTTP
>>>>>>>>>>>>>>> server. Just let the timer start it.
>>>>>>>>>>>>>>> Then later your can connect using SMX instead of the camel
>>>>>>>>>>>>>>> timer.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> On Sat, Jan 10, 2009 at 12:53 PM, Liav Ezer
>>>>>>>>>>>>>>> <li...@gmail.com>
>>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>                             
>>>>>>>>>>>>>>>> Hi Claus again,
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> I addition to what i asked in my previouse response here is
>>>>>>>>>>>>>>>> a
>>>>>>>>>>>>>>>> question
>>>>>>>>>>>>>>>> regarding the producer snippet which you gave in your last
>>>>>>>>>>>>>>>> answer:
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> I indeed wrote the following in my process() method:
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> ProducerTemplate producer =
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> exchange.getCamelContext().createProducerTemplate();
>>>>>>>>>>>>>>>>                            Object response =
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> producer.sendBody("http://myserver.com/myapp?foo=bar",
>>>>>>>>>>>>>>>> "Liav
>>>>>>>>>>>>>>>> Camel
>>>>>>>>>>>>>>>> POC");
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> but i don't have the camel context at hand (saying "The
>>>>>>>>>>>>>>>> method
>>>>>>>>>>>>>>>> getCamelContext() is undefined for the type Exchange").
>>>>>>>>>>>>>>>>  & also do i need to deploy a camel http producer su
>>>>>>>>>>>>>>>> instead
>>>>>>>>>>>>>>>> of
>>>>>>>>>>>>>>>> an
>>>>>>>>>>>>>>>> http
>>>>>>>>>>>>>>>> service mix provider?
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>>>>> Hi
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> When you are working with ServiceMix you must use the JBI
>>>>>>>>>>>>>>>>> component
>>>>>>>>>>>>>>>>> in
>>>>>>>>>>>>>>>>> Camel
>>>>>>>>>>>>>>>>> http://activemq.apache.org/camel/jbi.html
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> So your endpoints should starting with "jbi:XXXX"
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> And ServiceMix has some Camel docu here:
>>>>>>>>>>>>>>>>> http://servicemix.apache.org/servicemix-camel.html
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> Could you take a look at this docu a bit. There might be
>>>>>>>>>>>>>>>>> some
>>>>>>>>>>>>>>>>> help
>>>>>>>>>>>>>>>>> there.
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> Try to get something more easier working with SMX and
>>>>>>>>>>>>>>>>> Camel
>>>>>>>>>>>>>>>>> and
>>>>>>>>>>>>>>>>> then
>>>>>>>>>>>>>>>>> later do the stuff you want with the dynamic add a camel
>>>>>>>>>>>>>>>>> context.
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> On Sat, Jan 10, 2009 at 12:39 PM, Liav Ezer
>>>>>>>>>>>>>>>>> <li...@gmail.com>
>>>>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>>>                                 
>>>>>>>>>>>>>>>>>> Hi Claus,
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> I read your tutorial & learnt from it. Thanks. I adopted
>>>>>>>>>>>>>>>>>> the
>>>>>>>>>>>>>>>>>> cxf
>>>>>>>>>>>>>>>>>> framework
>>>>>>>>>>>>>>>>>> for now.
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> Regarding my project (as stated above in snippets):
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> I planted the following camel routing logic at my
>>>>>>>>>>>>>>>>>> processor
>>>>>>>>>>>>>>>>>> class:
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> process method - with camel:
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> public void process(Exchange exchange) throws Exception {
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>  CamelContext camel = new DefaultCamelContext();
>>>>>>>>>>>>>>>>>>  camel.start();
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>  Component component = (Component)
>>>>>>>>>>>>>>>>>> camel.getComponent("http-provider-su");
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>  Endpoint endpoint = (Endpoint)
>>>>>>>>>>>>>>>>>> ((org.apache.camel.Component)
>>>>>>>>>>>>>>>>>> component).createEndpoint("provider:com.liav.oxp.esb");
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>  exchange.getIn().setBody("Liav testing here!");
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>  Producer producer = ((org.apache.camel.Endpoint)
>>>>>>>>>>>>>>>>>> endpoint).createProducer();
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>  producer.start();
>>>>>>>>>>>>>>>>>>  producer.process(exchange);
>>>>>>>>>>>>>>>>>>  producer.stop();
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>  //System.out.println(exchange.getIn().toString() +
>>>>>>>>>>>>>>>>>> "process
>>>>>>>>>>>>>>>>>> activated
>>>>>>>>>>>>>>>>>> by
>>>>>>>>>>>>>>>>>> SU");
>>>>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> And got the following exception while SA's jar was
>>>>>>>>>>>>>>>>>> deployed:
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> ERROR - DeadLetterChannel              - Failed delivery
>>>>>>>>>>>>>>>>>> for
>>>>>>>>>>>>>>>>>> exchangeId:
>>>>>>>>>>>>>>>>>> ID-LIAVE02/1885-1231586726193/0-0. On delivery attemp
>>>>>>>>>>>>>>>>>> java.lang.NullPointerException
>>>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>>>> org.apache.servicemix.tutorial.camel.MyProcessor.process(MyProcessor.java:33)
>>>>>>>>>>>>>>>>>> at
>>>>>>>>>>>>>>>>>> org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:92)
>>>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>>>> org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:66)
>>>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>>>> org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorT
>>>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>>>> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:75)
>>>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>>>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:146)
>>>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>>>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:90)
>>>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>>>> org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
>>>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>>>> org.apache.camel.processor.Pipeline.process(Pipeline.java:85)
>>>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>>>> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:39)
>>>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>>>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
>>>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>>>> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
>>>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>>>> org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:91)
>>>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>>>> org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:48)
>>>>>>>>>>>>>>>>>>        at java.util.TimerThread.mainLoop(Timer.java:512)
>>>>>>>>>>>>>>>>>>        at java.util.TimerThread.run(Timer.java:462)
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> Be advise that line 33 is:Endpoint endpoint = (Endpoint)
>>>>>>>>>>>>>>>>>> ((org.apache.camel.Component)
>>>>>>>>>>>>>>>>>> component).createEndpoint("provider:com.liav.oxp.esb");
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> My questions:
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> 1. As bolded above i "fetched" my provider su component
>>>>>>>>>>>>>>>>>> by
>>>>>>>>>>>>>>>>>> staing
>>>>>>>>>>>>>>>>>> it's
>>>>>>>>>>>>>>>>>> name
>>>>>>>>>>>>>>>>>> - is it correct?
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> 2. I used the following servicemix object (not camel's)
>>>>>>>>>>>>>>>>>> since
>>>>>>>>>>>>>>>>>> i
>>>>>>>>>>>>>>>>>> work
>>>>>>>>>>>>>>>>>> with
>>>>>>>>>>>>>>>>>> servicemix provider endpoint. That's the reason for all
>>>>>>>>>>>>>>>>>> the
>>>>>>>>>>>>>>>>>> casting
>>>>>>>>>>>>>>>>>> in
>>>>>>>>>>>>>>>>>> my
>>>>>>>>>>>>>>>>>> code:
>>>>>>>>>>>>>>>>>> import org.apache.servicemix.jbi.deployment.Component;
>>>>>>>>>>>>>>>>>> import org.apache.servicemix.jbi.framework.Endpoint;
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> Is it correct?
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> Thank again,
>>>>>>>>>>>>>>>>>> Liav Ezer.
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>>>>>>>>>>>                                   
>>>>>>>>>>>>>>>>>>> Hi
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> You can use the producer template to call an external
>>>>>>>>>>>>>>>>>>> http
>>>>>>>>>>>>>>>>>>> server
>>>>>>>>>>>>>>>>>>> and
>>>>>>>>>>>>>>>>>>> get the response.
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> See this tutorial:
>>>>>>>>>>>>>>>>>>> http://activemq.apache.org/camel/tutorial-axis-camel.html
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> From the section - integrating Camel
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> Its kinda the same but its just uses the producer
>>>>>>>>>>>>>>>>>>> template
>>>>>>>>>>>>>>>>>>> to
>>>>>>>>>>>>>>>>>>> save
>>>>>>>>>>>>>>>>>>> a
>>>>>>>>>>>>>>>>>>> file. Its the same API for using any of the camel
>>>>>>>>>>>>>>>>>>> components.
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> Little sidenote:
>>>>>>>>>>>>>>>>>>> And since you use InOut you should use: requestBody
>>>>>>>>>>>>>>>>>>> instread
>>>>>>>>>>>>>>>>>>> of
>>>>>>>>>>>>>>>>>>> sendBody. However Camel is not to stricky about this yet
>>>>>>>>>>>>>>>>>>> so
>>>>>>>>>>>>>>>>>>> if
>>>>>>>>>>>>>>>>>>> you
>>>>>>>>>>>>>>>>>>> use
>>>>>>>>>>>>>>>>>>> a send instead of request then it should work as well.
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> The demo shows how to inject a producer template from
>>>>>>>>>>>>>>>>>>> spring
>>>>>>>>>>>>>>>>>>> into
>>>>>>>>>>>>>>>>>>> your
>>>>>>>>>>>>>>>>>>> bean class = your processor. when you have this template
>>>>>>>>>>>>>>>>>>> you
>>>>>>>>>>>>>>>>>>> can
>>>>>>>>>>>>>>>>>>> call
>>>>>>>>>>>>>>>>>>> the external http server and get the response using the
>>>>>>>>>>>>>>>>>>> requestBody
>>>>>>>>>>>>>>>>>>> method.
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> On Thu, Jan 8, 2009 at 1:46 PM, Liav Ezer
>>>>>>>>>>>>>>>>>>> <li...@gmail.com>
>>>>>>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>>>>>                                     
>>>>>>>>>>>>>>>>>>>> Hi,
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>> Here is my camel-context:
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>  <camelContext id="camel"
>>>>>>>>>>>>>>>>>>>> xmlns="http://activemq.apache.org/camel/schema/spring">
>>>>>>>>>>>>>>>>>>>>   
>>>>>>>>>>>>>>>>>>>> <package>org.apache.servicemix.tutorial.camel</package>
>>>>>>>>>>>>>>>>>>>>  </camelContext>
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>  <bean id="myProcessor"
>>>>>>>>>>>>>>>>>>>> class="org.apache.servicemix.tutorial.camel.MyProcessor"/>
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>> Here is my RouteBuilder java file:
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>> public class MyRouteBuilder extends RouteBuilder {
>>>>>>>>>>>>>>>>>>>>        public void configure() {
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>> from("timer://tutorial?fixedRate=true&delay=3000&period=10000")
>>>>>>>>>>>>>>>>>>>>               
>>>>>>>>>>>>>>>>>>>> .setBody(constant(".....................Liav
>>>>>>>>>>>>>>>>>>>> Camel
>>>>>>>>>>>>>>>>>>>> POC......................."))
>>>>>>>>>>>>>>>>>>>>                        .to("myProcessor");
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>    }
>>>>>>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>> Here is my processor java file:
>>>>>>>>>>>>>>>>>>>> public class MyProcessor implements Processor {
>>>>>>>>>>>>>>>>>>>>          public void process(Exchange exchange) throws
>>>>>>>>>>>>>>>>>>>> Exception
>>>>>>>>>>>>>>>>>>>> {
>>>>>>>>>>>>>>>>>>>>              //WANT TO INITIATE A CALL TO http pROVIDER
>>>>>>>>>>>>>>>>>>>> END
>>>>>>>>>>>>>>>>>>>> POINT
>>>>>>>>>>>>>>>>>>>> &
>>>>>>>>>>>>>>>>>>>> PASS
>>>>>>>>>>>>>>>>>>>> THE
>>>>>>>>>>>>>>>>>>>> 'FROM'
>>>>>>>>>>>>>>>>>>>>                  // PARAMETRS RECIEVED PROIRE TO THE
>>>>>>>>>>>>>>>>>>>> PROCESSOR
>>>>>>>>>>>>>>>>>>>> INVOKE.
>>>>>>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>> Thanks.
>>>>>>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>>>>>> View this message in context:
>>>>>>>>>>>>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21351142.html
>>>>>>>>>>>>>>>>>>>> Sent from the Camel - Users mailing list archive at
>>>>>>>>>>>>>>>>>>>> Nabble.com.
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>                                       
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> /Claus Ibsen
>>>>>>>>>>>>>>>>>>> Apache Camel Committer
>>>>>>>>>>>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>                                     
>>>>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>>>> View this message in context:
>>>>>>>>>>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21387207.html
>>>>>>>>>>>>>>>>>> Sent from the Camel - Users mailing list archive at
>>>>>>>>>>>>>>>>>> Nabble.com.
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>                                   
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> /Claus Ibsen
>>>>>>>>>>>>>>>>> Apache Camel Committer
>>>>>>>>>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>                                 
>>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>> View this message in context:
>>>>>>>>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21387318.html
>>>>>>>>>>>>>>>> Sent from the Camel - Users mailing list archive at
>>>>>>>>>>>>>>>> Nabble.com.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> /Claus Ibsen
>>>>>>>>>>>>>>> Apache Camel Committer
>>>>>>>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                             
>>>>>>>>>>>>>> --
>>>>>>>>>>>>>> View this message in context:
>>>>>>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21388391.html
>>>>>>>>>>>>>> Sent from the Camel - Users mailing list archive at
>>>>>>>>>>>>>> Nabble.com.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                           
>>>>>>>>>>>>>
>>>>>>>>>>>>> --
>>>>>>>>>>>>>
>>>>>>>>>>>>> /Claus Ibsen
>>>>>>>>>>>>> Apache Camel Committer
>>>>>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                         
>>>>>>>>>>>> --
>>>>>>>>>>>> View this message in context:
>>>>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21389069.html
>>>>>>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                       
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>>>
>>>>>>>>>>> /Claus Ibsen
>>>>>>>>>>> Apache Camel Committer
>>>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                     
>>>>>>>>>> --
>>>>>>>>>> View this message in context:
>>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21390941.html
>>>>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                   
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>>
>>>>>>>>> /Claus Ibsen
>>>>>>>>> Apache Camel Committer
>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                 
>>>>>>>> --
>>>>>>>> View this message in context:
>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21396985.html
>>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>>
>>>>>>>>
>>>>>>>>               
>>>>>>>
>>>>>>> --
>>>>>>>
>>>>>>> /Claus Ibsen
>>>>>>> Apache Camel Committer
>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>
>>>>>>>
>>>>>>>             
>>>>>>           
>>>>>         
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21412377.html
>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>
>>>>
>>>>       
>>>
>>> -- 
>>>
>>> /Claus Ibsen
>>> Apache Camel Committer
>>> Blog: http://davsclaus.blogspot.com/
>>>
>>>
>>>     
>>
>>   
> 
> 
> 
> -----
> ---
> Gert Vanthienen
> http://gertvanthienen.blogspot.com
> 

-- 
View this message in context: http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21414365.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: How do i call an HTTP Provider end-pont from the process method?

Posted by Gert Vanthienen <ge...@skynet.be>.
Liav,

It looks like the HTTP provider endpoint did invoke you remote (i.e. 
http://localhost:8080/...) web service now, but it got some unexpected 
exception back.  Could you check the log for the Jetty or whatever 
server that is running the web service to see what went wrong there?

Regards,

Gert

Liav Ezer schreef:
> Hi Claus,
>
> I noticed that i use an InOnly & tries changing it via the original Exchange
> object with no success.
>
> Using you methode (requestBody), i get the following exception:
>
> ERROR - HttpComponent                  - Error processing exchange InOut[
>   id: ID:10.236.11.194-11eca7dd5b2-2:24
>   status: Active
>   role: provider
>   service: {http://com.amdocs.oxp/esb}LiavHelloImplSvcService
>   endpoint: wsn:LiavHelloImplSvc
>   in: <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:q0="http://service.app.esb.oxp.amdocs.com" xmlns:xsd="
> http://www.w3.org/2001/XMLSchema"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><q0:sayHello><q0:name>LiavFromRouterBuilder</q0:name></q0:sayHello></soapenv:B
> ody></soapenv:Envelope>
> ]
> org.apache.servicemix.soap.SoapFault: Unexpected fault code:
> {http://www.w3.org/2003/05/soap-envelope}Server.userException        at
> org.apache.servicemix.soap.marshalers.SoapReader.readFaultUsingDom(SoapReader.java:259)
>         at
> org.apache.servicemix.soap.marshalers.SoapReader.readFaultUsingStax(SoapReader.java:341)
>         at
> org.apache.servicemix.soap.marshalers.SoapReader.readSoapUsingStax(SoapReader.java:203)
>         at
> org.apache.servicemix.soap.marshalers.SoapReader.read(SoapReader.java:89)
>         at
> org.apache.servicemix.soap.marshalers.SoapReader.read(SoapReader.java:76)
>         at
> org.apache.servicemix.http.processors.ProviderProcessor.process(ProviderProcessor.java:182)
>         at
> org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLifeCycle.java:540)
>         at
> org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(AsyncBaseLifeCycle.java:492)
>         at
> org.apache.servicemix.common.BaseLifeCycle.onMessageExchange(BaseLifeCycle.java:46)
>         at
> org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(DeliveryChannelImpl.java:610)
>         at
> org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:172)
>         at
> org.apache.servicemix.jbi.nmr.flow.seda.SedaFlow.doRouting(SedaFlow.java:167)
>         at
> org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.java:134)
>         at
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
>         at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
>         at java.lang.Thread.run(Thread.java:595)
>
> My Code:
>
> ProducerTemplate producerTemplate =
> exchange.getContext().createProducerTemplate();
>
> String body = "<soapenv:Envelope
> xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'
> xmlns:q0='http://service.app.esb.oxp.liav.com'
> xmlns:xsd='http://www.w3.org/2001/XMLSchema'
> xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><soapenv:Body><q0:sayHello><q0:name>LIAV</q0:name></q0:sayHello></soapenv:Body></soapenv:Envelope>";
>
> Object response =
> producerTemplate.requestBody("jbi:service:http://com.liav.oxp/esb/LiavHelloImplSvcService",
> body);
>
> Is it related again to my API or maybe it's a wrong use of my 'body' string?
>
> Thanks.
>
> Claus Ibsen-2 wrote:
>   
>>
>>
>> Hi
>>
>> SMX is more strict with setting the correct exchange pattern
>> - InOnly
>> - InOut
>> etc
>>
>> We get this from the log
>>     
>>> Error processing exchange InOnly
>>>       
>> So you should use InOut from Camel as its a http component that
>> expects an InOut exchange pattern
>>
>> This is done by using the requestBody method instread of sendBody in
>> the producer template
>>
>> So it should be:
>> producer.requestBody("jbi:service:http://com.amdocs.oxp/esb/LiavHelloImplSvcService",
>> request);
>>
>>
>>
>> On Mon, Jan 12, 2009 at 12:03 PM, Liav Ezer <li...@gmail.com> wrote:
>>     
>>> Hi Claus,
>>>
>>> Ok, I progressed a bit but still has the a problem consuming my WS.
>>>
>>> Here is my Processor code (producer.sendBody() first arg' has changed).
>>>
>>> public void process(Exchange exchange) throws Exception {
>>>          ProducerTemplate producer =
>>> exchange.getContext().createProducerTemplate();
>>>          String payload = exchange.getIn().getBody(String.class); // ==
>>> liav
>>>          String request = "<?xml version=\"1.0\"
>>> encoding=\"UTF-8\"?><soapenv:Body><sayHello><name>"+payload+"</name></sayHello></soapenv:Body>";
>>>          Object response =
>>> producer.sendBody("jbi:service:http://com.amdocs.oxp/esb/LiavHelloImplSvcService",
>>> request);
>>> }
>>>
>>> This is the xbean of the SMX http Provider:
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <beans xmlns:http="http://servicemix.apache.org/http/1.0"
>>>       xmlns:wsn="http://com.amdocs.oxp/esb"
>>>       xmlns="http://www.springframework.org/schema/beans"
>>>       xmlns:xsi="http://http://www.w3.org/2001/XMLSchema-instance"
>>>       xsi:schemaLocation="http://servicemix.apache.org/http/1.0
>>> http://servicemix.apache.org/schema/servicemix-http-3.3.1.3-fuse.xsd
>>>       http://www.springframework.org/schema/beans
>>> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
>>>
>>>           <http:endpoint service="wsn:LiavHelloImplSvcService"
>>>                 endpoint="wsn:LiavHelloImplSvc"
>>>                 role="provider"
>>>
>>> locationURI="http://localhost:8080/LiavHello2/services/LiavHelloImplSvc"
>>>
>>> wsdlResource="c:/HTTPReceiverServices/LiavHelloImplSvc.wsdl"
>>>                 defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>>                 soap="true" />
>>> </beans>
>>>
>>> My question:
>>>
>>> By looking at the end-point invoke (via the producerTemplate) & at the
>>> end-point config (xbean file),
>>>
>>> do you see a reason why my WS (LiavHelloImplSvcService) isn't consumed?
>>>
>>> Here is the current SMX log after deployment:
>>>
>>> ERROR - HttpComponent                  - Error processing exchange
>>> InOnly[
>>>  id: ID:10.236.11.194-11eca7dd5b2-2:8
>>>  status: Active
>>>  role: provider
>>>  service: {http://com.amdocs.oxp/esb}LiavHelloImplSvcService
>>>  endpoint: wsn:LiavHelloImplSvc
>>>  in: <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
>>> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
>>> xmlns:q0="http://service.app.esb.oxp.amdocs.com" xmlns:xsd="
>>> http://www.w3.org/2001/XMLSchema"
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><q0:sayHello><q0:name>LiavFromRouterBuilder</q0:name></q0:sayHello></soapenv:B
>>> ody></soapenv:Envelope>
>>> ]
>>> java.lang.Exception: Invalid status response: 500
>>> Thanks.
>>>
>>> Liav Ezer wrote:
>>>       
>>>> Hi Claus,
>>>>
>>>> What i managed to accomplish is that my producer is 'familiar' with my
>>>> Provider end-point but from some reason it doesn't invoke my service
>>>> (WS)
>>>> & hence report an invalide status response (500).
>>>>
>>>> ERROR - HttpComponent                  - Error processing exchange
>>>> InOnly[
>>>>   id: ID:10.236.11.194-11ec622522e-2:96
>>>>   status: Active
>>>>   role: provider
>>>>   service: {http://com.amdocs.oxp/esb}LiavHelloImplSvcService
>>>>   endpoint: wsn:LiavHelloImplSvc
>>>>   in: <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
>>>> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
>>>> xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http
>>>> ://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><sayHello><name>Liav</name></sayHello></soapenv:Body></soapenv:Envelope>
>>>> ]
>>>>
>>>> This is my xbean.xml (it must be related to the end-point
>>>> configuration):
>>>>
>>>> <http:endpoint service="wsn:LiavHelloImplSvcService"
>>>>                  endpoint="wsn:LiavHelloImplSvc"
>>>>                  role="provider"
>>>>
>>>> locationURI="http://localhost:8080/LiavHello2/services/LiavHelloImplSvc"
>>>>
>>>> wsdlResource="c:/HTTPReceiverServices/LiavHelloImplSvc.wsdl"
>>>>                  defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>>>                  soap="true" />
>>>>
>>>> Thanks.
>>>> java.lang.Exception: Invalid status response: 500
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Liav Ezer wrote:
>>>>         
>>>>> Hi Claus,
>>>>>
>>>>> I'm stuck with a problem that my servixmix is reporting a try to send a
>>>>> request to the provider but appearantly it's not able to consume the
>>>>> Provider's WS.
>>>>>
>>>>> Here is the console:
>>>>>
>>>>> ERROR - DeadLetterChannel              - Failed delivery for
>>>>> exchangeId:
>>>>> ID-LIAVE02/1441-1231673232762/0-2. On delivery attempt: 0 caught:
>>>>> org.apache.camel.RuntimeCamelException: o
>>>>> rg.apache.servicemix.camel.JbiException:
>>>>> javax.jbi.messaging.MessagingException: Could not find route for
>>>>> exchange: InOnly[
>>>>>   id: ID:10.236.11.194-11ec5713753-2:7
>>>>>   status: Active
>>>>>   role: provider
>>>>> in: <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
>>>>> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
>>>>> xmlns:q0="http://service.app.esb.oxp.amdocs.com" xmlns:xsd="
>>>>> http://www.w3.org/2001/XMLSchema"
>>>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><q0:sayHello><q0:name>liav-name</q0:name>
>>>>> </q0:sayHello></soapenv:Body></soape
>>>>> nv:Envelope>
>>>>> ] for service: null and interface: null
>>>>>
>>>>> When i develpoed the WS i tested it via eclipse with success.
>>>>>
>>>>> Here is the xbean definition:
>>>>>
>>>>> <http:endpoint service="wsn:LiavHelloImplSvcService"
>>>>>                  endpoint="wsn:LiavHelloImplSvc"
>>>>>                  role="provider"
>>>>>
>>>>> locationURI="http://localhost:8080/LiavHello2/services/LiavHelloImplSvc"
>>>>>
>>>>> wsdlResource="c:/HTTPReceiverServices/LiavHelloImplSvc.wsdl"
>>>>>                  defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>>>>                  soap="true" />
>>>>>
>>>>> Why does it report null for the service & interface?
>>>>>
>>>>> Thanks.
>>>>>
>>>>> Claus Ibsen-2 wrote:
>>>>>           
>>>>>> On Sun, Jan 11, 2009 at 9:19 AM, Liav Ezer <li...@gmail.com>
>>>>>> wrote:
>>>>>>             
>>>>>>> Hi Claus,
>>>>>>>
>>>>>>> Yes, i changed the body (arg2 in the sendBody method) to be a SOAP
>>>>>>> request
>>>>>>> like the following:
>>>>>>>
>>>>>>> String request = "<soapenv:Envelope
>>>>>>> xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'
>>>>>>> xmlns:q0='http://service.app.esb.oxp.liav.com'
>>>>>>> xmlns:xsd='http://www.w3.org/2001/XMLSchema'
>>>>>>> xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><soapenv:Body><q0:sayHello><q0:name>liav-name</q0:name>
>>>>>>> </q0:sayHello></soapenv:Body></soapenv:Envelope>";
>>>>>>>
>>>>>>> 1. Is it a correct payload to send a request?
>>>>>>>               
>>>>>> Yeah it should be something like that. You might need the <?xml
>>>>>> version...> header. But try with and without it.
>>>>>>
>>>>>>
>>>>>>             
>>>>>>> 2. Does this method will return the provider response - The API shows
>>>>>>> that
>>>>>>> it returns an Object - should i cast it to be an 'Exchange' & extract
>>>>>>> the
>>>>>>> response from the provider?
>>>>>>>               
>>>>>> When you use Camel's producer template to do a request/reply then
>>>>>> Camel will extract the response from the Exchange/IN or OUT/Message,
>>>>>> so you just get the payload. The type is Object but it can be what SMX
>>>>>> returns, so it could be some sort of XML holder such as
>>>>>> org.w3c.Document. But try and see what kind of Object you get back.
>>>>>>
>>>>>> There are type converters in Camel that can convert it back to a
>>>>>> String if you want to use that, or what else there is
>>>>>> http://activemq.apache.org/camel/type-converter.html
>>>>>>
>>>>>>
>>>>>>
>>>>>>             
>>>>>>> Thanks.
>>>>>>>
>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>               
>>>>>>>> On Sat, Jan 10, 2009 at 8:51 PM, Liav Ezer <li...@gmail.com>
>>>>>>>> wrote:
>>>>>>>>                 
>>>>>>>>> Hi Claus,
>>>>>>>>>
>>>>>>>>> I changed the notation as needed to:
>>>>>>>>>
>>>>>>>>> producer.sendBody("jbi:endpoint:http://localhost:8080/LiavHello/services/LiavHelloImpl",
>>>>>>>>> "Netania");
>>>>>>>>>
>>>>>>>>>  SMX console now output some wierd error - googling it comes up
>>>>>>>>> with
>>>>>>>>> some
>>>>>>>>> xml parsing error:
>>>>>>>>>
>>>>>>>>> [Fatal Error] :1:1: Content is not allowed in prolog.DEBUG -
>>>>>>>>> DeliveryChannelImpl            - Exception processing:
>>>>>>>>> ID:10.236.11.194-11ec1f3a450-2:291 in
>>>>>>>>> DeliveryChannel{servicemix-camel}
>>>>>>>>> ERROR - DeadLetterChannel              - Failed delivery for
>>>>>>>>> exchangeId:
>>>>>>>>> ID-LIAVE02/4519-1231614935663/0-50. On delivery attempt: 0 caught:
>>>>>>>>> org.apache
>>>>>>>>> org.apache.servicemix.camel.JbiException:
>>>>>>>>> javax.jbi.messaging.MessagingException: Could not find route for
>>>>>>>>> exchange:
>>>>>>>>> InOnly[
>>>>>>>>>  id: ID:10.236.11.194-11ec1f3a450-2:291
>>>>>>>>>  status: Active
>>>>>>>>>  role: provider
>>>>>>>>>                   
>>>>>>>> Yeah when you send data to SMX you must remember that its expecting
>>>>>>>> the payload to be according to the JBI spec. in XML format. So you
>>>>>>>> should send the data as XML.
>>>>>>>>
>>>>>>>> "Content is not allowed in prolog" is a bit cryptical XML parser
>>>>>>>> error
>>>>>>>> stating that it could not find the <?xml ... ?> declaration in top
>>>>>>>> of
>>>>>>>> the content it was parsing.
>>>>>>>>
>>>>>>>> So you should send the payload as XML.
>>>>>>>>
>>>>>>>> BTW: Which version of SMX and Camel are you using? I think the
>>>>>>>> missing
>>>>>>>> method from X mails back could be because we added it in Camel 1.4.0
>>>>>>>> (I think).
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>>                   
>>>>>>>>>>
>>>>>>>>>> This is the SMX Provider xbean:
>>>>>>>>>>
>>>>>>>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>>>>>>>> <beans xmlns:http="http://servicemix.apache.org/http/1.0"
>>>>>>>>>>        xmlns:wsn="http://com.amdocs.oxp/esb"
>>>>>>>>>>        xmlns="http://www.springframework.org/schema/beans"
>>>>>>>>>>       
>>>>>>>>>> xmlns:xsi="http://http://www.w3.org/2001/XMLSchema-instance"
>>>>>>>>>>        xsi:schemaLocation="http://servicemix.apache.org/http/1.0
>>>>>>>>>> http://servicemix.apache.org/schema/servicemix-http-3.3.1.3-fuse.xsd
>>>>>>>>>>        http://www.springframework.org/schema/beans
>>>>>>>>>> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
>>>>>>>>>>
>>>>>>>>>>                 <http:endpoint service="wsn:LiavHelloImplService"
>>>>>>>>>>                  endpoint="wsn:LiavHelloImpl"
>>>>>>>>>>                  role="provider"
>>>>>>>>>>
>>>>>>>>>> locationURI="http://localhost:8080/LiavHello/services/LiavHelloImpl"
>>>>>>>>>>
>>>>>>>>>> wsdlResource="c:/HTTPReceiverServices/LiavHelloImpl.wsdl"
>>>>>>>>>>                 
>>>>>>>>>> defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>>>>>>>>>                  soap="true" />
>>>>>>>>>> </beans>
>>>>>>>>>> Any clue?
>>>>>>>>>> On Sat, Jan 10, 2009 at 4:17 PM, Liav Ezer <li...@gmail.com>
>>>>>>>>>> wrote:
>>>>>>>>>>                     
>>>>>>>>>>> Hi Claus,
>>>>>>>>>>>
>>>>>>>>>>> Well i'll stick with the Http SMX provider end-point. I guess
>>>>>>>>>>> it's
>>>>>>>>>>> should
>>>>>>>>>>> integrate with camel routing with no problem.
>>>>>>>>>>>
>>>>>>>>>>> Ok what i did is the advise you gave me a few answers ago:
>>>>>>>>>>>
>>>>>>>>>>> ProducerTemplate producer =
>>>>>>>>>>> exchange.getContext().createProducerTemplate();
>>>>>>>>>>> Object response =
>>>>>>>>>>> producer.sendBody("http://localhost:8080/LiavHello/services/LiavHelloImpl",
>>>>>>>>>>> "Daviv");
>>>>>>>>>>>                       
>>>>>>>>>> See below
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>>> And got this exception (SMX console after deply):
>>>>>>>>>>>
>>>>>>>>>>> : No endpoint could be found for:
>>>>>>>>>>> http://localhost:8080/LiavHello/services/LiavHelloImpl
>>>>>>>>>>> org.apache.camel.NoSuchEndpointException: No endpoint could be
>>>>>>>>>>> found
>>>>>>>>>>> for:
>>>>>>>>>>> http://localhost:8080/LiavHello/services/LiavHelloImpl
>>>>>>>>>>>
>>>>>>>>>>> LiavHelloImpl is the wsdlsoap:address location of the wsdl file
>>>>>>>>>>> representing
>>>>>>>>>>> the LiavHelloImp web project (under a running tomcat 6.0).
>>>>>>>>>>>
>>>>>>>>>>> Can you advise? It seems that the routing trying to be
>>>>>>>>>>> accomplished
>>>>>>>>>>> but
>>>>>>>>>>> something "configi" is messed up.
>>>>>>>>>>>
>>>>>>>>>>> Here is my provider xbean:
>>>>>>>>>>>
>>>>>>>>>>> <http:endpoint service="wsn:LiavHelloImplService"
>>>>>>>>>>>                 endpoint="wsn:LiavHelloImpl"
>>>>>>>>>>>                 role="provider"
>>>>>>>>>>>
>>>>>>>>>>> locationURI="http://localhost:8080/LiavHello/services/LiavHelloImpl"
>>>>>>>>>>>
>>>>>>>>>>> wsdlResource="c:/HTTPReceiverServices/LiavHelloImpl.wsdl"
>>>>>>>>>>>                
>>>>>>>>>>> defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>>>>>>>>>>                 soap="true" />
>>>>>>>>>>>                       
>>>>>>>>>> When you want from Camel to call service on SMX then you must use
>>>>>>>>>> the
>>>>>>>>>> camel-jbi component that delegates to the SU in SMX.
>>>>>>>>>> So you need to add the jbi prefix in front.
>>>>>>>>>> See: http://activemq.apache.org/camel/jbi.html
>>>>>>>>>>
>>>>>>>>>> It should be something like this. By by all means I am not SMX
>>>>>>>>>> expert
>>>>>>>>>> (yet):
>>>>>>>>>> producer.sendBody("jbi:service:wsn:LiavHelloImplService",
>>>>>>>>>> "Daviv");
>>>>>>>>>>
>>>>>>>>>> The jbi component have different notation so please check it out.
>>>>>>>>>>
>>>>>>>>>> If you manage to get it working, then please write back how to, so
>>>>>>>>>> we
>>>>>>>>>> can improve the documentation and help others in the future.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>>> Thanks!
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>>>>                       
>>>>>>>>>>>> On Sat, Jan 10, 2009 at 3:02 PM, Liav Ezer <li...@gmail.com>
>>>>>>>>>>>> wrote:
>>>>>>>>>>>>                         
>>>>>>>>>>>>> Hi Claus,
>>>>>>>>>>>>>
>>>>>>>>>>>>> I did follow this camel example & set up a timer 'from'
>>>>>>>>>>>>> end-point
>>>>>>>>>>>>> which
>>>>>>>>>>>>> my
>>>>>>>>>>>>> processor 'catched'.
>>>>>>>>>>>>>
>>>>>>>>>>>>> My will is to query this 'catched' data by sending it to a
>>>>>>>>>>>>> different
>>>>>>>>>>>>> end-point such as a service provider.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Therefore, i deployed two SU's in my servicemix: One for the
>>>>>>>>>>>>> camel
>>>>>>>>>>>>> routing
>>>>>>>>>>>>> (timer example) & two is for
>>>>>>>>>>>>>
>>>>>>>>>>>>> the HTTP servicemix provider which i want to invoke in the
>>>>>>>>>>>>> proceesor.
>>>>>>>>>>>>>
>>>>>>>>>>>>> My question seems simple as long as an API exists for it:
>>>>>>>>>>>>>
>>>>>>>>>>>>> When my Processor class is instansiated than the process()
>>>>>>>>>>>>> method
>>>>>>>>>>>>> is
>>>>>>>>>>>>> invoked:
>>>>>>>>>>>>>
>>>>>>>>>>>>> public void process(Exchange exchange) throws Exception {
>>>>>>>>>>>>>
>>>>>>>>>>>>> The exchange.getIn() consist my 'from' end-point data (=the
>>>>>>>>>>>>> timer).
>>>>>>>>>>>>>
>>>>>>>>>>>>> I need the API to fetch the Http servicemix provider end-point
>>>>>>>>>>>>> &
>>>>>>>>>>>>> to
>>>>>>>>>>>>> send
>>>>>>>>>>>>> hime a request with this data.
>>>>>>>>>>>>>                           
>>>>>>>>>>>> If you want to send FROM Camel to SMX then you need to use the
>>>>>>>>>>>> camel-jbi component. That is you get endpoints FROM Camel
>>>>>>>>>>>> starting
>>>>>>>>>>>> with the "jbi:" prefix. See camel-jbi component.
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>>> One extra small question: Do i need to replace my provider SU
>>>>>>>>>>>>> with a
>>>>>>>>>>>>> camel
>>>>>>>>>>>>> http producer SU?
>>>>>>>>>>>>>                           
>>>>>>>>>>>> If you are using SMX 3.x then you dont as SMX has one SU for
>>>>>>>>>>>> Camel.
>>>>>>>>>>>> However if you need to use any of the other camel components
>>>>>>>>>>>> from
>>>>>>>>>>>> SMX
>>>>>>>>>>>> you need to have them in the classpath as well, such as
>>>>>>>>>>>> camel-http.jar.
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> (In SMX 4.x its all OSGi land and you need to install features
>>>>>>>>>>>> into
>>>>>>>>>>>> SMX.)
>>>>>>>>>>>>
>>>>>>>>>>>> A bit confused now. Which http provider do you want to use?
>>>>>>>>>>>> - SMX Http provider
>>>>>>>>>>>> - Camel http provider
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>>> Thanks.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>>>>>>                           
>>>>>>>>>>>>>> Hi
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Yeah its a bit mixed up since Camel and ServiceMix have
>>>>>>>>>>>>>> classes
>>>>>>>>>>>>>> with
>>>>>>>>>>>>>> common name: Endpoint, Exchange etc.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> All the code I have shown assumes pure Camel code.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> I advice to check the ServceMix docu about using Camel in
>>>>>>>>>>>>>> ServiceMix.
>>>>>>>>>>>>>> And get a basic example running. Such as this example
>>>>>>>>>>>>>> http://servicemix.apache.org/camel-example.html
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> You could use that as a starting point to get Camel invoking
>>>>>>>>>>>>>> your
>>>>>>>>>>>>>> HTTP
>>>>>>>>>>>>>> server. Just let the timer start it.
>>>>>>>>>>>>>> Then later your can connect using SMX instead of the camel
>>>>>>>>>>>>>> timer.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> On Sat, Jan 10, 2009 at 12:53 PM, Liav Ezer
>>>>>>>>>>>>>> <li...@gmail.com>
>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>>>> Hi Claus again,
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> I addition to what i asked in my previouse response here is a
>>>>>>>>>>>>>>> question
>>>>>>>>>>>>>>> regarding the producer snippet which you gave in your last
>>>>>>>>>>>>>>> answer:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> I indeed wrote the following in my process() method:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> ProducerTemplate producer =
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> exchange.getCamelContext().createProducerTemplate();
>>>>>>>>>>>>>>>                            Object response =
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> producer.sendBody("http://myserver.com/myapp?foo=bar", "Liav
>>>>>>>>>>>>>>> Camel
>>>>>>>>>>>>>>> POC");
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> but i don't have the camel context at hand (saying "The
>>>>>>>>>>>>>>> method
>>>>>>>>>>>>>>> getCamelContext() is undefined for the type Exchange").
>>>>>>>>>>>>>>>  & also do i need to deploy a camel http producer su instead
>>>>>>>>>>>>>>> of
>>>>>>>>>>>>>>> an
>>>>>>>>>>>>>>> http
>>>>>>>>>>>>>>> service mix provider?
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>>>> Hi
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> When you are working with ServiceMix you must use the JBI
>>>>>>>>>>>>>>>> component
>>>>>>>>>>>>>>>> in
>>>>>>>>>>>>>>>> Camel
>>>>>>>>>>>>>>>> http://activemq.apache.org/camel/jbi.html
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> So your endpoints should starting with "jbi:XXXX"
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> And ServiceMix has some Camel docu here:
>>>>>>>>>>>>>>>> http://servicemix.apache.org/servicemix-camel.html
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Could you take a look at this docu a bit. There might be
>>>>>>>>>>>>>>>> some
>>>>>>>>>>>>>>>> help
>>>>>>>>>>>>>>>> there.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Try to get something more easier working with SMX and Camel
>>>>>>>>>>>>>>>> and
>>>>>>>>>>>>>>>> then
>>>>>>>>>>>>>>>> later do the stuff you want with the dynamic add a camel
>>>>>>>>>>>>>>>> context.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> On Sat, Jan 10, 2009 at 12:39 PM, Liav Ezer
>>>>>>>>>>>>>>>> <li...@gmail.com>
>>>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>>                                 
>>>>>>>>>>>>>>>>> Hi Claus,
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> I read your tutorial & learnt from it. Thanks. I adopted
>>>>>>>>>>>>>>>>> the
>>>>>>>>>>>>>>>>> cxf
>>>>>>>>>>>>>>>>> framework
>>>>>>>>>>>>>>>>> for now.
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> Regarding my project (as stated above in snippets):
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> I planted the following camel routing logic at my processor
>>>>>>>>>>>>>>>>> class:
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> process method - with camel:
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> public void process(Exchange exchange) throws Exception {
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>  CamelContext camel = new DefaultCamelContext();
>>>>>>>>>>>>>>>>>  camel.start();
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>  Component component = (Component)
>>>>>>>>>>>>>>>>> camel.getComponent("http-provider-su");
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>  Endpoint endpoint = (Endpoint)
>>>>>>>>>>>>>>>>> ((org.apache.camel.Component)
>>>>>>>>>>>>>>>>> component).createEndpoint("provider:com.amdocs.oxp.esb");
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>  exchange.getIn().setBody("Liav testing here!");
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>  Producer producer = ((org.apache.camel.Endpoint)
>>>>>>>>>>>>>>>>> endpoint).createProducer();
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>  producer.start();
>>>>>>>>>>>>>>>>>  producer.process(exchange);
>>>>>>>>>>>>>>>>>  producer.stop();
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>  //System.out.println(exchange.getIn().toString() +
>>>>>>>>>>>>>>>>> "process
>>>>>>>>>>>>>>>>> activated
>>>>>>>>>>>>>>>>> by
>>>>>>>>>>>>>>>>> SU");
>>>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> And got the following exception while SA's jar was
>>>>>>>>>>>>>>>>> deployed:
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> ERROR - DeadLetterChannel              - Failed delivery
>>>>>>>>>>>>>>>>> for
>>>>>>>>>>>>>>>>> exchangeId:
>>>>>>>>>>>>>>>>> ID-LIAVE02/1885-1231586726193/0-0. On delivery attemp
>>>>>>>>>>>>>>>>> java.lang.NullPointerException
>>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>>> org.apache.servicemix.tutorial.camel.MyProcessor.process(MyProcessor.java:33)
>>>>>>>>>>>>>>>>> at
>>>>>>>>>>>>>>>>> org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:92)
>>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>>> org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:66)
>>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>>> org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorT
>>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>>> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:75)
>>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:146)
>>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:90)
>>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>>> org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
>>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>>> org.apache.camel.processor.Pipeline.process(Pipeline.java:85)
>>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>>> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:39)
>>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
>>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>>> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
>>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>>> org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:91)
>>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>>> org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:48)
>>>>>>>>>>>>>>>>>        at java.util.TimerThread.mainLoop(Timer.java:512)
>>>>>>>>>>>>>>>>>        at java.util.TimerThread.run(Timer.java:462)
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> Be advise that line 33 is:Endpoint endpoint = (Endpoint)
>>>>>>>>>>>>>>>>> ((org.apache.camel.Component)
>>>>>>>>>>>>>>>>> component).createEndpoint("provider:com.amdocs.oxp.esb");
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> My questions:
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> 1. As bolded above i "fetched" my provider su component by
>>>>>>>>>>>>>>>>> staing
>>>>>>>>>>>>>>>>> it's
>>>>>>>>>>>>>>>>> name
>>>>>>>>>>>>>>>>> - is it correct?
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> 2. I used the following servicemix object (not camel's)
>>>>>>>>>>>>>>>>> since
>>>>>>>>>>>>>>>>> i
>>>>>>>>>>>>>>>>> work
>>>>>>>>>>>>>>>>> with
>>>>>>>>>>>>>>>>> servicemix provider endpoint. That's the reason for all the
>>>>>>>>>>>>>>>>> casting
>>>>>>>>>>>>>>>>> in
>>>>>>>>>>>>>>>>> my
>>>>>>>>>>>>>>>>> code:
>>>>>>>>>>>>>>>>> import org.apache.servicemix.jbi.deployment.Component;
>>>>>>>>>>>>>>>>> import org.apache.servicemix.jbi.framework.Endpoint;
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> Is it correct?
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> Thank again,
>>>>>>>>>>>>>>>>> Liav Ezer.
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>>>>>>>>>>                                   
>>>>>>>>>>>>>>>>>> Hi
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> You can use the producer template to call an external http
>>>>>>>>>>>>>>>>>> server
>>>>>>>>>>>>>>>>>> and
>>>>>>>>>>>>>>>>>> get the response.
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> See this tutorial:
>>>>>>>>>>>>>>>>>> http://activemq.apache.org/camel/tutorial-axis-camel.html
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> From the section - integrating Camel
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> Its kinda the same but its just uses the producer template
>>>>>>>>>>>>>>>>>> to
>>>>>>>>>>>>>>>>>> save
>>>>>>>>>>>>>>>>>> a
>>>>>>>>>>>>>>>>>> file. Its the same API for using any of the camel
>>>>>>>>>>>>>>>>>> components.
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> Little sidenote:
>>>>>>>>>>>>>>>>>> And since you use InOut you should use: requestBody
>>>>>>>>>>>>>>>>>> instread
>>>>>>>>>>>>>>>>>> of
>>>>>>>>>>>>>>>>>> sendBody. However Camel is not to stricky about this yet
>>>>>>>>>>>>>>>>>> so
>>>>>>>>>>>>>>>>>> if
>>>>>>>>>>>>>>>>>> you
>>>>>>>>>>>>>>>>>> use
>>>>>>>>>>>>>>>>>> a send instead of request then it should work as well.
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> The demo shows how to inject a producer template from
>>>>>>>>>>>>>>>>>> spring
>>>>>>>>>>>>>>>>>> into
>>>>>>>>>>>>>>>>>> your
>>>>>>>>>>>>>>>>>> bean class = your processor. when you have this template
>>>>>>>>>>>>>>>>>> you
>>>>>>>>>>>>>>>>>> can
>>>>>>>>>>>>>>>>>> call
>>>>>>>>>>>>>>>>>> the external http server and get the response using the
>>>>>>>>>>>>>>>>>> requestBody
>>>>>>>>>>>>>>>>>> method.
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> On Thu, Jan 8, 2009 at 1:46 PM, Liav Ezer
>>>>>>>>>>>>>>>>>> <li...@gmail.com>
>>>>>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>>>>                                     
>>>>>>>>>>>>>>>>>>> Hi,
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> Here is my camel-context:
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>  <camelContext id="camel"
>>>>>>>>>>>>>>>>>>> xmlns="http://activemq.apache.org/camel/schema/spring">
>>>>>>>>>>>>>>>>>>>   
>>>>>>>>>>>>>>>>>>> <package>org.apache.servicemix.tutorial.camel</package>
>>>>>>>>>>>>>>>>>>>  </camelContext>
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>  <bean id="myProcessor"
>>>>>>>>>>>>>>>>>>> class="org.apache.servicemix.tutorial.camel.MyProcessor"/>
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> Here is my RouteBuilder java file:
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> public class MyRouteBuilder extends RouteBuilder {
>>>>>>>>>>>>>>>>>>>        public void configure() {
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> from("timer://tutorial?fixedRate=true&delay=3000&period=10000")
>>>>>>>>>>>>>>>>>>>               
>>>>>>>>>>>>>>>>>>> .setBody(constant(".....................Liav
>>>>>>>>>>>>>>>>>>> Camel
>>>>>>>>>>>>>>>>>>> POC......................."))
>>>>>>>>>>>>>>>>>>>                        .to("myProcessor");
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>    }
>>>>>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> Here is my processor java file:
>>>>>>>>>>>>>>>>>>> public class MyProcessor implements Processor {
>>>>>>>>>>>>>>>>>>>          public void process(Exchange exchange) throws
>>>>>>>>>>>>>>>>>>> Exception
>>>>>>>>>>>>>>>>>>> {
>>>>>>>>>>>>>>>>>>>              //WANT TO INITIATE A CALL TO http pROVIDER
>>>>>>>>>>>>>>>>>>> END
>>>>>>>>>>>>>>>>>>> POINT
>>>>>>>>>>>>>>>>>>> &
>>>>>>>>>>>>>>>>>>> PASS
>>>>>>>>>>>>>>>>>>> THE
>>>>>>>>>>>>>>>>>>> 'FROM'
>>>>>>>>>>>>>>>>>>>                  // PARAMETRS RECIEVED PROIRE TO THE
>>>>>>>>>>>>>>>>>>> PROCESSOR
>>>>>>>>>>>>>>>>>>> INVOKE.
>>>>>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> Thanks.
>>>>>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>>>>> View this message in context:
>>>>>>>>>>>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21351142.html
>>>>>>>>>>>>>>>>>>> Sent from the Camel - Users mailing list archive at
>>>>>>>>>>>>>>>>>>> Nabble.com.
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>                                       
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> /Claus Ibsen
>>>>>>>>>>>>>>>>>> Apache Camel Committer
>>>>>>>>>>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>                                     
>>>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>>> View this message in context:
>>>>>>>>>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21387207.html
>>>>>>>>>>>>>>>>> Sent from the Camel - Users mailing list archive at
>>>>>>>>>>>>>>>>> Nabble.com.
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>                                   
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> /Claus Ibsen
>>>>>>>>>>>>>>>> Apache Camel Committer
>>>>>>>>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>                                 
>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>> View this message in context:
>>>>>>>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21387318.html
>>>>>>>>>>>>>>> Sent from the Camel - Users mailing list archive at
>>>>>>>>>>>>>>> Nabble.com.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> /Claus Ibsen
>>>>>>>>>>>>>> Apache Camel Committer
>>>>>>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>> --
>>>>>>>>>>>>> View this message in context:
>>>>>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21388391.html
>>>>>>>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>>
>>>>>>>>>>>> --
>>>>>>>>>>>>
>>>>>>>>>>>> /Claus Ibsen
>>>>>>>>>>>> Apache Camel Committer
>>>>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>> --
>>>>>>>>>>> View this message in context:
>>>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21389069.html
>>>>>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>>
>>>>>>>>>> /Claus Ibsen
>>>>>>>>>> Apache Camel Committer
>>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>> --
>>>>>>>>> View this message in context:
>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21390941.html
>>>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>
>>>>>>>> --
>>>>>>>>
>>>>>>>> /Claus Ibsen
>>>>>>>> Apache Camel Committer
>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>> --
>>>>>>> View this message in context:
>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21396985.html
>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>
>>>>>> --
>>>>>>
>>>>>> /Claus Ibsen
>>>>>> Apache Camel Committer
>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>
>>>>>>
>>>>>>             
>>>>>           
>>>>         
>>> --
>>> View this message in context:
>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21412377.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>>       
>>
>> -- 
>>
>> /Claus Ibsen
>> Apache Camel Committer
>> Blog: http://davsclaus.blogspot.com/
>>
>>
>>     
>
>   


Re: How do i call an HTTP Provider end-pont from the process method?

Posted by Liav Ezer <li...@gmail.com>.
Hi Claus,

I noticed that i use an InOnly & tries changing it via the original Exchange
object with no success.

Using you methode (requestBody), i get the following exception:

ERROR - HttpComponent                  - Error processing exchange InOut[
  id: ID:10.236.11.194-11eca7dd5b2-2:24
  status: Active
  role: provider
  service: {http://com.amdocs.oxp/esb}LiavHelloImplSvcService
  endpoint: wsn:LiavHelloImplSvc
  in: <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:q0="http://service.app.esb.oxp.amdocs.com" xmlns:xsd="
http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><q0:sayHello><q0:name>LiavFromRouterBuilder</q0:name></q0:sayHello></soapenv:B
ody></soapenv:Envelope>
]
org.apache.servicemix.soap.SoapFault: Unexpected fault code:
{http://www.w3.org/2003/05/soap-envelope}Server.userException        at
org.apache.servicemix.soap.marshalers.SoapReader.readFaultUsingDom(SoapReader.java:259)
        at
org.apache.servicemix.soap.marshalers.SoapReader.readFaultUsingStax(SoapReader.java:341)
        at
org.apache.servicemix.soap.marshalers.SoapReader.readSoapUsingStax(SoapReader.java:203)
        at
org.apache.servicemix.soap.marshalers.SoapReader.read(SoapReader.java:89)
        at
org.apache.servicemix.soap.marshalers.SoapReader.read(SoapReader.java:76)
        at
org.apache.servicemix.http.processors.ProviderProcessor.process(ProviderProcessor.java:182)
        at
org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLifeCycle.java:540)
        at
org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(AsyncBaseLifeCycle.java:492)
        at
org.apache.servicemix.common.BaseLifeCycle.onMessageExchange(BaseLifeCycle.java:46)
        at
org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(DeliveryChannelImpl.java:610)
        at
org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:172)
        at
org.apache.servicemix.jbi.nmr.flow.seda.SedaFlow.doRouting(SedaFlow.java:167)
        at
org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.java:134)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
        at java.lang.Thread.run(Thread.java:595)

My Code:

ProducerTemplate producerTemplate =
exchange.getContext().createProducerTemplate();

String body = "<soapenv:Envelope
xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'
xmlns:q0='http://service.app.esb.oxp.liav.com'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><soapenv:Body><q0:sayHello><q0:name>LIAV</q0:name></q0:sayHello></soapenv:Body></soapenv:Envelope>";

Object response =
producerTemplate.requestBody("jbi:service:http://com.liav.oxp/esb/LiavHelloImplSvcService",
body);

Is it related again to my API or maybe it's a wrong use of my 'body' string?

Thanks.

Claus Ibsen-2 wrote:
> 
> 
> 
> 
> Hi
> 
> SMX is more strict with setting the correct exchange pattern
> - InOnly
> - InOut
> etc
> 
> We get this from the log
>> Error processing exchange InOnly
> 
> So you should use InOut from Camel as its a http component that
> expects an InOut exchange pattern
> 
> This is done by using the requestBody method instread of sendBody in
> the producer template
> 
> So it should be:
> producer.requestBody("jbi:service:http://com.amdocs.oxp/esb/LiavHelloImplSvcService",
> request);
> 
> 
> 
> On Mon, Jan 12, 2009 at 12:03 PM, Liav Ezer <li...@gmail.com> wrote:
>>
>> Hi Claus,
>>
>> Ok, I progressed a bit but still has the a problem consuming my WS.
>>
>> Here is my Processor code (producer.sendBody() first arg' has changed).
>>
>> public void process(Exchange exchange) throws Exception {
>>          ProducerTemplate producer =
>> exchange.getContext().createProducerTemplate();
>>          String payload = exchange.getIn().getBody(String.class); // ==
>> liav
>>          String request = "<?xml version=\"1.0\"
>> encoding=\"UTF-8\"?><soapenv:Body><sayHello><name>"+payload+"</name></sayHello></soapenv:Body>";
>>          Object response =
>> producer.sendBody("jbi:service:http://com.amdocs.oxp/esb/LiavHelloImplSvcService",
>> request);
>> }
>>
>> This is the xbean of the SMX http Provider:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <beans xmlns:http="http://servicemix.apache.org/http/1.0"
>>       xmlns:wsn="http://com.amdocs.oxp/esb"
>>       xmlns="http://www.springframework.org/schema/beans"
>>       xmlns:xsi="http://http://www.w3.org/2001/XMLSchema-instance"
>>       xsi:schemaLocation="http://servicemix.apache.org/http/1.0
>> http://servicemix.apache.org/schema/servicemix-http-3.3.1.3-fuse.xsd
>>       http://www.springframework.org/schema/beans
>> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
>>
>>           <http:endpoint service="wsn:LiavHelloImplSvcService"
>>                 endpoint="wsn:LiavHelloImplSvc"
>>                 role="provider"
>>
>> locationURI="http://localhost:8080/LiavHello2/services/LiavHelloImplSvc"
>>
>> wsdlResource="c:/HTTPReceiverServices/LiavHelloImplSvc.wsdl"
>>                 defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>                 soap="true" />
>> </beans>
>>
>> My question:
>>
>> By looking at the end-point invoke (via the producerTemplate) & at the
>> end-point config (xbean file),
>>
>> do you see a reason why my WS (LiavHelloImplSvcService) isn't consumed?
>>
>> Here is the current SMX log after deployment:
>>
>> ERROR - HttpComponent                  - Error processing exchange
>> InOnly[
>>  id: ID:10.236.11.194-11eca7dd5b2-2:8
>>  status: Active
>>  role: provider
>>  service: {http://com.amdocs.oxp/esb}LiavHelloImplSvcService
>>  endpoint: wsn:LiavHelloImplSvc
>>  in: <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
>> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
>> xmlns:q0="http://service.app.esb.oxp.amdocs.com" xmlns:xsd="
>> http://www.w3.org/2001/XMLSchema"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><q0:sayHello><q0:name>LiavFromRouterBuilder</q0:name></q0:sayHello></soapenv:B
>> ody></soapenv:Envelope>
>> ]
>> java.lang.Exception: Invalid status response: 500
>> Thanks.
>>
>> Liav Ezer wrote:
>>>
>>> Hi Claus,
>>>
>>> What i managed to accomplish is that my producer is 'familiar' with my
>>> Provider end-point but from some reason it doesn't invoke my service
>>> (WS)
>>> & hence report an invalide status response (500).
>>>
>>> ERROR - HttpComponent                  - Error processing exchange
>>> InOnly[
>>>   id: ID:10.236.11.194-11ec622522e-2:96
>>>   status: Active
>>>   role: provider
>>>   service: {http://com.amdocs.oxp/esb}LiavHelloImplSvcService
>>>   endpoint: wsn:LiavHelloImplSvc
>>>   in: <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
>>> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
>>> xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http
>>> ://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><sayHello><name>Liav</name></sayHello></soapenv:Body></soapenv:Envelope>
>>> ]
>>>
>>> This is my xbean.xml (it must be related to the end-point
>>> configuration):
>>>
>>> <http:endpoint service="wsn:LiavHelloImplSvcService"
>>>                  endpoint="wsn:LiavHelloImplSvc"
>>>                  role="provider"
>>>
>>> locationURI="http://localhost:8080/LiavHello2/services/LiavHelloImplSvc"
>>>
>>> wsdlResource="c:/HTTPReceiverServices/LiavHelloImplSvc.wsdl"
>>>                  defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>>                  soap="true" />
>>>
>>> Thanks.
>>> java.lang.Exception: Invalid status response: 500
>>>
>>>
>>>
>>>
>>>
>>> Liav Ezer wrote:
>>>>
>>>> Hi Claus,
>>>>
>>>> I'm stuck with a problem that my servixmix is reporting a try to send a
>>>> request to the provider but appearantly it's not able to consume the
>>>> Provider's WS.
>>>>
>>>> Here is the console:
>>>>
>>>> ERROR - DeadLetterChannel              - Failed delivery for
>>>> exchangeId:
>>>> ID-LIAVE02/1441-1231673232762/0-2. On delivery attempt: 0 caught:
>>>> org.apache.camel.RuntimeCamelException: o
>>>> rg.apache.servicemix.camel.JbiException:
>>>> javax.jbi.messaging.MessagingException: Could not find route for
>>>> exchange: InOnly[
>>>>   id: ID:10.236.11.194-11ec5713753-2:7
>>>>   status: Active
>>>>   role: provider
>>>> in: <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
>>>> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
>>>> xmlns:q0="http://service.app.esb.oxp.amdocs.com" xmlns:xsd="
>>>> http://www.w3.org/2001/XMLSchema"
>>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><q0:sayHello><q0:name>liav-name</q0:name>
>>>> </q0:sayHello></soapenv:Body></soape
>>>> nv:Envelope>
>>>> ] for service: null and interface: null
>>>>
>>>> When i develpoed the WS i tested it via eclipse with success.
>>>>
>>>> Here is the xbean definition:
>>>>
>>>> <http:endpoint service="wsn:LiavHelloImplSvcService"
>>>>                  endpoint="wsn:LiavHelloImplSvc"
>>>>                  role="provider"
>>>>
>>>> locationURI="http://localhost:8080/LiavHello2/services/LiavHelloImplSvc"
>>>>
>>>> wsdlResource="c:/HTTPReceiverServices/LiavHelloImplSvc.wsdl"
>>>>                  defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>>>                  soap="true" />
>>>>
>>>> Why does it report null for the service & interface?
>>>>
>>>> Thanks.
>>>>
>>>> Claus Ibsen-2 wrote:
>>>>>
>>>>> On Sun, Jan 11, 2009 at 9:19 AM, Liav Ezer <li...@gmail.com>
>>>>> wrote:
>>>>>>
>>>>>> Hi Claus,
>>>>>>
>>>>>> Yes, i changed the body (arg2 in the sendBody method) to be a SOAP
>>>>>> request
>>>>>> like the following:
>>>>>>
>>>>>> String request = "<soapenv:Envelope
>>>>>> xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'
>>>>>> xmlns:q0='http://service.app.esb.oxp.liav.com'
>>>>>> xmlns:xsd='http://www.w3.org/2001/XMLSchema'
>>>>>> xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><soapenv:Body><q0:sayHello><q0:name>liav-name</q0:name>
>>>>>> </q0:sayHello></soapenv:Body></soapenv:Envelope>";
>>>>>>
>>>>>> 1. Is it a correct payload to send a request?
>>>>> Yeah it should be something like that. You might need the <?xml
>>>>> version...> header. But try with and without it.
>>>>>
>>>>>
>>>>>>
>>>>>> 2. Does this method will return the provider response - The API shows
>>>>>> that
>>>>>> it returns an Object - should i cast it to be an 'Exchange' & extract
>>>>>> the
>>>>>> response from the provider?
>>>>> When you use Camel's producer template to do a request/reply then
>>>>> Camel will extract the response from the Exchange/IN or OUT/Message,
>>>>> so you just get the payload. The type is Object but it can be what SMX
>>>>> returns, so it could be some sort of XML holder such as
>>>>> org.w3c.Document. But try and see what kind of Object you get back.
>>>>>
>>>>> There are type converters in Camel that can convert it back to a
>>>>> String if you want to use that, or what else there is
>>>>> http://activemq.apache.org/camel/type-converter.html
>>>>>
>>>>>
>>>>>
>>>>>>
>>>>>> Thanks.
>>>>>>
>>>>>> Claus Ibsen-2 wrote:
>>>>>>>
>>>>>>> On Sat, Jan 10, 2009 at 8:51 PM, Liav Ezer <li...@gmail.com>
>>>>>>> wrote:
>>>>>>>>
>>>>>>>> Hi Claus,
>>>>>>>>
>>>>>>>> I changed the notation as needed to:
>>>>>>>>
>>>>>>>> producer.sendBody("jbi:endpoint:http://localhost:8080/LiavHello/services/LiavHelloImpl",
>>>>>>>> "Netania");
>>>>>>>>
>>>>>>>>  SMX console now output some wierd error - googling it comes up
>>>>>>>> with
>>>>>>>> some
>>>>>>>> xml parsing error:
>>>>>>>>
>>>>>>>> [Fatal Error] :1:1: Content is not allowed in prolog.DEBUG -
>>>>>>>> DeliveryChannelImpl            - Exception processing:
>>>>>>>> ID:10.236.11.194-11ec1f3a450-2:291 in
>>>>>>>> DeliveryChannel{servicemix-camel}
>>>>>>>> ERROR - DeadLetterChannel              - Failed delivery for
>>>>>>>> exchangeId:
>>>>>>>> ID-LIAVE02/4519-1231614935663/0-50. On delivery attempt: 0 caught:
>>>>>>>> org.apache
>>>>>>>> org.apache.servicemix.camel.JbiException:
>>>>>>>> javax.jbi.messaging.MessagingException: Could not find route for
>>>>>>>> exchange:
>>>>>>>> InOnly[
>>>>>>>>  id: ID:10.236.11.194-11ec1f3a450-2:291
>>>>>>>>  status: Active
>>>>>>>>  role: provider
>>>>>>> Yeah when you send data to SMX you must remember that its expecting
>>>>>>> the payload to be according to the JBI spec. in XML format. So you
>>>>>>> should send the data as XML.
>>>>>>>
>>>>>>> "Content is not allowed in prolog" is a bit cryptical XML parser
>>>>>>> error
>>>>>>> stating that it could not find the <?xml ... ?> declaration in top
>>>>>>> of
>>>>>>> the content it was parsing.
>>>>>>>
>>>>>>> So you should send the payload as XML.
>>>>>>>
>>>>>>> BTW: Which version of SMX and Camel are you using? I think the
>>>>>>> missing
>>>>>>> method from X mails back could be because we added it in Camel 1.4.0
>>>>>>> (I think).
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> This is the SMX Provider xbean:
>>>>>>>>>
>>>>>>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>>>>>>> <beans xmlns:http="http://servicemix.apache.org/http/1.0"
>>>>>>>>>        xmlns:wsn="http://com.amdocs.oxp/esb"
>>>>>>>>>        xmlns="http://www.springframework.org/schema/beans"
>>>>>>>>>       
>>>>>>>>> xmlns:xsi="http://http://www.w3.org/2001/XMLSchema-instance"
>>>>>>>>>        xsi:schemaLocation="http://servicemix.apache.org/http/1.0
>>>>>>>>> http://servicemix.apache.org/schema/servicemix-http-3.3.1.3-fuse.xsd
>>>>>>>>>        http://www.springframework.org/schema/beans
>>>>>>>>> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
>>>>>>>>>
>>>>>>>>>                 <http:endpoint service="wsn:LiavHelloImplService"
>>>>>>>>>                  endpoint="wsn:LiavHelloImpl"
>>>>>>>>>                  role="provider"
>>>>>>>>>
>>>>>>>>> locationURI="http://localhost:8080/LiavHello/services/LiavHelloImpl"
>>>>>>>>>
>>>>>>>>> wsdlResource="c:/HTTPReceiverServices/LiavHelloImpl.wsdl"
>>>>>>>>>                 
>>>>>>>>> defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>>>>>>>>                  soap="true" />
>>>>>>>>> </beans>
>>>>>>>>> Any clue?
>>>>>>>>> On Sat, Jan 10, 2009 at 4:17 PM, Liav Ezer <li...@gmail.com>
>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>> Hi Claus,
>>>>>>>>>>
>>>>>>>>>> Well i'll stick with the Http SMX provider end-point. I guess
>>>>>>>>>> it's
>>>>>>>>>> should
>>>>>>>>>> integrate with camel routing with no problem.
>>>>>>>>>>
>>>>>>>>>> Ok what i did is the advise you gave me a few answers ago:
>>>>>>>>>>
>>>>>>>>>> ProducerTemplate producer =
>>>>>>>>>> exchange.getContext().createProducerTemplate();
>>>>>>>>>> Object response =
>>>>>>>>>> producer.sendBody("http://localhost:8080/LiavHello/services/LiavHelloImpl",
>>>>>>>>>> "Daviv");
>>>>>>>>> See below
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> And got this exception (SMX console after deply):
>>>>>>>>>>
>>>>>>>>>> : No endpoint could be found for:
>>>>>>>>>> http://localhost:8080/LiavHello/services/LiavHelloImpl
>>>>>>>>>> org.apache.camel.NoSuchEndpointException: No endpoint could be
>>>>>>>>>> found
>>>>>>>>>> for:
>>>>>>>>>> http://localhost:8080/LiavHello/services/LiavHelloImpl
>>>>>>>>>>
>>>>>>>>>> LiavHelloImpl is the wsdlsoap:address location of the wsdl file
>>>>>>>>>> representing
>>>>>>>>>> the LiavHelloImp web project (under a running tomcat 6.0).
>>>>>>>>>>
>>>>>>>>>> Can you advise? It seems that the routing trying to be
>>>>>>>>>> accomplished
>>>>>>>>>> but
>>>>>>>>>> something "configi" is messed up.
>>>>>>>>>>
>>>>>>>>>> Here is my provider xbean:
>>>>>>>>>>
>>>>>>>>>> <http:endpoint service="wsn:LiavHelloImplService"
>>>>>>>>>>                 endpoint="wsn:LiavHelloImpl"
>>>>>>>>>>                 role="provider"
>>>>>>>>>>
>>>>>>>>>> locationURI="http://localhost:8080/LiavHello/services/LiavHelloImpl"
>>>>>>>>>>
>>>>>>>>>> wsdlResource="c:/HTTPReceiverServices/LiavHelloImpl.wsdl"
>>>>>>>>>>                
>>>>>>>>>> defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>>>>>>>>>                 soap="true" />
>>>>>>>>> When you want from Camel to call service on SMX then you must use
>>>>>>>>> the
>>>>>>>>> camel-jbi component that delegates to the SU in SMX.
>>>>>>>>> So you need to add the jbi prefix in front.
>>>>>>>>> See: http://activemq.apache.org/camel/jbi.html
>>>>>>>>>
>>>>>>>>> It should be something like this. By by all means I am not SMX
>>>>>>>>> expert
>>>>>>>>> (yet):
>>>>>>>>> producer.sendBody("jbi:service:wsn:LiavHelloImplService",
>>>>>>>>> "Daviv");
>>>>>>>>>
>>>>>>>>> The jbi component have different notation so please check it out.
>>>>>>>>>
>>>>>>>>> If you manage to get it working, then please write back how to, so
>>>>>>>>> we
>>>>>>>>> can improve the documentation and help others in the future.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Thanks!
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>>>>
>>>>>>>>>>> On Sat, Jan 10, 2009 at 3:02 PM, Liav Ezer <li...@gmail.com>
>>>>>>>>>>> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>> Hi Claus,
>>>>>>>>>>>>
>>>>>>>>>>>> I did follow this camel example & set up a timer 'from'
>>>>>>>>>>>> end-point
>>>>>>>>>>>> which
>>>>>>>>>>>> my
>>>>>>>>>>>> processor 'catched'.
>>>>>>>>>>>>
>>>>>>>>>>>> My will is to query this 'catched' data by sending it to a
>>>>>>>>>>>> different
>>>>>>>>>>>> end-point such as a service provider.
>>>>>>>>>>>>
>>>>>>>>>>>> Therefore, i deployed two SU's in my servicemix: One for the
>>>>>>>>>>>> camel
>>>>>>>>>>>> routing
>>>>>>>>>>>> (timer example) & two is for
>>>>>>>>>>>>
>>>>>>>>>>>> the HTTP servicemix provider which i want to invoke in the
>>>>>>>>>>>> proceesor.
>>>>>>>>>>>>
>>>>>>>>>>>> My question seems simple as long as an API exists for it:
>>>>>>>>>>>>
>>>>>>>>>>>> When my Processor class is instansiated than the process()
>>>>>>>>>>>> method
>>>>>>>>>>>> is
>>>>>>>>>>>> invoked:
>>>>>>>>>>>>
>>>>>>>>>>>> public void process(Exchange exchange) throws Exception {
>>>>>>>>>>>>
>>>>>>>>>>>> The exchange.getIn() consist my 'from' end-point data (=the
>>>>>>>>>>>> timer).
>>>>>>>>>>>>
>>>>>>>>>>>> I need the API to fetch the Http servicemix provider end-point
>>>>>>>>>>>> &
>>>>>>>>>>>> to
>>>>>>>>>>>> send
>>>>>>>>>>>> hime a request with this data.
>>>>>>>>>>> If you want to send FROM Camel to SMX then you need to use the
>>>>>>>>>>> camel-jbi component. That is you get endpoints FROM Camel
>>>>>>>>>>> starting
>>>>>>>>>>> with the "jbi:" prefix. See camel-jbi component.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> One extra small question: Do i need to replace my provider SU
>>>>>>>>>>>> with a
>>>>>>>>>>>> camel
>>>>>>>>>>>> http producer SU?
>>>>>>>>>>> If you are using SMX 3.x then you dont as SMX has one SU for
>>>>>>>>>>> Camel.
>>>>>>>>>>> However if you need to use any of the other camel components
>>>>>>>>>>> from
>>>>>>>>>>> SMX
>>>>>>>>>>> you need to have them in the classpath as well, such as
>>>>>>>>>>> camel-http.jar.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> (In SMX 4.x its all OSGi land and you need to install features
>>>>>>>>>>> into
>>>>>>>>>>> SMX.)
>>>>>>>>>>>
>>>>>>>>>>> A bit confused now. Which http provider do you want to use?
>>>>>>>>>>> - SMX Http provider
>>>>>>>>>>> - Camel http provider
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> Thanks.
>>>>>>>>>>>>
>>>>>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>> Hi
>>>>>>>>>>>>>
>>>>>>>>>>>>> Yeah its a bit mixed up since Camel and ServiceMix have
>>>>>>>>>>>>> classes
>>>>>>>>>>>>> with
>>>>>>>>>>>>> common name: Endpoint, Exchange etc.
>>>>>>>>>>>>>
>>>>>>>>>>>>> All the code I have shown assumes pure Camel code.
>>>>>>>>>>>>>
>>>>>>>>>>>>> I advice to check the ServceMix docu about using Camel in
>>>>>>>>>>>>> ServiceMix.
>>>>>>>>>>>>> And get a basic example running. Such as this example
>>>>>>>>>>>>> http://servicemix.apache.org/camel-example.html
>>>>>>>>>>>>>
>>>>>>>>>>>>> You could use that as a starting point to get Camel invoking
>>>>>>>>>>>>> your
>>>>>>>>>>>>> HTTP
>>>>>>>>>>>>> server. Just let the timer start it.
>>>>>>>>>>>>> Then later your can connect using SMX instead of the camel
>>>>>>>>>>>>> timer.
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> On Sat, Jan 10, 2009 at 12:53 PM, Liav Ezer
>>>>>>>>>>>>> <li...@gmail.com>
>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Hi Claus again,
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> I addition to what i asked in my previouse response here is a
>>>>>>>>>>>>>> question
>>>>>>>>>>>>>> regarding the producer snippet which you gave in your last
>>>>>>>>>>>>>> answer:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> I indeed wrote the following in my process() method:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> ProducerTemplate producer =
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> exchange.getCamelContext().createProducerTemplate();
>>>>>>>>>>>>>>                            Object response =
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> producer.sendBody("http://myserver.com/myapp?foo=bar", "Liav
>>>>>>>>>>>>>> Camel
>>>>>>>>>>>>>> POC");
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> but i don't have the camel context at hand (saying "The
>>>>>>>>>>>>>> method
>>>>>>>>>>>>>> getCamelContext() is undefined for the type Exchange").
>>>>>>>>>>>>>>  & also do i need to deploy a camel http producer su instead
>>>>>>>>>>>>>> of
>>>>>>>>>>>>>> an
>>>>>>>>>>>>>> http
>>>>>>>>>>>>>> service mix provider?
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Hi
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> When you are working with ServiceMix you must use the JBI
>>>>>>>>>>>>>>> component
>>>>>>>>>>>>>>> in
>>>>>>>>>>>>>>> Camel
>>>>>>>>>>>>>>> http://activemq.apache.org/camel/jbi.html
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> So your endpoints should starting with "jbi:XXXX"
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> And ServiceMix has some Camel docu here:
>>>>>>>>>>>>>>> http://servicemix.apache.org/servicemix-camel.html
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Could you take a look at this docu a bit. There might be
>>>>>>>>>>>>>>> some
>>>>>>>>>>>>>>> help
>>>>>>>>>>>>>>> there.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Try to get something more easier working with SMX and Camel
>>>>>>>>>>>>>>> and
>>>>>>>>>>>>>>> then
>>>>>>>>>>>>>>> later do the stuff you want with the dynamic add a camel
>>>>>>>>>>>>>>> context.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> On Sat, Jan 10, 2009 at 12:39 PM, Liav Ezer
>>>>>>>>>>>>>>> <li...@gmail.com>
>>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Hi Claus,
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> I read your tutorial & learnt from it. Thanks. I adopted
>>>>>>>>>>>>>>>> the
>>>>>>>>>>>>>>>> cxf
>>>>>>>>>>>>>>>> framework
>>>>>>>>>>>>>>>> for now.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Regarding my project (as stated above in snippets):
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> I planted the following camel routing logic at my processor
>>>>>>>>>>>>>>>> class:
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> process method - with camel:
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> public void process(Exchange exchange) throws Exception {
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>  CamelContext camel = new DefaultCamelContext();
>>>>>>>>>>>>>>>>  camel.start();
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>  Component component = (Component)
>>>>>>>>>>>>>>>> camel.getComponent("http-provider-su");
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>  Endpoint endpoint = (Endpoint)
>>>>>>>>>>>>>>>> ((org.apache.camel.Component)
>>>>>>>>>>>>>>>> component).createEndpoint("provider:com.amdocs.oxp.esb");
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>  exchange.getIn().setBody("Liav testing here!");
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>  Producer producer = ((org.apache.camel.Endpoint)
>>>>>>>>>>>>>>>> endpoint).createProducer();
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>  producer.start();
>>>>>>>>>>>>>>>>  producer.process(exchange);
>>>>>>>>>>>>>>>>  producer.stop();
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>  //System.out.println(exchange.getIn().toString() +
>>>>>>>>>>>>>>>> "process
>>>>>>>>>>>>>>>> activated
>>>>>>>>>>>>>>>> by
>>>>>>>>>>>>>>>> SU");
>>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> And got the following exception while SA's jar was
>>>>>>>>>>>>>>>> deployed:
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> ERROR - DeadLetterChannel              - Failed delivery
>>>>>>>>>>>>>>>> for
>>>>>>>>>>>>>>>> exchangeId:
>>>>>>>>>>>>>>>> ID-LIAVE02/1885-1231586726193/0-0. On delivery attemp
>>>>>>>>>>>>>>>> java.lang.NullPointerException
>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>> org.apache.servicemix.tutorial.camel.MyProcessor.process(MyProcessor.java:33)
>>>>>>>>>>>>>>>> at
>>>>>>>>>>>>>>>> org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:92)
>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>> org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:66)
>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>> org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorT
>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:75)
>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:146)
>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:90)
>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>> org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>> org.apache.camel.processor.Pipeline.process(Pipeline.java:85)
>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:39)
>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>> org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:91)
>>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>>> org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:48)
>>>>>>>>>>>>>>>>        at java.util.TimerThread.mainLoop(Timer.java:512)
>>>>>>>>>>>>>>>>        at java.util.TimerThread.run(Timer.java:462)
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Be advise that line 33 is:Endpoint endpoint = (Endpoint)
>>>>>>>>>>>>>>>> ((org.apache.camel.Component)
>>>>>>>>>>>>>>>> component).createEndpoint("provider:com.amdocs.oxp.esb");
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> My questions:
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> 1. As bolded above i "fetched" my provider su component by
>>>>>>>>>>>>>>>> staing
>>>>>>>>>>>>>>>> it's
>>>>>>>>>>>>>>>> name
>>>>>>>>>>>>>>>> - is it correct?
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> 2. I used the following servicemix object (not camel's)
>>>>>>>>>>>>>>>> since
>>>>>>>>>>>>>>>> i
>>>>>>>>>>>>>>>> work
>>>>>>>>>>>>>>>> with
>>>>>>>>>>>>>>>> servicemix provider endpoint. That's the reason for all the
>>>>>>>>>>>>>>>> casting
>>>>>>>>>>>>>>>> in
>>>>>>>>>>>>>>>> my
>>>>>>>>>>>>>>>> code:
>>>>>>>>>>>>>>>> import org.apache.servicemix.jbi.deployment.Component;
>>>>>>>>>>>>>>>> import org.apache.servicemix.jbi.framework.Endpoint;
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Is it correct?
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Thank again,
>>>>>>>>>>>>>>>> Liav Ezer.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> Hi
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> You can use the producer template to call an external http
>>>>>>>>>>>>>>>>> server
>>>>>>>>>>>>>>>>> and
>>>>>>>>>>>>>>>>> get the response.
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> See this tutorial:
>>>>>>>>>>>>>>>>> http://activemq.apache.org/camel/tutorial-axis-camel.html
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> From the section - integrating Camel
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> Its kinda the same but its just uses the producer template
>>>>>>>>>>>>>>>>> to
>>>>>>>>>>>>>>>>> save
>>>>>>>>>>>>>>>>> a
>>>>>>>>>>>>>>>>> file. Its the same API for using any of the camel
>>>>>>>>>>>>>>>>> components.
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> Little sidenote:
>>>>>>>>>>>>>>>>> And since you use InOut you should use: requestBody
>>>>>>>>>>>>>>>>> instread
>>>>>>>>>>>>>>>>> of
>>>>>>>>>>>>>>>>> sendBody. However Camel is not to stricky about this yet
>>>>>>>>>>>>>>>>> so
>>>>>>>>>>>>>>>>> if
>>>>>>>>>>>>>>>>> you
>>>>>>>>>>>>>>>>> use
>>>>>>>>>>>>>>>>> a send instead of request then it should work as well.
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> The demo shows how to inject a producer template from
>>>>>>>>>>>>>>>>> spring
>>>>>>>>>>>>>>>>> into
>>>>>>>>>>>>>>>>> your
>>>>>>>>>>>>>>>>> bean class = your processor. when you have this template
>>>>>>>>>>>>>>>>> you
>>>>>>>>>>>>>>>>> can
>>>>>>>>>>>>>>>>> call
>>>>>>>>>>>>>>>>> the external http server and get the response using the
>>>>>>>>>>>>>>>>> requestBody
>>>>>>>>>>>>>>>>> method.
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> On Thu, Jan 8, 2009 at 1:46 PM, Liav Ezer
>>>>>>>>>>>>>>>>> <li...@gmail.com>
>>>>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> Hi,
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> Here is my camel-context:
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>  <camelContext id="camel"
>>>>>>>>>>>>>>>>>> xmlns="http://activemq.apache.org/camel/schema/spring">
>>>>>>>>>>>>>>>>>>   
>>>>>>>>>>>>>>>>>> <package>org.apache.servicemix.tutorial.camel</package>
>>>>>>>>>>>>>>>>>>  </camelContext>
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>  <bean id="myProcessor"
>>>>>>>>>>>>>>>>>> class="org.apache.servicemix.tutorial.camel.MyProcessor"/>
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> Here is my RouteBuilder java file:
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> public class MyRouteBuilder extends RouteBuilder {
>>>>>>>>>>>>>>>>>>        public void configure() {
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> from("timer://tutorial?fixedRate=true&delay=3000&period=10000")
>>>>>>>>>>>>>>>>>>               
>>>>>>>>>>>>>>>>>> .setBody(constant(".....................Liav
>>>>>>>>>>>>>>>>>> Camel
>>>>>>>>>>>>>>>>>> POC......................."))
>>>>>>>>>>>>>>>>>>                        .to("myProcessor");
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>    }
>>>>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> Here is my processor java file:
>>>>>>>>>>>>>>>>>> public class MyProcessor implements Processor {
>>>>>>>>>>>>>>>>>>          public void process(Exchange exchange) throws
>>>>>>>>>>>>>>>>>> Exception
>>>>>>>>>>>>>>>>>> {
>>>>>>>>>>>>>>>>>>              //WANT TO INITIATE A CALL TO http pROVIDER
>>>>>>>>>>>>>>>>>> END
>>>>>>>>>>>>>>>>>> POINT
>>>>>>>>>>>>>>>>>> &
>>>>>>>>>>>>>>>>>> PASS
>>>>>>>>>>>>>>>>>> THE
>>>>>>>>>>>>>>>>>> 'FROM'
>>>>>>>>>>>>>>>>>>                  // PARAMETRS RECIEVED PROIRE TO THE
>>>>>>>>>>>>>>>>>> PROCESSOR
>>>>>>>>>>>>>>>>>> INVOKE.
>>>>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> Thanks.
>>>>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>>>> View this message in context:
>>>>>>>>>>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21351142.html
>>>>>>>>>>>>>>>>>> Sent from the Camel - Users mailing list archive at
>>>>>>>>>>>>>>>>>> Nabble.com.
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> /Claus Ibsen
>>>>>>>>>>>>>>>>> Apache Camel Committer
>>>>>>>>>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>> View this message in context:
>>>>>>>>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21387207.html
>>>>>>>>>>>>>>>> Sent from the Camel - Users mailing list archive at
>>>>>>>>>>>>>>>> Nabble.com.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> /Claus Ibsen
>>>>>>>>>>>>>>> Apache Camel Committer
>>>>>>>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> --
>>>>>>>>>>>>>> View this message in context:
>>>>>>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21387318.html
>>>>>>>>>>>>>> Sent from the Camel - Users mailing list archive at
>>>>>>>>>>>>>> Nabble.com.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> --
>>>>>>>>>>>>>
>>>>>>>>>>>>> /Claus Ibsen
>>>>>>>>>>>>> Apache Camel Committer
>>>>>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> --
>>>>>>>>>>>> View this message in context:
>>>>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21388391.html
>>>>>>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>>>
>>>>>>>>>>> /Claus Ibsen
>>>>>>>>>>> Apache Camel Committer
>>>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> View this message in context:
>>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21389069.html
>>>>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>>
>>>>>>>>> /Claus Ibsen
>>>>>>>>> Apache Camel Committer
>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> View this message in context:
>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21390941.html
>>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>>
>>>>>>> /Claus Ibsen
>>>>>>> Apache Camel Committer
>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> --
>>>>>> View this message in context:
>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21396985.html
>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>>
>>>>> /Claus Ibsen
>>>>> Apache Camel Committer
>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21412377.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> 
> /Claus Ibsen
> Apache Camel Committer
> Blog: http://davsclaus.blogspot.com/
> 
> 

-- 
View this message in context: http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21413291.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: How do i call an HTTP Provider end-pont from the process method?

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

SMX is more strict with setting the correct exchange pattern
- InOnly
- InOut
etc

We get this from the log
> Error processing exchange InOnly

So you should use InOut from Camel as its a http component that
expects an InOut exchange pattern

This is done by using the requestBody method instread of sendBody in
the producer template

So it should be:
producer.requestBody("jbi:service:http://com.amdocs.oxp/esb/LiavHelloImplSvcService",
request);



On Mon, Jan 12, 2009 at 12:03 PM, Liav Ezer <li...@gmail.com> wrote:
>
> Hi Claus,
>
> Ok, I progressed a bit but still has the a problem consuming my WS.
>
> Here is my Processor code (producer.sendBody() first arg' has changed).
>
> public void process(Exchange exchange) throws Exception {
>          ProducerTemplate producer =
> exchange.getContext().createProducerTemplate();
>          String payload = exchange.getIn().getBody(String.class); // == liav
>          String request = "<?xml version=\"1.0\"
> encoding=\"UTF-8\"?><soapenv:Body><sayHello><name>"+payload+"</name></sayHello></soapenv:Body>";
>          Object response =
> producer.sendBody("jbi:service:http://com.amdocs.oxp/esb/LiavHelloImplSvcService",
> request);
> }
>
> This is the xbean of the SMX http Provider:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns:http="http://servicemix.apache.org/http/1.0"
>       xmlns:wsn="http://com.amdocs.oxp/esb"
>       xmlns="http://www.springframework.org/schema/beans"
>       xmlns:xsi="http://http://www.w3.org/2001/XMLSchema-instance"
>       xsi:schemaLocation="http://servicemix.apache.org/http/1.0
> http://servicemix.apache.org/schema/servicemix-http-3.3.1.3-fuse.xsd
>       http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
>
>           <http:endpoint service="wsn:LiavHelloImplSvcService"
>                 endpoint="wsn:LiavHelloImplSvc"
>                 role="provider"
>
> locationURI="http://localhost:8080/LiavHello2/services/LiavHelloImplSvc"
>
> wsdlResource="c:/HTTPReceiverServices/LiavHelloImplSvc.wsdl"
>                 defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>                 soap="true" />
> </beans>
>
> My question:
>
> By looking at the end-point invoke (via the producerTemplate) & at the
> end-point config (xbean file),
>
> do you see a reason why my WS (LiavHelloImplSvcService) isn't consumed?
>
> Here is the current SMX log after deployment:
>
> ERROR - HttpComponent                  - Error processing exchange InOnly[
>  id: ID:10.236.11.194-11eca7dd5b2-2:8
>  status: Active
>  role: provider
>  service: {http://com.amdocs.oxp/esb}LiavHelloImplSvcService
>  endpoint: wsn:LiavHelloImplSvc
>  in: <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:q0="http://service.app.esb.oxp.amdocs.com" xmlns:xsd="
> http://www.w3.org/2001/XMLSchema"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><q0:sayHello><q0:name>LiavFromRouterBuilder</q0:name></q0:sayHello></soapenv:B
> ody></soapenv:Envelope>
> ]
> java.lang.Exception: Invalid status response: 500
> Thanks.
>
> Liav Ezer wrote:
>>
>> Hi Claus,
>>
>> What i managed to accomplish is that my producer is 'familiar' with my
>> Provider end-point but from some reason it doesn't invoke my service (WS)
>> & hence report an invalide status response (500).
>>
>> ERROR - HttpComponent                  - Error processing exchange InOnly[
>>   id: ID:10.236.11.194-11ec622522e-2:96
>>   status: Active
>>   role: provider
>>   service: {http://com.amdocs.oxp/esb}LiavHelloImplSvcService
>>   endpoint: wsn:LiavHelloImplSvc
>>   in: <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
>> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
>> xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http
>> ://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><sayHello><name>Liav</name></sayHello></soapenv:Body></soapenv:Envelope>
>> ]
>>
>> This is my xbean.xml (it must be related to the end-point configuration):
>>
>> <http:endpoint service="wsn:LiavHelloImplSvcService"
>>                  endpoint="wsn:LiavHelloImplSvc"
>>                  role="provider"
>>
>> locationURI="http://localhost:8080/LiavHello2/services/LiavHelloImplSvc"
>>
>> wsdlResource="c:/HTTPReceiverServices/LiavHelloImplSvc.wsdl"
>>                  defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>                  soap="true" />
>>
>> Thanks.
>> java.lang.Exception: Invalid status response: 500
>>
>>
>>
>>
>>
>> Liav Ezer wrote:
>>>
>>> Hi Claus,
>>>
>>> I'm stuck with a problem that my servixmix is reporting a try to send a
>>> request to the provider but appearantly it's not able to consume the
>>> Provider's WS.
>>>
>>> Here is the console:
>>>
>>> ERROR - DeadLetterChannel              - Failed delivery for exchangeId:
>>> ID-LIAVE02/1441-1231673232762/0-2. On delivery attempt: 0 caught:
>>> org.apache.camel.RuntimeCamelException: o
>>> rg.apache.servicemix.camel.JbiException:
>>> javax.jbi.messaging.MessagingException: Could not find route for
>>> exchange: InOnly[
>>>   id: ID:10.236.11.194-11ec5713753-2:7
>>>   status: Active
>>>   role: provider
>>> in: <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
>>> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
>>> xmlns:q0="http://service.app.esb.oxp.amdocs.com" xmlns:xsd="
>>> http://www.w3.org/2001/XMLSchema"
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><q0:sayHello><q0:name>liav-name</q0:name>
>>> </q0:sayHello></soapenv:Body></soape
>>> nv:Envelope>
>>> ] for service: null and interface: null
>>>
>>> When i develpoed the WS i tested it via eclipse with success.
>>>
>>> Here is the xbean definition:
>>>
>>> <http:endpoint service="wsn:LiavHelloImplSvcService"
>>>                  endpoint="wsn:LiavHelloImplSvc"
>>>                  role="provider"
>>>
>>> locationURI="http://localhost:8080/LiavHello2/services/LiavHelloImplSvc"
>>>
>>> wsdlResource="c:/HTTPReceiverServices/LiavHelloImplSvc.wsdl"
>>>                  defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>>                  soap="true" />
>>>
>>> Why does it report null for the service & interface?
>>>
>>> Thanks.
>>>
>>> Claus Ibsen-2 wrote:
>>>>
>>>> On Sun, Jan 11, 2009 at 9:19 AM, Liav Ezer <li...@gmail.com> wrote:
>>>>>
>>>>> Hi Claus,
>>>>>
>>>>> Yes, i changed the body (arg2 in the sendBody method) to be a SOAP
>>>>> request
>>>>> like the following:
>>>>>
>>>>> String request = "<soapenv:Envelope
>>>>> xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'
>>>>> xmlns:q0='http://service.app.esb.oxp.liav.com'
>>>>> xmlns:xsd='http://www.w3.org/2001/XMLSchema'
>>>>> xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><soapenv:Body><q0:sayHello><q0:name>liav-name</q0:name>
>>>>> </q0:sayHello></soapenv:Body></soapenv:Envelope>";
>>>>>
>>>>> 1. Is it a correct payload to send a request?
>>>> Yeah it should be something like that. You might need the <?xml
>>>> version...> header. But try with and without it.
>>>>
>>>>
>>>>>
>>>>> 2. Does this method will return the provider response - The API shows
>>>>> that
>>>>> it returns an Object - should i cast it to be an 'Exchange' & extract
>>>>> the
>>>>> response from the provider?
>>>> When you use Camel's producer template to do a request/reply then
>>>> Camel will extract the response from the Exchange/IN or OUT/Message,
>>>> so you just get the payload. The type is Object but it can be what SMX
>>>> returns, so it could be some sort of XML holder such as
>>>> org.w3c.Document. But try and see what kind of Object you get back.
>>>>
>>>> There are type converters in Camel that can convert it back to a
>>>> String if you want to use that, or what else there is
>>>> http://activemq.apache.org/camel/type-converter.html
>>>>
>>>>
>>>>
>>>>>
>>>>> Thanks.
>>>>>
>>>>> Claus Ibsen-2 wrote:
>>>>>>
>>>>>> On Sat, Jan 10, 2009 at 8:51 PM, Liav Ezer <li...@gmail.com>
>>>>>> wrote:
>>>>>>>
>>>>>>> Hi Claus,
>>>>>>>
>>>>>>> I changed the notation as needed to:
>>>>>>>
>>>>>>> producer.sendBody("jbi:endpoint:http://localhost:8080/LiavHello/services/LiavHelloImpl",
>>>>>>> "Netania");
>>>>>>>
>>>>>>>  SMX console now output some wierd error - googling it comes up with
>>>>>>> some
>>>>>>> xml parsing error:
>>>>>>>
>>>>>>> [Fatal Error] :1:1: Content is not allowed in prolog.DEBUG -
>>>>>>> DeliveryChannelImpl            - Exception processing:
>>>>>>> ID:10.236.11.194-11ec1f3a450-2:291 in
>>>>>>> DeliveryChannel{servicemix-camel}
>>>>>>> ERROR - DeadLetterChannel              - Failed delivery for
>>>>>>> exchangeId:
>>>>>>> ID-LIAVE02/4519-1231614935663/0-50. On delivery attempt: 0 caught:
>>>>>>> org.apache
>>>>>>> org.apache.servicemix.camel.JbiException:
>>>>>>> javax.jbi.messaging.MessagingException: Could not find route for
>>>>>>> exchange:
>>>>>>> InOnly[
>>>>>>>  id: ID:10.236.11.194-11ec1f3a450-2:291
>>>>>>>  status: Active
>>>>>>>  role: provider
>>>>>> Yeah when you send data to SMX you must remember that its expecting
>>>>>> the payload to be according to the JBI spec. in XML format. So you
>>>>>> should send the data as XML.
>>>>>>
>>>>>> "Content is not allowed in prolog" is a bit cryptical XML parser error
>>>>>> stating that it could not find the <?xml ... ?> declaration in top of
>>>>>> the content it was parsing.
>>>>>>
>>>>>> So you should send the payload as XML.
>>>>>>
>>>>>> BTW: Which version of SMX and Camel are you using? I think the missing
>>>>>> method from X mails back could be because we added it in Camel 1.4.0
>>>>>> (I think).
>>>>>>
>>>>>>
>>>>>>
>>>>>>>
>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> This is the SMX Provider xbean:
>>>>>>>>
>>>>>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>>>>>> <beans xmlns:http="http://servicemix.apache.org/http/1.0"
>>>>>>>>        xmlns:wsn="http://com.amdocs.oxp/esb"
>>>>>>>>        xmlns="http://www.springframework.org/schema/beans"
>>>>>>>>        xmlns:xsi="http://http://www.w3.org/2001/XMLSchema-instance"
>>>>>>>>        xsi:schemaLocation="http://servicemix.apache.org/http/1.0
>>>>>>>> http://servicemix.apache.org/schema/servicemix-http-3.3.1.3-fuse.xsd
>>>>>>>>        http://www.springframework.org/schema/beans
>>>>>>>> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
>>>>>>>>
>>>>>>>>                 <http:endpoint service="wsn:LiavHelloImplService"
>>>>>>>>                  endpoint="wsn:LiavHelloImpl"
>>>>>>>>                  role="provider"
>>>>>>>>
>>>>>>>> locationURI="http://localhost:8080/LiavHello/services/LiavHelloImpl"
>>>>>>>>
>>>>>>>> wsdlResource="c:/HTTPReceiverServices/LiavHelloImpl.wsdl"
>>>>>>>>                  defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>>>>>>>                  soap="true" />
>>>>>>>> </beans>
>>>>>>>> Any clue?
>>>>>>>> On Sat, Jan 10, 2009 at 4:17 PM, Liav Ezer <li...@gmail.com>
>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>> Hi Claus,
>>>>>>>>>
>>>>>>>>> Well i'll stick with the Http SMX provider end-point. I guess it's
>>>>>>>>> should
>>>>>>>>> integrate with camel routing with no problem.
>>>>>>>>>
>>>>>>>>> Ok what i did is the advise you gave me a few answers ago:
>>>>>>>>>
>>>>>>>>> ProducerTemplate producer =
>>>>>>>>> exchange.getContext().createProducerTemplate();
>>>>>>>>> Object response =
>>>>>>>>> producer.sendBody("http://localhost:8080/LiavHello/services/LiavHelloImpl",
>>>>>>>>> "Daviv");
>>>>>>>> See below
>>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>> And got this exception (SMX console after deply):
>>>>>>>>>
>>>>>>>>> : No endpoint could be found for:
>>>>>>>>> http://localhost:8080/LiavHello/services/LiavHelloImpl
>>>>>>>>> org.apache.camel.NoSuchEndpointException: No endpoint could be
>>>>>>>>> found
>>>>>>>>> for:
>>>>>>>>> http://localhost:8080/LiavHello/services/LiavHelloImpl
>>>>>>>>>
>>>>>>>>> LiavHelloImpl is the wsdlsoap:address location of the wsdl file
>>>>>>>>> representing
>>>>>>>>> the LiavHelloImp web project (under a running tomcat 6.0).
>>>>>>>>>
>>>>>>>>> Can you advise? It seems that the routing trying to be accomplished
>>>>>>>>> but
>>>>>>>>> something "configi" is messed up.
>>>>>>>>>
>>>>>>>>> Here is my provider xbean:
>>>>>>>>>
>>>>>>>>> <http:endpoint service="wsn:LiavHelloImplService"
>>>>>>>>>                 endpoint="wsn:LiavHelloImpl"
>>>>>>>>>                 role="provider"
>>>>>>>>>
>>>>>>>>> locationURI="http://localhost:8080/LiavHello/services/LiavHelloImpl"
>>>>>>>>>
>>>>>>>>> wsdlResource="c:/HTTPReceiverServices/LiavHelloImpl.wsdl"
>>>>>>>>>                 defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>>>>>>>>                 soap="true" />
>>>>>>>> When you want from Camel to call service on SMX then you must use
>>>>>>>> the
>>>>>>>> camel-jbi component that delegates to the SU in SMX.
>>>>>>>> So you need to add the jbi prefix in front.
>>>>>>>> See: http://activemq.apache.org/camel/jbi.html
>>>>>>>>
>>>>>>>> It should be something like this. By by all means I am not SMX
>>>>>>>> expert
>>>>>>>> (yet):
>>>>>>>> producer.sendBody("jbi:service:wsn:LiavHelloImplService", "Daviv");
>>>>>>>>
>>>>>>>> The jbi component have different notation so please check it out.
>>>>>>>>
>>>>>>>> If you manage to get it working, then please write back how to, so
>>>>>>>> we
>>>>>>>> can improve the documentation and help others in the future.
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>> Thanks!
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>>>
>>>>>>>>>> On Sat, Jan 10, 2009 at 3:02 PM, Liav Ezer <li...@gmail.com>
>>>>>>>>>> wrote:
>>>>>>>>>>>
>>>>>>>>>>> Hi Claus,
>>>>>>>>>>>
>>>>>>>>>>> I did follow this camel example & set up a timer 'from' end-point
>>>>>>>>>>> which
>>>>>>>>>>> my
>>>>>>>>>>> processor 'catched'.
>>>>>>>>>>>
>>>>>>>>>>> My will is to query this 'catched' data by sending it to a
>>>>>>>>>>> different
>>>>>>>>>>> end-point such as a service provider.
>>>>>>>>>>>
>>>>>>>>>>> Therefore, i deployed two SU's in my servicemix: One for the
>>>>>>>>>>> camel
>>>>>>>>>>> routing
>>>>>>>>>>> (timer example) & two is for
>>>>>>>>>>>
>>>>>>>>>>> the HTTP servicemix provider which i want to invoke in the
>>>>>>>>>>> proceesor.
>>>>>>>>>>>
>>>>>>>>>>> My question seems simple as long as an API exists for it:
>>>>>>>>>>>
>>>>>>>>>>> When my Processor class is instansiated than the process() method
>>>>>>>>>>> is
>>>>>>>>>>> invoked:
>>>>>>>>>>>
>>>>>>>>>>> public void process(Exchange exchange) throws Exception {
>>>>>>>>>>>
>>>>>>>>>>> The exchange.getIn() consist my 'from' end-point data (=the
>>>>>>>>>>> timer).
>>>>>>>>>>>
>>>>>>>>>>> I need the API to fetch the Http servicemix provider end-point &
>>>>>>>>>>> to
>>>>>>>>>>> send
>>>>>>>>>>> hime a request with this data.
>>>>>>>>>> If you want to send FROM Camel to SMX then you need to use the
>>>>>>>>>> camel-jbi component. That is you get endpoints FROM Camel starting
>>>>>>>>>> with the "jbi:" prefix. See camel-jbi component.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> One extra small question: Do i need to replace my provider SU
>>>>>>>>>>> with a
>>>>>>>>>>> camel
>>>>>>>>>>> http producer SU?
>>>>>>>>>> If you are using SMX 3.x then you dont as SMX has one SU for
>>>>>>>>>> Camel.
>>>>>>>>>> However if you need to use any of the other camel components from
>>>>>>>>>> SMX
>>>>>>>>>> you need to have them in the classpath as well, such as
>>>>>>>>>> camel-http.jar.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> (In SMX 4.x its all OSGi land and you need to install features
>>>>>>>>>> into
>>>>>>>>>> SMX.)
>>>>>>>>>>
>>>>>>>>>> A bit confused now. Which http provider do you want to use?
>>>>>>>>>> - SMX Http provider
>>>>>>>>>> - Camel http provider
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Thanks.
>>>>>>>>>>>
>>>>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>>>>>
>>>>>>>>>>>> Hi
>>>>>>>>>>>>
>>>>>>>>>>>> Yeah its a bit mixed up since Camel and ServiceMix have classes
>>>>>>>>>>>> with
>>>>>>>>>>>> common name: Endpoint, Exchange etc.
>>>>>>>>>>>>
>>>>>>>>>>>> All the code I have shown assumes pure Camel code.
>>>>>>>>>>>>
>>>>>>>>>>>> I advice to check the ServceMix docu about using Camel in
>>>>>>>>>>>> ServiceMix.
>>>>>>>>>>>> And get a basic example running. Such as this example
>>>>>>>>>>>> http://servicemix.apache.org/camel-example.html
>>>>>>>>>>>>
>>>>>>>>>>>> You could use that as a starting point to get Camel invoking
>>>>>>>>>>>> your
>>>>>>>>>>>> HTTP
>>>>>>>>>>>> server. Just let the timer start it.
>>>>>>>>>>>> Then later your can connect using SMX instead of the camel
>>>>>>>>>>>> timer.
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> On Sat, Jan 10, 2009 at 12:53 PM, Liav Ezer
>>>>>>>>>>>> <li...@gmail.com>
>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>> Hi Claus again,
>>>>>>>>>>>>>
>>>>>>>>>>>>> I addition to what i asked in my previouse response here is a
>>>>>>>>>>>>> question
>>>>>>>>>>>>> regarding the producer snippet which you gave in your last
>>>>>>>>>>>>> answer:
>>>>>>>>>>>>>
>>>>>>>>>>>>> I indeed wrote the following in my process() method:
>>>>>>>>>>>>>
>>>>>>>>>>>>> ProducerTemplate producer =
>>>>>>>>>>>>>
>>>>>>>>>>>>> exchange.getCamelContext().createProducerTemplate();
>>>>>>>>>>>>>                            Object response =
>>>>>>>>>>>>>
>>>>>>>>>>>>> producer.sendBody("http://myserver.com/myapp?foo=bar", "Liav
>>>>>>>>>>>>> Camel
>>>>>>>>>>>>> POC");
>>>>>>>>>>>>>
>>>>>>>>>>>>> but i don't have the camel context at hand (saying "The method
>>>>>>>>>>>>> getCamelContext() is undefined for the type Exchange").
>>>>>>>>>>>>>  & also do i need to deploy a camel http producer su instead of
>>>>>>>>>>>>> an
>>>>>>>>>>>>> http
>>>>>>>>>>>>> service mix provider?
>>>>>>>>>>>>>
>>>>>>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Hi
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> When you are working with ServiceMix you must use the JBI
>>>>>>>>>>>>>> component
>>>>>>>>>>>>>> in
>>>>>>>>>>>>>> Camel
>>>>>>>>>>>>>> http://activemq.apache.org/camel/jbi.html
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> So your endpoints should starting with "jbi:XXXX"
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> And ServiceMix has some Camel docu here:
>>>>>>>>>>>>>> http://servicemix.apache.org/servicemix-camel.html
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Could you take a look at this docu a bit. There might be some
>>>>>>>>>>>>>> help
>>>>>>>>>>>>>> there.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Try to get something more easier working with SMX and Camel
>>>>>>>>>>>>>> and
>>>>>>>>>>>>>> then
>>>>>>>>>>>>>> later do the stuff you want with the dynamic add a camel
>>>>>>>>>>>>>> context.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> On Sat, Jan 10, 2009 at 12:39 PM, Liav Ezer
>>>>>>>>>>>>>> <li...@gmail.com>
>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Hi Claus,
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> I read your tutorial & learnt from it. Thanks. I adopted the
>>>>>>>>>>>>>>> cxf
>>>>>>>>>>>>>>> framework
>>>>>>>>>>>>>>> for now.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Regarding my project (as stated above in snippets):
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> I planted the following camel routing logic at my processor
>>>>>>>>>>>>>>> class:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> process method - with camel:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> public void process(Exchange exchange) throws Exception {
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>  CamelContext camel = new DefaultCamelContext();
>>>>>>>>>>>>>>>  camel.start();
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>  Component component = (Component)
>>>>>>>>>>>>>>> camel.getComponent("http-provider-su");
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>  Endpoint endpoint = (Endpoint) ((org.apache.camel.Component)
>>>>>>>>>>>>>>> component).createEndpoint("provider:com.amdocs.oxp.esb");
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>  exchange.getIn().setBody("Liav testing here!");
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>  Producer producer = ((org.apache.camel.Endpoint)
>>>>>>>>>>>>>>> endpoint).createProducer();
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>  producer.start();
>>>>>>>>>>>>>>>  producer.process(exchange);
>>>>>>>>>>>>>>>  producer.stop();
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>  //System.out.println(exchange.getIn().toString() + "process
>>>>>>>>>>>>>>> activated
>>>>>>>>>>>>>>> by
>>>>>>>>>>>>>>> SU");
>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> And got the following exception while SA's jar was deployed:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> ERROR - DeadLetterChannel              - Failed delivery for
>>>>>>>>>>>>>>> exchangeId:
>>>>>>>>>>>>>>> ID-LIAVE02/1885-1231586726193/0-0. On delivery attemp
>>>>>>>>>>>>>>> java.lang.NullPointerException
>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>> org.apache.servicemix.tutorial.camel.MyProcessor.process(MyProcessor.java:33)
>>>>>>>>>>>>>>> at
>>>>>>>>>>>>>>> org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:92)
>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>> org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:66)
>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>> org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorT
>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:75)
>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:146)
>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:90)
>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>> org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>> org.apache.camel.processor.Pipeline.process(Pipeline.java:85)
>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:39)
>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>> org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:91)
>>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>>> org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:48)
>>>>>>>>>>>>>>>        at java.util.TimerThread.mainLoop(Timer.java:512)
>>>>>>>>>>>>>>>        at java.util.TimerThread.run(Timer.java:462)
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Be advise that line 33 is:Endpoint endpoint = (Endpoint)
>>>>>>>>>>>>>>> ((org.apache.camel.Component)
>>>>>>>>>>>>>>> component).createEndpoint("provider:com.amdocs.oxp.esb");
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> My questions:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> 1. As bolded above i "fetched" my provider su component by
>>>>>>>>>>>>>>> staing
>>>>>>>>>>>>>>> it's
>>>>>>>>>>>>>>> name
>>>>>>>>>>>>>>> - is it correct?
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> 2. I used the following servicemix object (not camel's) since
>>>>>>>>>>>>>>> i
>>>>>>>>>>>>>>> work
>>>>>>>>>>>>>>> with
>>>>>>>>>>>>>>> servicemix provider endpoint. That's the reason for all the
>>>>>>>>>>>>>>> casting
>>>>>>>>>>>>>>> in
>>>>>>>>>>>>>>> my
>>>>>>>>>>>>>>> code:
>>>>>>>>>>>>>>> import org.apache.servicemix.jbi.deployment.Component;
>>>>>>>>>>>>>>> import org.apache.servicemix.jbi.framework.Endpoint;
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Is it correct?
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Thank again,
>>>>>>>>>>>>>>> Liav Ezer.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Hi
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> You can use the producer template to call an external http
>>>>>>>>>>>>>>>> server
>>>>>>>>>>>>>>>> and
>>>>>>>>>>>>>>>> get the response.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> See this tutorial:
>>>>>>>>>>>>>>>> http://activemq.apache.org/camel/tutorial-axis-camel.html
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> From the section - integrating Camel
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Its kinda the same but its just uses the producer template
>>>>>>>>>>>>>>>> to
>>>>>>>>>>>>>>>> save
>>>>>>>>>>>>>>>> a
>>>>>>>>>>>>>>>> file. Its the same API for using any of the camel
>>>>>>>>>>>>>>>> components.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Little sidenote:
>>>>>>>>>>>>>>>> And since you use InOut you should use: requestBody instread
>>>>>>>>>>>>>>>> of
>>>>>>>>>>>>>>>> sendBody. However Camel is not to stricky about this yet so
>>>>>>>>>>>>>>>> if
>>>>>>>>>>>>>>>> you
>>>>>>>>>>>>>>>> use
>>>>>>>>>>>>>>>> a send instead of request then it should work as well.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> The demo shows how to inject a producer template from spring
>>>>>>>>>>>>>>>> into
>>>>>>>>>>>>>>>> your
>>>>>>>>>>>>>>>> bean class = your processor. when you have this template you
>>>>>>>>>>>>>>>> can
>>>>>>>>>>>>>>>> call
>>>>>>>>>>>>>>>> the external http server and get the response using the
>>>>>>>>>>>>>>>> requestBody
>>>>>>>>>>>>>>>> method.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> On Thu, Jan 8, 2009 at 1:46 PM, Liav Ezer
>>>>>>>>>>>>>>>> <li...@gmail.com>
>>>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> Hi,
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> Here is my camel-context:
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>  <camelContext id="camel"
>>>>>>>>>>>>>>>>> xmlns="http://activemq.apache.org/camel/schema/spring">
>>>>>>>>>>>>>>>>>    <package>org.apache.servicemix.tutorial.camel</package>
>>>>>>>>>>>>>>>>>  </camelContext>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>  <bean id="myProcessor"
>>>>>>>>>>>>>>>>> class="org.apache.servicemix.tutorial.camel.MyProcessor"/>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> Here is my RouteBuilder java file:
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> public class MyRouteBuilder extends RouteBuilder {
>>>>>>>>>>>>>>>>>        public void configure() {
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> from("timer://tutorial?fixedRate=true&delay=3000&period=10000")
>>>>>>>>>>>>>>>>>                .setBody(constant(".....................Liav
>>>>>>>>>>>>>>>>> Camel
>>>>>>>>>>>>>>>>> POC......................."))
>>>>>>>>>>>>>>>>>                        .to("myProcessor");
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>    }
>>>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> Here is my processor java file:
>>>>>>>>>>>>>>>>> public class MyProcessor implements Processor {
>>>>>>>>>>>>>>>>>          public void process(Exchange exchange) throws
>>>>>>>>>>>>>>>>> Exception
>>>>>>>>>>>>>>>>> {
>>>>>>>>>>>>>>>>>              //WANT TO INITIATE A CALL TO http pROVIDER END
>>>>>>>>>>>>>>>>> POINT
>>>>>>>>>>>>>>>>> &
>>>>>>>>>>>>>>>>> PASS
>>>>>>>>>>>>>>>>> THE
>>>>>>>>>>>>>>>>> 'FROM'
>>>>>>>>>>>>>>>>>                  // PARAMETRS RECIEVED PROIRE TO THE
>>>>>>>>>>>>>>>>> PROCESSOR
>>>>>>>>>>>>>>>>> INVOKE.
>>>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> Thanks.
>>>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>>> View this message in context:
>>>>>>>>>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21351142.html
>>>>>>>>>>>>>>>>> Sent from the Camel - Users mailing list archive at
>>>>>>>>>>>>>>>>> Nabble.com.
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> /Claus Ibsen
>>>>>>>>>>>>>>>> Apache Camel Committer
>>>>>>>>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>> View this message in context:
>>>>>>>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21387207.html
>>>>>>>>>>>>>>> Sent from the Camel - Users mailing list archive at
>>>>>>>>>>>>>>> Nabble.com.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> /Claus Ibsen
>>>>>>>>>>>>>> Apache Camel Committer
>>>>>>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> --
>>>>>>>>>>>>> View this message in context:
>>>>>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21387318.html
>>>>>>>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> --
>>>>>>>>>>>>
>>>>>>>>>>>> /Claus Ibsen
>>>>>>>>>>>> Apache Camel Committer
>>>>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>>> View this message in context:
>>>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21388391.html
>>>>>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>>
>>>>>>>>>> /Claus Ibsen
>>>>>>>>>> Apache Camel Committer
>>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> View this message in context:
>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21389069.html
>>>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>>
>>>>>>>> /Claus Ibsen
>>>>>>>> Apache Camel Committer
>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> View this message in context:
>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21390941.html
>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>>
>>>>>> /Claus Ibsen
>>>>>> Apache Camel Committer
>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21396985.html
>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>>
>>>> /Claus Ibsen
>>>> Apache Camel Committer
>>>> Blog: http://davsclaus.blogspot.com/
>>>>
>>>>
>>>
>>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21412377.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 

/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/

Re: How do i call an HTTP Provider end-pont from the process method?

Posted by Liav Ezer <li...@gmail.com>.
Hi Claus,

Ok, I progressed a bit but still has the a problem consuming my WS.

Here is my Processor code (producer.sendBody() first arg' has changed).

public void process(Exchange exchange) throws Exception {
	  ProducerTemplate producer =
exchange.getContext().createProducerTemplate();
	  String payload = exchange.getIn().getBody(String.class); // == liav
	  String request = "<?xml version=\"1.0\"
encoding=\"UTF-8\"?><soapenv:Body><sayHello><name>"+payload+"</name></sayHello></soapenv:Body>";	  
	  Object response =
producer.sendBody("jbi:service:http://com.amdocs.oxp/esb/LiavHelloImplSvcService",
request);
}

This is the xbean of the SMX http Provider:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:http="http://servicemix.apache.org/http/1.0"
       xmlns:wsn="http://com.amdocs.oxp/esb"
       xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://servicemix.apache.org/http/1.0
http://servicemix.apache.org/schema/servicemix-http-3.3.1.3-fuse.xsd
       http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
                 
           <http:endpoint service="wsn:LiavHelloImplSvcService"
                 endpoint="wsn:LiavHelloImplSvc"
                 role="provider"
                
locationURI="http://localhost:8080/LiavHello2/services/LiavHelloImplSvc"
                
wsdlResource="c:/HTTPReceiverServices/LiavHelloImplSvc.wsdl"
                 defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
                 soap="true" />
</beans>

My question:

By looking at the end-point invoke (via the producerTemplate) & at the
end-point config (xbean file),

do you see a reason why my WS (LiavHelloImplSvcService) isn't consumed?

Here is the current SMX log after deployment:

ERROR - HttpComponent                  - Error processing exchange InOnly[
  id: ID:10.236.11.194-11eca7dd5b2-2:8
  status: Active
  role: provider
  service: {http://com.amdocs.oxp/esb}LiavHelloImplSvcService
  endpoint: wsn:LiavHelloImplSvc
  in: <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:q0="http://service.app.esb.oxp.amdocs.com" xmlns:xsd="
http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><q0:sayHello><q0:name>LiavFromRouterBuilder</q0:name></q0:sayHello></soapenv:B
ody></soapenv:Envelope>
]
java.lang.Exception: Invalid status response: 500
Thanks.

Liav Ezer wrote:
> 
> Hi Claus,
> 
> What i managed to accomplish is that my producer is 'familiar' with my
> Provider end-point but from some reason it doesn't invoke my service (WS)
> & hence report an invalide status response (500).
> 
> ERROR - HttpComponent                  - Error processing exchange InOnly[
>   id: ID:10.236.11.194-11ec622522e-2:96
>   status: Active
>   role: provider
>   service: {http://com.amdocs.oxp/esb}LiavHelloImplSvcService
>   endpoint: wsn:LiavHelloImplSvc
>   in: <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http
> ://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><sayHello><name>Liav</name></sayHello></soapenv:Body></soapenv:Envelope>
> ]
> 
> This is my xbean.xml (it must be related to the end-point configuration):
> 
> <http:endpoint service="wsn:LiavHelloImplSvcService"
>                  endpoint="wsn:LiavHelloImplSvc"
>                  role="provider"
>                 
> locationURI="http://localhost:8080/LiavHello2/services/LiavHelloImplSvc"
>                 
> wsdlResource="c:/HTTPReceiverServices/LiavHelloImplSvc.wsdl"
>                  defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>                  soap="true" />
> 
> Thanks.
> java.lang.Exception: Invalid status response: 500
> 
> 
> 
> 
> 
> Liav Ezer wrote:
>> 
>> Hi Claus,
>> 
>> I'm stuck with a problem that my servixmix is reporting a try to send a
>> request to the provider but appearantly it's not able to consume the
>> Provider's WS.
>> 
>> Here is the console:
>> 
>> ERROR - DeadLetterChannel              - Failed delivery for exchangeId:
>> ID-LIAVE02/1441-1231673232762/0-2. On delivery attempt: 0 caught:
>> org.apache.camel.RuntimeCamelException: o
>> rg.apache.servicemix.camel.JbiException:
>> javax.jbi.messaging.MessagingException: Could not find route for
>> exchange: InOnly[
>>   id: ID:10.236.11.194-11ec5713753-2:7
>>   status: Active
>>   role: provider  
>> in: <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
>> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
>> xmlns:q0="http://service.app.esb.oxp.amdocs.com" xmlns:xsd="
>> http://www.w3.org/2001/XMLSchema"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><q0:sayHello><q0:name>liav-name</q0:name>
>> </q0:sayHello></soapenv:Body></soape
>> nv:Envelope>
>> ] for service: null and interface: null
>> 
>> When i develpoed the WS i tested it via eclipse with success.
>> 
>> Here is the xbean definition:
>> 
>> <http:endpoint service="wsn:LiavHelloImplSvcService"
>>                  endpoint="wsn:LiavHelloImplSvc"
>>                  role="provider"
>>                 
>> locationURI="http://localhost:8080/LiavHello2/services/LiavHelloImplSvc"
>>                 
>> wsdlResource="c:/HTTPReceiverServices/LiavHelloImplSvc.wsdl"
>>                  defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>                  soap="true" />
>> 
>> Why does it report null for the service & interface?
>> 
>> Thanks.
>> 
>> Claus Ibsen-2 wrote:
>>> 
>>> On Sun, Jan 11, 2009 at 9:19 AM, Liav Ezer <li...@gmail.com> wrote:
>>>>
>>>> Hi Claus,
>>>>
>>>> Yes, i changed the body (arg2 in the sendBody method) to be a SOAP
>>>> request
>>>> like the following:
>>>>
>>>> String request = "<soapenv:Envelope
>>>> xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'
>>>> xmlns:q0='http://service.app.esb.oxp.liav.com'
>>>> xmlns:xsd='http://www.w3.org/2001/XMLSchema'
>>>> xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><soapenv:Body><q0:sayHello><q0:name>liav-name</q0:name>
>>>> </q0:sayHello></soapenv:Body></soapenv:Envelope>";
>>>>
>>>> 1. Is it a correct payload to send a request?
>>> Yeah it should be something like that. You might need the <?xml
>>> version...> header. But try with and without it.
>>> 
>>> 
>>>>
>>>> 2. Does this method will return the provider response - The API shows
>>>> that
>>>> it returns an Object - should i cast it to be an 'Exchange' & extract
>>>> the
>>>> response from the provider?
>>> When you use Camel's producer template to do a request/reply then
>>> Camel will extract the response from the Exchange/IN or OUT/Message,
>>> so you just get the payload. The type is Object but it can be what SMX
>>> returns, so it could be some sort of XML holder such as
>>> org.w3c.Document. But try and see what kind of Object you get back.
>>> 
>>> There are type converters in Camel that can convert it back to a
>>> String if you want to use that, or what else there is
>>> http://activemq.apache.org/camel/type-converter.html
>>> 
>>> 
>>> 
>>>>
>>>> Thanks.
>>>>
>>>> Claus Ibsen-2 wrote:
>>>>>
>>>>> On Sat, Jan 10, 2009 at 8:51 PM, Liav Ezer <li...@gmail.com>
>>>>> wrote:
>>>>>>
>>>>>> Hi Claus,
>>>>>>
>>>>>> I changed the notation as needed to:
>>>>>>
>>>>>> producer.sendBody("jbi:endpoint:http://localhost:8080/LiavHello/services/LiavHelloImpl",
>>>>>> "Netania");
>>>>>>
>>>>>>  SMX console now output some wierd error - googling it comes up with
>>>>>> some
>>>>>> xml parsing error:
>>>>>>
>>>>>> [Fatal Error] :1:1: Content is not allowed in prolog.DEBUG -
>>>>>> DeliveryChannelImpl            - Exception processing:
>>>>>> ID:10.236.11.194-11ec1f3a450-2:291 in
>>>>>> DeliveryChannel{servicemix-camel}
>>>>>> ERROR - DeadLetterChannel              - Failed delivery for
>>>>>> exchangeId:
>>>>>> ID-LIAVE02/4519-1231614935663/0-50. On delivery attempt: 0 caught:
>>>>>> org.apache
>>>>>> org.apache.servicemix.camel.JbiException:
>>>>>> javax.jbi.messaging.MessagingException: Could not find route for
>>>>>> exchange:
>>>>>> InOnly[
>>>>>>  id: ID:10.236.11.194-11ec1f3a450-2:291
>>>>>>  status: Active
>>>>>>  role: provider
>>>>> Yeah when you send data to SMX you must remember that its expecting
>>>>> the payload to be according to the JBI spec. in XML format. So you
>>>>> should send the data as XML.
>>>>>
>>>>> "Content is not allowed in prolog" is a bit cryptical XML parser error
>>>>> stating that it could not find the <?xml ... ?> declaration in top of
>>>>> the content it was parsing.
>>>>>
>>>>> So you should send the payload as XML.
>>>>>
>>>>> BTW: Which version of SMX and Camel are you using? I think the missing
>>>>> method from X mails back could be because we added it in Camel 1.4.0
>>>>> (I think).
>>>>>
>>>>>
>>>>>
>>>>>>
>>>>>> Claus Ibsen-2 wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> This is the SMX Provider xbean:
>>>>>>>
>>>>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>>>>> <beans xmlns:http="http://servicemix.apache.org/http/1.0"
>>>>>>>        xmlns:wsn="http://com.amdocs.oxp/esb"
>>>>>>>        xmlns="http://www.springframework.org/schema/beans"
>>>>>>>        xmlns:xsi="http://http://www.w3.org/2001/XMLSchema-instance"
>>>>>>>        xsi:schemaLocation="http://servicemix.apache.org/http/1.0
>>>>>>> http://servicemix.apache.org/schema/servicemix-http-3.3.1.3-fuse.xsd
>>>>>>>        http://www.springframework.org/schema/beans
>>>>>>> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
>>>>>>>
>>>>>>>                 <http:endpoint service="wsn:LiavHelloImplService"
>>>>>>>                  endpoint="wsn:LiavHelloImpl"
>>>>>>>                  role="provider"
>>>>>>>
>>>>>>> locationURI="http://localhost:8080/LiavHello/services/LiavHelloImpl"
>>>>>>>
>>>>>>> wsdlResource="c:/HTTPReceiverServices/LiavHelloImpl.wsdl"
>>>>>>>                  defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>>>>>>                  soap="true" />
>>>>>>> </beans>
>>>>>>> Any clue?
>>>>>>> On Sat, Jan 10, 2009 at 4:17 PM, Liav Ezer <li...@gmail.com>
>>>>>>> wrote:
>>>>>>>>
>>>>>>>> Hi Claus,
>>>>>>>>
>>>>>>>> Well i'll stick with the Http SMX provider end-point. I guess it's
>>>>>>>> should
>>>>>>>> integrate with camel routing with no problem.
>>>>>>>>
>>>>>>>> Ok what i did is the advise you gave me a few answers ago:
>>>>>>>>
>>>>>>>> ProducerTemplate producer =
>>>>>>>> exchange.getContext().createProducerTemplate();
>>>>>>>> Object response =
>>>>>>>> producer.sendBody("http://localhost:8080/LiavHello/services/LiavHelloImpl",
>>>>>>>> "Daviv");
>>>>>>> See below
>>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>> And got this exception (SMX console after deply):
>>>>>>>>
>>>>>>>> : No endpoint could be found for:
>>>>>>>> http://localhost:8080/LiavHello/services/LiavHelloImpl
>>>>>>>> org.apache.camel.NoSuchEndpointException: No endpoint could be
>>>>>>>> found
>>>>>>>> for:
>>>>>>>> http://localhost:8080/LiavHello/services/LiavHelloImpl
>>>>>>>>
>>>>>>>> LiavHelloImpl is the wsdlsoap:address location of the wsdl file
>>>>>>>> representing
>>>>>>>> the LiavHelloImp web project (under a running tomcat 6.0).
>>>>>>>>
>>>>>>>> Can you advise? It seems that the routing trying to be accomplished
>>>>>>>> but
>>>>>>>> something "configi" is messed up.
>>>>>>>>
>>>>>>>> Here is my provider xbean:
>>>>>>>>
>>>>>>>> <http:endpoint service="wsn:LiavHelloImplService"
>>>>>>>>                 endpoint="wsn:LiavHelloImpl"
>>>>>>>>                 role="provider"
>>>>>>>>
>>>>>>>> locationURI="http://localhost:8080/LiavHello/services/LiavHelloImpl"
>>>>>>>>
>>>>>>>> wsdlResource="c:/HTTPReceiverServices/LiavHelloImpl.wsdl"
>>>>>>>>                 defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>>>>>>>                 soap="true" />
>>>>>>> When you want from Camel to call service on SMX then you must use
>>>>>>> the
>>>>>>> camel-jbi component that delegates to the SU in SMX.
>>>>>>> So you need to add the jbi prefix in front.
>>>>>>> See: http://activemq.apache.org/camel/jbi.html
>>>>>>>
>>>>>>> It should be something like this. By by all means I am not SMX
>>>>>>> expert
>>>>>>> (yet):
>>>>>>> producer.sendBody("jbi:service:wsn:LiavHelloImplService", "Daviv");
>>>>>>>
>>>>>>> The jbi component have different notation so please check it out.
>>>>>>>
>>>>>>> If you manage to get it working, then please write back how to, so
>>>>>>> we
>>>>>>> can improve the documentation and help others in the future.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>> Thanks!
>>>>>>>>
>>>>>>>>
>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>>
>>>>>>>>> On Sat, Jan 10, 2009 at 3:02 PM, Liav Ezer <li...@gmail.com>
>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>> Hi Claus,
>>>>>>>>>>
>>>>>>>>>> I did follow this camel example & set up a timer 'from' end-point
>>>>>>>>>> which
>>>>>>>>>> my
>>>>>>>>>> processor 'catched'.
>>>>>>>>>>
>>>>>>>>>> My will is to query this 'catched' data by sending it to a
>>>>>>>>>> different
>>>>>>>>>> end-point such as a service provider.
>>>>>>>>>>
>>>>>>>>>> Therefore, i deployed two SU's in my servicemix: One for the
>>>>>>>>>> camel
>>>>>>>>>> routing
>>>>>>>>>> (timer example) & two is for
>>>>>>>>>>
>>>>>>>>>> the HTTP servicemix provider which i want to invoke in the
>>>>>>>>>> proceesor.
>>>>>>>>>>
>>>>>>>>>> My question seems simple as long as an API exists for it:
>>>>>>>>>>
>>>>>>>>>> When my Processor class is instansiated than the process() method
>>>>>>>>>> is
>>>>>>>>>> invoked:
>>>>>>>>>>
>>>>>>>>>> public void process(Exchange exchange) throws Exception {
>>>>>>>>>>
>>>>>>>>>> The exchange.getIn() consist my 'from' end-point data (=the
>>>>>>>>>> timer).
>>>>>>>>>>
>>>>>>>>>> I need the API to fetch the Http servicemix provider end-point &
>>>>>>>>>> to
>>>>>>>>>> send
>>>>>>>>>> hime a request with this data.
>>>>>>>>> If you want to send FROM Camel to SMX then you need to use the
>>>>>>>>> camel-jbi component. That is you get endpoints FROM Camel starting
>>>>>>>>> with the "jbi:" prefix. See camel-jbi component.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> One extra small question: Do i need to replace my provider SU
>>>>>>>>>> with a
>>>>>>>>>> camel
>>>>>>>>>> http producer SU?
>>>>>>>>> If you are using SMX 3.x then you dont as SMX has one SU for
>>>>>>>>> Camel.
>>>>>>>>> However if you need to use any of the other camel components from
>>>>>>>>> SMX
>>>>>>>>> you need to have them in the classpath as well, such as
>>>>>>>>> camel-http.jar.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> (In SMX 4.x its all OSGi land and you need to install features
>>>>>>>>> into
>>>>>>>>> SMX.)
>>>>>>>>>
>>>>>>>>> A bit confused now. Which http provider do you want to use?
>>>>>>>>> - SMX Http provider
>>>>>>>>> - Camel http provider
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Thanks.
>>>>>>>>>>
>>>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>>>>
>>>>>>>>>>> Hi
>>>>>>>>>>>
>>>>>>>>>>> Yeah its a bit mixed up since Camel and ServiceMix have classes
>>>>>>>>>>> with
>>>>>>>>>>> common name: Endpoint, Exchange etc.
>>>>>>>>>>>
>>>>>>>>>>> All the code I have shown assumes pure Camel code.
>>>>>>>>>>>
>>>>>>>>>>> I advice to check the ServceMix docu about using Camel in
>>>>>>>>>>> ServiceMix.
>>>>>>>>>>> And get a basic example running. Such as this example
>>>>>>>>>>> http://servicemix.apache.org/camel-example.html
>>>>>>>>>>>
>>>>>>>>>>> You could use that as a starting point to get Camel invoking
>>>>>>>>>>> your
>>>>>>>>>>> HTTP
>>>>>>>>>>> server. Just let the timer start it.
>>>>>>>>>>> Then later your can connect using SMX instead of the camel
>>>>>>>>>>> timer.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> On Sat, Jan 10, 2009 at 12:53 PM, Liav Ezer
>>>>>>>>>>> <li...@gmail.com>
>>>>>>>>>>> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>> Hi Claus again,
>>>>>>>>>>>>
>>>>>>>>>>>> I addition to what i asked in my previouse response here is a
>>>>>>>>>>>> question
>>>>>>>>>>>> regarding the producer snippet which you gave in your last
>>>>>>>>>>>> answer:
>>>>>>>>>>>>
>>>>>>>>>>>> I indeed wrote the following in my process() method:
>>>>>>>>>>>>
>>>>>>>>>>>> ProducerTemplate producer =
>>>>>>>>>>>>
>>>>>>>>>>>> exchange.getCamelContext().createProducerTemplate();
>>>>>>>>>>>>                            Object response =
>>>>>>>>>>>>
>>>>>>>>>>>> producer.sendBody("http://myserver.com/myapp?foo=bar", "Liav
>>>>>>>>>>>> Camel
>>>>>>>>>>>> POC");
>>>>>>>>>>>>
>>>>>>>>>>>> but i don't have the camel context at hand (saying "The method
>>>>>>>>>>>> getCamelContext() is undefined for the type Exchange").
>>>>>>>>>>>>  & also do i need to deploy a camel http producer su instead of
>>>>>>>>>>>> an
>>>>>>>>>>>> http
>>>>>>>>>>>> service mix provider?
>>>>>>>>>>>>
>>>>>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>> Hi
>>>>>>>>>>>>>
>>>>>>>>>>>>> When you are working with ServiceMix you must use the JBI
>>>>>>>>>>>>> component
>>>>>>>>>>>>> in
>>>>>>>>>>>>> Camel
>>>>>>>>>>>>> http://activemq.apache.org/camel/jbi.html
>>>>>>>>>>>>>
>>>>>>>>>>>>> So your endpoints should starting with "jbi:XXXX"
>>>>>>>>>>>>>
>>>>>>>>>>>>> And ServiceMix has some Camel docu here:
>>>>>>>>>>>>> http://servicemix.apache.org/servicemix-camel.html
>>>>>>>>>>>>>
>>>>>>>>>>>>> Could you take a look at this docu a bit. There might be some
>>>>>>>>>>>>> help
>>>>>>>>>>>>> there.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Try to get something more easier working with SMX and Camel
>>>>>>>>>>>>> and
>>>>>>>>>>>>> then
>>>>>>>>>>>>> later do the stuff you want with the dynamic add a camel
>>>>>>>>>>>>> context.
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> On Sat, Jan 10, 2009 at 12:39 PM, Liav Ezer
>>>>>>>>>>>>> <li...@gmail.com>
>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Hi Claus,
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> I read your tutorial & learnt from it. Thanks. I adopted the
>>>>>>>>>>>>>> cxf
>>>>>>>>>>>>>> framework
>>>>>>>>>>>>>> for now.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Regarding my project (as stated above in snippets):
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> I planted the following camel routing logic at my processor
>>>>>>>>>>>>>> class:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> process method - with camel:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> public void process(Exchange exchange) throws Exception {
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  CamelContext camel = new DefaultCamelContext();
>>>>>>>>>>>>>>  camel.start();
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  Component component = (Component)
>>>>>>>>>>>>>> camel.getComponent("http-provider-su");
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  Endpoint endpoint = (Endpoint) ((org.apache.camel.Component)
>>>>>>>>>>>>>> component).createEndpoint("provider:com.amdocs.oxp.esb");
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  exchange.getIn().setBody("Liav testing here!");
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  Producer producer = ((org.apache.camel.Endpoint)
>>>>>>>>>>>>>> endpoint).createProducer();
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  producer.start();
>>>>>>>>>>>>>>  producer.process(exchange);
>>>>>>>>>>>>>>  producer.stop();
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  //System.out.println(exchange.getIn().toString() + "process
>>>>>>>>>>>>>> activated
>>>>>>>>>>>>>> by
>>>>>>>>>>>>>> SU");
>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> And got the following exception while SA's jar was deployed:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> ERROR - DeadLetterChannel              - Failed delivery for
>>>>>>>>>>>>>> exchangeId:
>>>>>>>>>>>>>> ID-LIAVE02/1885-1231586726193/0-0. On delivery attemp
>>>>>>>>>>>>>> java.lang.NullPointerException
>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>> org.apache.servicemix.tutorial.camel.MyProcessor.process(MyProcessor.java:33)
>>>>>>>>>>>>>> at
>>>>>>>>>>>>>> org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:92)
>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>> org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:66)
>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>> org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorT
>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:75)
>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:146)
>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:90)
>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>> org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>> org.apache.camel.processor.Pipeline.process(Pipeline.java:85)
>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:39)
>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>> org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:91)
>>>>>>>>>>>>>>        at
>>>>>>>>>>>>>> org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:48)
>>>>>>>>>>>>>>        at java.util.TimerThread.mainLoop(Timer.java:512)
>>>>>>>>>>>>>>        at java.util.TimerThread.run(Timer.java:462)
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Be advise that line 33 is:Endpoint endpoint = (Endpoint)
>>>>>>>>>>>>>> ((org.apache.camel.Component)
>>>>>>>>>>>>>> component).createEndpoint("provider:com.amdocs.oxp.esb");
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> My questions:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> 1. As bolded above i "fetched" my provider su component by
>>>>>>>>>>>>>> staing
>>>>>>>>>>>>>> it's
>>>>>>>>>>>>>> name
>>>>>>>>>>>>>> - is it correct?
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> 2. I used the following servicemix object (not camel's) since
>>>>>>>>>>>>>> i
>>>>>>>>>>>>>> work
>>>>>>>>>>>>>> with
>>>>>>>>>>>>>> servicemix provider endpoint. That's the reason for all the
>>>>>>>>>>>>>> casting
>>>>>>>>>>>>>> in
>>>>>>>>>>>>>> my
>>>>>>>>>>>>>> code:
>>>>>>>>>>>>>> import org.apache.servicemix.jbi.deployment.Component;
>>>>>>>>>>>>>> import org.apache.servicemix.jbi.framework.Endpoint;
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Is it correct?
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Thank again,
>>>>>>>>>>>>>> Liav Ezer.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Hi
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> You can use the producer template to call an external http
>>>>>>>>>>>>>>> server
>>>>>>>>>>>>>>> and
>>>>>>>>>>>>>>> get the response.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> See this tutorial:
>>>>>>>>>>>>>>> http://activemq.apache.org/camel/tutorial-axis-camel.html
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> From the section - integrating Camel
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Its kinda the same but its just uses the producer template
>>>>>>>>>>>>>>> to
>>>>>>>>>>>>>>> save
>>>>>>>>>>>>>>> a
>>>>>>>>>>>>>>> file. Its the same API for using any of the camel
>>>>>>>>>>>>>>> components.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Little sidenote:
>>>>>>>>>>>>>>> And since you use InOut you should use: requestBody instread
>>>>>>>>>>>>>>> of
>>>>>>>>>>>>>>> sendBody. However Camel is not to stricky about this yet so
>>>>>>>>>>>>>>> if
>>>>>>>>>>>>>>> you
>>>>>>>>>>>>>>> use
>>>>>>>>>>>>>>> a send instead of request then it should work as well.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> The demo shows how to inject a producer template from spring
>>>>>>>>>>>>>>> into
>>>>>>>>>>>>>>> your
>>>>>>>>>>>>>>> bean class = your processor. when you have this template you
>>>>>>>>>>>>>>> can
>>>>>>>>>>>>>>> call
>>>>>>>>>>>>>>> the external http server and get the response using the
>>>>>>>>>>>>>>> requestBody
>>>>>>>>>>>>>>> method.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> On Thu, Jan 8, 2009 at 1:46 PM, Liav Ezer
>>>>>>>>>>>>>>> <li...@gmail.com>
>>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Hi,
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Here is my camel-context:
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>  <camelContext id="camel"
>>>>>>>>>>>>>>>> xmlns="http://activemq.apache.org/camel/schema/spring">
>>>>>>>>>>>>>>>>    <package>org.apache.servicemix.tutorial.camel</package>
>>>>>>>>>>>>>>>>  </camelContext>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>  <bean id="myProcessor"
>>>>>>>>>>>>>>>> class="org.apache.servicemix.tutorial.camel.MyProcessor"/>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Here is my RouteBuilder java file:
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> public class MyRouteBuilder extends RouteBuilder {
>>>>>>>>>>>>>>>>        public void configure() {
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> from("timer://tutorial?fixedRate=true&delay=3000&period=10000")
>>>>>>>>>>>>>>>>                .setBody(constant(".....................Liav
>>>>>>>>>>>>>>>> Camel
>>>>>>>>>>>>>>>> POC......................."))
>>>>>>>>>>>>>>>>                        .to("myProcessor");
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>    }
>>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Here is my processor java file:
>>>>>>>>>>>>>>>> public class MyProcessor implements Processor {
>>>>>>>>>>>>>>>>          public void process(Exchange exchange) throws
>>>>>>>>>>>>>>>> Exception
>>>>>>>>>>>>>>>> {
>>>>>>>>>>>>>>>>              //WANT TO INITIATE A CALL TO http pROVIDER END
>>>>>>>>>>>>>>>> POINT
>>>>>>>>>>>>>>>> &
>>>>>>>>>>>>>>>> PASS
>>>>>>>>>>>>>>>> THE
>>>>>>>>>>>>>>>> 'FROM'
>>>>>>>>>>>>>>>>                  // PARAMETRS RECIEVED PROIRE TO THE
>>>>>>>>>>>>>>>> PROCESSOR
>>>>>>>>>>>>>>>> INVOKE.
>>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Thanks.
>>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>> View this message in context:
>>>>>>>>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21351142.html
>>>>>>>>>>>>>>>> Sent from the Camel - Users mailing list archive at
>>>>>>>>>>>>>>>> Nabble.com.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> /Claus Ibsen
>>>>>>>>>>>>>>> Apache Camel Committer
>>>>>>>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> --
>>>>>>>>>>>>>> View this message in context:
>>>>>>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21387207.html
>>>>>>>>>>>>>> Sent from the Camel - Users mailing list archive at
>>>>>>>>>>>>>> Nabble.com.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> --
>>>>>>>>>>>>>
>>>>>>>>>>>>> /Claus Ibsen
>>>>>>>>>>>>> Apache Camel Committer
>>>>>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> --
>>>>>>>>>>>> View this message in context:
>>>>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21387318.html
>>>>>>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>>>
>>>>>>>>>>> /Claus Ibsen
>>>>>>>>>>> Apache Camel Committer
>>>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> View this message in context:
>>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21388391.html
>>>>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>>
>>>>>>>>> /Claus Ibsen
>>>>>>>>> Apache Camel Committer
>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> View this message in context:
>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21389069.html
>>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>>
>>>>>>> /Claus Ibsen
>>>>>>> Apache Camel Committer
>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> --
>>>>>> View this message in context:
>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21390941.html
>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>>
>>>>> /Claus Ibsen
>>>>> Apache Camel Committer
>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>
>>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21396985.html
>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>
>>>>
>>> 
>>> 
>>> 
>>> -- 
>>> 
>>> /Claus Ibsen
>>> Apache Camel Committer
>>> Blog: http://davsclaus.blogspot.com/
>>> 
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21412377.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: How do i call an HTTP Provider end-pont from the process method?

Posted by Liav Ezer <li...@gmail.com>.
Hi Claus,

What i managed to accomplish is that my producer is 'familiar' with my
Provider end-point but from some reason it doesn't invoke my service (WS) &
hence report an invalide status response (500).

ERROR - HttpComponent                  - Error processing exchange InOnly[
  id: ID:10.236.11.194-11ec622522e-2:96
  status: Active
  role: provider
  service: {http://com.amdocs.oxp/esb}LiavHelloImplSvcService
  endpoint: wsn:LiavHelloImplSvc
  in: <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http
://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><sayHello><name>Liav</name></sayHello></soapenv:Body></soapenv:Envelope>
]

This is my xbean.xml (it must be related to the end-point configuration):

<http:endpoint service="wsn:LiavHelloImplSvcService"
                 endpoint="wsn:LiavHelloImplSvc"
                 role="provider"
                
locationURI="http://localhost:8080/LiavHello2/services/LiavHelloImplSvc"
                
wsdlResource="c:/HTTPReceiverServices/LiavHelloImplSvc.wsdl"
                 defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
                 soap="true" />

Thanks.
java.lang.Exception: Invalid status response: 500





Liav Ezer wrote:
> 
> Hi Claus,
> 
> I'm stuck with a problem that my servixmix is reporting a try to send a
> request to the provider but appearantly it's not able to consume the
> Provider's WS.
> 
> Here is the console:
> 
> ERROR - DeadLetterChannel              - Failed delivery for exchangeId:
> ID-LIAVE02/1441-1231673232762/0-2. On delivery attempt: 0 caught:
> org.apache.camel.RuntimeCamelException: o
> rg.apache.servicemix.camel.JbiException:
> javax.jbi.messaging.MessagingException: Could not find route for exchange:
> InOnly[
>   id: ID:10.236.11.194-11ec5713753-2:7
>   status: Active
>   role: provider  
> in: <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:q0="http://service.app.esb.oxp.amdocs.com" xmlns:xsd="
> http://www.w3.org/2001/XMLSchema"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><q0:sayHello><q0:name>liav-name</q0:name>
> </q0:sayHello></soapenv:Body></soape
> nv:Envelope>
> ] for service: null and interface: null
> 
> When i develpoed the WS i tested it via eclipse with success.
> 
> Here is the xbean definition:
> 
> <http:endpoint service="wsn:LiavHelloImplSvcService"
>                  endpoint="wsn:LiavHelloImplSvc"
>                  role="provider"
>                 
> locationURI="http://localhost:8080/LiavHello2/services/LiavHelloImplSvc"
>                 
> wsdlResource="c:/HTTPReceiverServices/LiavHelloImplSvc.wsdl"
>                  defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>                  soap="true" />
> 
> Why does it report null for the service & interface?
> 
> Thanks.
> 
> Claus Ibsen-2 wrote:
>> 
>> On Sun, Jan 11, 2009 at 9:19 AM, Liav Ezer <li...@gmail.com> wrote:
>>>
>>> Hi Claus,
>>>
>>> Yes, i changed the body (arg2 in the sendBody method) to be a SOAP
>>> request
>>> like the following:
>>>
>>> String request = "<soapenv:Envelope
>>> xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'
>>> xmlns:q0='http://service.app.esb.oxp.liav.com'
>>> xmlns:xsd='http://www.w3.org/2001/XMLSchema'
>>> xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><soapenv:Body><q0:sayHello><q0:name>liav-name</q0:name>
>>> </q0:sayHello></soapenv:Body></soapenv:Envelope>";
>>>
>>> 1. Is it a correct payload to send a request?
>> Yeah it should be something like that. You might need the <?xml
>> version...> header. But try with and without it.
>> 
>> 
>>>
>>> 2. Does this method will return the provider response - The API shows
>>> that
>>> it returns an Object - should i cast it to be an 'Exchange' & extract
>>> the
>>> response from the provider?
>> When you use Camel's producer template to do a request/reply then
>> Camel will extract the response from the Exchange/IN or OUT/Message,
>> so you just get the payload. The type is Object but it can be what SMX
>> returns, so it could be some sort of XML holder such as
>> org.w3c.Document. But try and see what kind of Object you get back.
>> 
>> There are type converters in Camel that can convert it back to a
>> String if you want to use that, or what else there is
>> http://activemq.apache.org/camel/type-converter.html
>> 
>> 
>> 
>>>
>>> Thanks.
>>>
>>> Claus Ibsen-2 wrote:
>>>>
>>>> On Sat, Jan 10, 2009 at 8:51 PM, Liav Ezer <li...@gmail.com> wrote:
>>>>>
>>>>> Hi Claus,
>>>>>
>>>>> I changed the notation as needed to:
>>>>>
>>>>> producer.sendBody("jbi:endpoint:http://localhost:8080/LiavHello/services/LiavHelloImpl",
>>>>> "Netania");
>>>>>
>>>>>  SMX console now output some wierd error - googling it comes up with
>>>>> some
>>>>> xml parsing error:
>>>>>
>>>>> [Fatal Error] :1:1: Content is not allowed in prolog.DEBUG -
>>>>> DeliveryChannelImpl            - Exception processing:
>>>>> ID:10.236.11.194-11ec1f3a450-2:291 in
>>>>> DeliveryChannel{servicemix-camel}
>>>>> ERROR - DeadLetterChannel              - Failed delivery for
>>>>> exchangeId:
>>>>> ID-LIAVE02/4519-1231614935663/0-50. On delivery attempt: 0 caught:
>>>>> org.apache
>>>>> org.apache.servicemix.camel.JbiException:
>>>>> javax.jbi.messaging.MessagingException: Could not find route for
>>>>> exchange:
>>>>> InOnly[
>>>>>  id: ID:10.236.11.194-11ec1f3a450-2:291
>>>>>  status: Active
>>>>>  role: provider
>>>> Yeah when you send data to SMX you must remember that its expecting
>>>> the payload to be according to the JBI spec. in XML format. So you
>>>> should send the data as XML.
>>>>
>>>> "Content is not allowed in prolog" is a bit cryptical XML parser error
>>>> stating that it could not find the <?xml ... ?> declaration in top of
>>>> the content it was parsing.
>>>>
>>>> So you should send the payload as XML.
>>>>
>>>> BTW: Which version of SMX and Camel are you using? I think the missing
>>>> method from X mails back could be because we added it in Camel 1.4.0
>>>> (I think).
>>>>
>>>>
>>>>
>>>>>
>>>>> Claus Ibsen-2 wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>> This is the SMX Provider xbean:
>>>>>>
>>>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>>>> <beans xmlns:http="http://servicemix.apache.org/http/1.0"
>>>>>>        xmlns:wsn="http://com.amdocs.oxp/esb"
>>>>>>        xmlns="http://www.springframework.org/schema/beans"
>>>>>>        xmlns:xsi="http://http://www.w3.org/2001/XMLSchema-instance"
>>>>>>        xsi:schemaLocation="http://servicemix.apache.org/http/1.0
>>>>>> http://servicemix.apache.org/schema/servicemix-http-3.3.1.3-fuse.xsd
>>>>>>        http://www.springframework.org/schema/beans
>>>>>> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
>>>>>>
>>>>>>                 <http:endpoint service="wsn:LiavHelloImplService"
>>>>>>                  endpoint="wsn:LiavHelloImpl"
>>>>>>                  role="provider"
>>>>>>
>>>>>> locationURI="http://localhost:8080/LiavHello/services/LiavHelloImpl"
>>>>>>
>>>>>> wsdlResource="c:/HTTPReceiverServices/LiavHelloImpl.wsdl"
>>>>>>                  defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>>>>>                  soap="true" />
>>>>>> </beans>
>>>>>> Any clue?
>>>>>> On Sat, Jan 10, 2009 at 4:17 PM, Liav Ezer <li...@gmail.com>
>>>>>> wrote:
>>>>>>>
>>>>>>> Hi Claus,
>>>>>>>
>>>>>>> Well i'll stick with the Http SMX provider end-point. I guess it's
>>>>>>> should
>>>>>>> integrate with camel routing with no problem.
>>>>>>>
>>>>>>> Ok what i did is the advise you gave me a few answers ago:
>>>>>>>
>>>>>>> ProducerTemplate producer =
>>>>>>> exchange.getContext().createProducerTemplate();
>>>>>>> Object response =
>>>>>>> producer.sendBody("http://localhost:8080/LiavHello/services/LiavHelloImpl",
>>>>>>> "Daviv");
>>>>>> See below
>>>>>>
>>>>>>
>>>>>>>
>>>>>>> And got this exception (SMX console after deply):
>>>>>>>
>>>>>>> : No endpoint could be found for:
>>>>>>> http://localhost:8080/LiavHello/services/LiavHelloImpl
>>>>>>> org.apache.camel.NoSuchEndpointException: No endpoint could be found
>>>>>>> for:
>>>>>>> http://localhost:8080/LiavHello/services/LiavHelloImpl
>>>>>>>
>>>>>>> LiavHelloImpl is the wsdlsoap:address location of the wsdl file
>>>>>>> representing
>>>>>>> the LiavHelloImp web project (under a running tomcat 6.0).
>>>>>>>
>>>>>>> Can you advise? It seems that the routing trying to be accomplished
>>>>>>> but
>>>>>>> something "configi" is messed up.
>>>>>>>
>>>>>>> Here is my provider xbean:
>>>>>>>
>>>>>>> <http:endpoint service="wsn:LiavHelloImplService"
>>>>>>>                 endpoint="wsn:LiavHelloImpl"
>>>>>>>                 role="provider"
>>>>>>>
>>>>>>> locationURI="http://localhost:8080/LiavHello/services/LiavHelloImpl"
>>>>>>>
>>>>>>> wsdlResource="c:/HTTPReceiverServices/LiavHelloImpl.wsdl"
>>>>>>>                 defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>>>>>>                 soap="true" />
>>>>>> When you want from Camel to call service on SMX then you must use the
>>>>>> camel-jbi component that delegates to the SU in SMX.
>>>>>> So you need to add the jbi prefix in front.
>>>>>> See: http://activemq.apache.org/camel/jbi.html
>>>>>>
>>>>>> It should be something like this. By by all means I am not SMX expert
>>>>>> (yet):
>>>>>> producer.sendBody("jbi:service:wsn:LiavHelloImplService", "Daviv");
>>>>>>
>>>>>> The jbi component have different notation so please check it out.
>>>>>>
>>>>>> If you manage to get it working, then please write back how to, so we
>>>>>> can improve the documentation and help others in the future.
>>>>>>
>>>>>>
>>>>>>
>>>>>>>
>>>>>>> Thanks!
>>>>>>>
>>>>>>>
>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>
>>>>>>>> On Sat, Jan 10, 2009 at 3:02 PM, Liav Ezer <li...@gmail.com>
>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>> Hi Claus,
>>>>>>>>>
>>>>>>>>> I did follow this camel example & set up a timer 'from' end-point
>>>>>>>>> which
>>>>>>>>> my
>>>>>>>>> processor 'catched'.
>>>>>>>>>
>>>>>>>>> My will is to query this 'catched' data by sending it to a
>>>>>>>>> different
>>>>>>>>> end-point such as a service provider.
>>>>>>>>>
>>>>>>>>> Therefore, i deployed two SU's in my servicemix: One for the camel
>>>>>>>>> routing
>>>>>>>>> (timer example) & two is for
>>>>>>>>>
>>>>>>>>> the HTTP servicemix provider which i want to invoke in the
>>>>>>>>> proceesor.
>>>>>>>>>
>>>>>>>>> My question seems simple as long as an API exists for it:
>>>>>>>>>
>>>>>>>>> When my Processor class is instansiated than the process() method
>>>>>>>>> is
>>>>>>>>> invoked:
>>>>>>>>>
>>>>>>>>> public void process(Exchange exchange) throws Exception {
>>>>>>>>>
>>>>>>>>> The exchange.getIn() consist my 'from' end-point data (=the
>>>>>>>>> timer).
>>>>>>>>>
>>>>>>>>> I need the API to fetch the Http servicemix provider end-point &
>>>>>>>>> to
>>>>>>>>> send
>>>>>>>>> hime a request with this data.
>>>>>>>> If you want to send FROM Camel to SMX then you need to use the
>>>>>>>> camel-jbi component. That is you get endpoints FROM Camel starting
>>>>>>>> with the "jbi:" prefix. See camel-jbi component.
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>> One extra small question: Do i need to replace my provider SU with
>>>>>>>>> a
>>>>>>>>> camel
>>>>>>>>> http producer SU?
>>>>>>>> If you are using SMX 3.x then you dont as SMX has one SU for Camel.
>>>>>>>> However if you need to use any of the other camel components from
>>>>>>>> SMX
>>>>>>>> you need to have them in the classpath as well, such as
>>>>>>>> camel-http.jar.
>>>>>>>>
>>>>>>>>
>>>>>>>> (In SMX 4.x its all OSGi land and you need to install features into
>>>>>>>> SMX.)
>>>>>>>>
>>>>>>>> A bit confused now. Which http provider do you want to use?
>>>>>>>> - SMX Http provider
>>>>>>>> - Camel http provider
>>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>> Thanks.
>>>>>>>>>
>>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>>>
>>>>>>>>>> Hi
>>>>>>>>>>
>>>>>>>>>> Yeah its a bit mixed up since Camel and ServiceMix have classes
>>>>>>>>>> with
>>>>>>>>>> common name: Endpoint, Exchange etc.
>>>>>>>>>>
>>>>>>>>>> All the code I have shown assumes pure Camel code.
>>>>>>>>>>
>>>>>>>>>> I advice to check the ServceMix docu about using Camel in
>>>>>>>>>> ServiceMix.
>>>>>>>>>> And get a basic example running. Such as this example
>>>>>>>>>> http://servicemix.apache.org/camel-example.html
>>>>>>>>>>
>>>>>>>>>> You could use that as a starting point to get Camel invoking your
>>>>>>>>>> HTTP
>>>>>>>>>> server. Just let the timer start it.
>>>>>>>>>> Then later your can connect using SMX instead of the camel timer.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Sat, Jan 10, 2009 at 12:53 PM, Liav Ezer <li...@gmail.com>
>>>>>>>>>> wrote:
>>>>>>>>>>>
>>>>>>>>>>> Hi Claus again,
>>>>>>>>>>>
>>>>>>>>>>> I addition to what i asked in my previouse response here is a
>>>>>>>>>>> question
>>>>>>>>>>> regarding the producer snippet which you gave in your last
>>>>>>>>>>> answer:
>>>>>>>>>>>
>>>>>>>>>>> I indeed wrote the following in my process() method:
>>>>>>>>>>>
>>>>>>>>>>> ProducerTemplate producer =
>>>>>>>>>>>
>>>>>>>>>>> exchange.getCamelContext().createProducerTemplate();
>>>>>>>>>>>                            Object response =
>>>>>>>>>>>
>>>>>>>>>>> producer.sendBody("http://myserver.com/myapp?foo=bar", "Liav
>>>>>>>>>>> Camel
>>>>>>>>>>> POC");
>>>>>>>>>>>
>>>>>>>>>>> but i don't have the camel context at hand (saying "The method
>>>>>>>>>>> getCamelContext() is undefined for the type Exchange").
>>>>>>>>>>>  & also do i need to deploy a camel http producer su instead of
>>>>>>>>>>> an
>>>>>>>>>>> http
>>>>>>>>>>> service mix provider?
>>>>>>>>>>>
>>>>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>>>>>
>>>>>>>>>>>> Hi
>>>>>>>>>>>>
>>>>>>>>>>>> When you are working with ServiceMix you must use the JBI
>>>>>>>>>>>> component
>>>>>>>>>>>> in
>>>>>>>>>>>> Camel
>>>>>>>>>>>> http://activemq.apache.org/camel/jbi.html
>>>>>>>>>>>>
>>>>>>>>>>>> So your endpoints should starting with "jbi:XXXX"
>>>>>>>>>>>>
>>>>>>>>>>>> And ServiceMix has some Camel docu here:
>>>>>>>>>>>> http://servicemix.apache.org/servicemix-camel.html
>>>>>>>>>>>>
>>>>>>>>>>>> Could you take a look at this docu a bit. There might be some
>>>>>>>>>>>> help
>>>>>>>>>>>> there.
>>>>>>>>>>>>
>>>>>>>>>>>> Try to get something more easier working with SMX and Camel and
>>>>>>>>>>>> then
>>>>>>>>>>>> later do the stuff you want with the dynamic add a camel
>>>>>>>>>>>> context.
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> On Sat, Jan 10, 2009 at 12:39 PM, Liav Ezer
>>>>>>>>>>>> <li...@gmail.com>
>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>> Hi Claus,
>>>>>>>>>>>>>
>>>>>>>>>>>>> I read your tutorial & learnt from it. Thanks. I adopted the
>>>>>>>>>>>>> cxf
>>>>>>>>>>>>> framework
>>>>>>>>>>>>> for now.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Regarding my project (as stated above in snippets):
>>>>>>>>>>>>>
>>>>>>>>>>>>> I planted the following camel routing logic at my processor
>>>>>>>>>>>>> class:
>>>>>>>>>>>>>
>>>>>>>>>>>>> process method - with camel:
>>>>>>>>>>>>>
>>>>>>>>>>>>> public void process(Exchange exchange) throws Exception {
>>>>>>>>>>>>>
>>>>>>>>>>>>>  CamelContext camel = new DefaultCamelContext();
>>>>>>>>>>>>>  camel.start();
>>>>>>>>>>>>>
>>>>>>>>>>>>>  Component component = (Component)
>>>>>>>>>>>>> camel.getComponent("http-provider-su");
>>>>>>>>>>>>>
>>>>>>>>>>>>>  Endpoint endpoint = (Endpoint) ((org.apache.camel.Component)
>>>>>>>>>>>>> component).createEndpoint("provider:com.amdocs.oxp.esb");
>>>>>>>>>>>>>
>>>>>>>>>>>>>  exchange.getIn().setBody("Liav testing here!");
>>>>>>>>>>>>>
>>>>>>>>>>>>>  Producer producer = ((org.apache.camel.Endpoint)
>>>>>>>>>>>>> endpoint).createProducer();
>>>>>>>>>>>>>
>>>>>>>>>>>>>  producer.start();
>>>>>>>>>>>>>  producer.process(exchange);
>>>>>>>>>>>>>  producer.stop();
>>>>>>>>>>>>>
>>>>>>>>>>>>>  //System.out.println(exchange.getIn().toString() + "process
>>>>>>>>>>>>> activated
>>>>>>>>>>>>> by
>>>>>>>>>>>>> SU");
>>>>>>>>>>>>> }
>>>>>>>>>>>>>
>>>>>>>>>>>>> And got the following exception while SA's jar was deployed:
>>>>>>>>>>>>>
>>>>>>>>>>>>> ERROR - DeadLetterChannel              - Failed delivery for
>>>>>>>>>>>>> exchangeId:
>>>>>>>>>>>>> ID-LIAVE02/1885-1231586726193/0-0. On delivery attemp
>>>>>>>>>>>>> java.lang.NullPointerException
>>>>>>>>>>>>>        at
>>>>>>>>>>>>> org.apache.servicemix.tutorial.camel.MyProcessor.process(MyProcessor.java:33)
>>>>>>>>>>>>> at
>>>>>>>>>>>>> org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:92)
>>>>>>>>>>>>>        at
>>>>>>>>>>>>> org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:66)
>>>>>>>>>>>>>        at
>>>>>>>>>>>>> org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorT
>>>>>>>>>>>>>        at
>>>>>>>>>>>>> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:75)
>>>>>>>>>>>>>        at
>>>>>>>>>>>>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:146)
>>>>>>>>>>>>>        at
>>>>>>>>>>>>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:90)
>>>>>>>>>>>>>        at
>>>>>>>>>>>>> org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
>>>>>>>>>>>>>        at
>>>>>>>>>>>>> org.apache.camel.processor.Pipeline.process(Pipeline.java:85)
>>>>>>>>>>>>>        at
>>>>>>>>>>>>> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:39)
>>>>>>>>>>>>>        at
>>>>>>>>>>>>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
>>>>>>>>>>>>>        at
>>>>>>>>>>>>> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
>>>>>>>>>>>>>        at
>>>>>>>>>>>>> org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:91)
>>>>>>>>>>>>>        at
>>>>>>>>>>>>> org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:48)
>>>>>>>>>>>>>        at java.util.TimerThread.mainLoop(Timer.java:512)
>>>>>>>>>>>>>        at java.util.TimerThread.run(Timer.java:462)
>>>>>>>>>>>>>
>>>>>>>>>>>>> Be advise that line 33 is:Endpoint endpoint = (Endpoint)
>>>>>>>>>>>>> ((org.apache.camel.Component)
>>>>>>>>>>>>> component).createEndpoint("provider:com.amdocs.oxp.esb");
>>>>>>>>>>>>>
>>>>>>>>>>>>> My questions:
>>>>>>>>>>>>>
>>>>>>>>>>>>> 1. As bolded above i "fetched" my provider su component by
>>>>>>>>>>>>> staing
>>>>>>>>>>>>> it's
>>>>>>>>>>>>> name
>>>>>>>>>>>>> - is it correct?
>>>>>>>>>>>>>
>>>>>>>>>>>>> 2. I used the following servicemix object (not camel's) since
>>>>>>>>>>>>> i
>>>>>>>>>>>>> work
>>>>>>>>>>>>> with
>>>>>>>>>>>>> servicemix provider endpoint. That's the reason for all the
>>>>>>>>>>>>> casting
>>>>>>>>>>>>> in
>>>>>>>>>>>>> my
>>>>>>>>>>>>> code:
>>>>>>>>>>>>> import org.apache.servicemix.jbi.deployment.Component;
>>>>>>>>>>>>> import org.apache.servicemix.jbi.framework.Endpoint;
>>>>>>>>>>>>>
>>>>>>>>>>>>> Is it correct?
>>>>>>>>>>>>>
>>>>>>>>>>>>> Thank again,
>>>>>>>>>>>>> Liav Ezer.
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Hi
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> You can use the producer template to call an external http
>>>>>>>>>>>>>> server
>>>>>>>>>>>>>> and
>>>>>>>>>>>>>> get the response.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> See this tutorial:
>>>>>>>>>>>>>> http://activemq.apache.org/camel/tutorial-axis-camel.html
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> From the section - integrating Camel
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Its kinda the same but its just uses the producer template to
>>>>>>>>>>>>>> save
>>>>>>>>>>>>>> a
>>>>>>>>>>>>>> file. Its the same API for using any of the camel components.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Little sidenote:
>>>>>>>>>>>>>> And since you use InOut you should use: requestBody instread
>>>>>>>>>>>>>> of
>>>>>>>>>>>>>> sendBody. However Camel is not to stricky about this yet so
>>>>>>>>>>>>>> if
>>>>>>>>>>>>>> you
>>>>>>>>>>>>>> use
>>>>>>>>>>>>>> a send instead of request then it should work as well.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> The demo shows how to inject a producer template from spring
>>>>>>>>>>>>>> into
>>>>>>>>>>>>>> your
>>>>>>>>>>>>>> bean class = your processor. when you have this template you
>>>>>>>>>>>>>> can
>>>>>>>>>>>>>> call
>>>>>>>>>>>>>> the external http server and get the response using the
>>>>>>>>>>>>>> requestBody
>>>>>>>>>>>>>> method.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> On Thu, Jan 8, 2009 at 1:46 PM, Liav Ezer
>>>>>>>>>>>>>> <li...@gmail.com>
>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Hi,
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Here is my camel-context:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>  <camelContext id="camel"
>>>>>>>>>>>>>>> xmlns="http://activemq.apache.org/camel/schema/spring">
>>>>>>>>>>>>>>>    <package>org.apache.servicemix.tutorial.camel</package>
>>>>>>>>>>>>>>>  </camelContext>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>  <bean id="myProcessor"
>>>>>>>>>>>>>>> class="org.apache.servicemix.tutorial.camel.MyProcessor"/>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Here is my RouteBuilder java file:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> public class MyRouteBuilder extends RouteBuilder {
>>>>>>>>>>>>>>>        public void configure() {
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> from("timer://tutorial?fixedRate=true&delay=3000&period=10000")
>>>>>>>>>>>>>>>                .setBody(constant(".....................Liav
>>>>>>>>>>>>>>> Camel
>>>>>>>>>>>>>>> POC......................."))
>>>>>>>>>>>>>>>                        .to("myProcessor");
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>    }
>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Here is my processor java file:
>>>>>>>>>>>>>>> public class MyProcessor implements Processor {
>>>>>>>>>>>>>>>          public void process(Exchange exchange) throws
>>>>>>>>>>>>>>> Exception
>>>>>>>>>>>>>>> {
>>>>>>>>>>>>>>>              //WANT TO INITIATE A CALL TO http pROVIDER END
>>>>>>>>>>>>>>> POINT
>>>>>>>>>>>>>>> &
>>>>>>>>>>>>>>> PASS
>>>>>>>>>>>>>>> THE
>>>>>>>>>>>>>>> 'FROM'
>>>>>>>>>>>>>>>                  // PARAMETRS RECIEVED PROIRE TO THE
>>>>>>>>>>>>>>> PROCESSOR
>>>>>>>>>>>>>>> INVOKE.
>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Thanks.
>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>> View this message in context:
>>>>>>>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21351142.html
>>>>>>>>>>>>>>> Sent from the Camel - Users mailing list archive at
>>>>>>>>>>>>>>> Nabble.com.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> /Claus Ibsen
>>>>>>>>>>>>>> Apache Camel Committer
>>>>>>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> --
>>>>>>>>>>>>> View this message in context:
>>>>>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21387207.html
>>>>>>>>>>>>> Sent from the Camel - Users mailing list archive at
>>>>>>>>>>>>> Nabble.com.
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> --
>>>>>>>>>>>>
>>>>>>>>>>>> /Claus Ibsen
>>>>>>>>>>>> Apache Camel Committer
>>>>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>>> View this message in context:
>>>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21387318.html
>>>>>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>>
>>>>>>>>>> /Claus Ibsen
>>>>>>>>>> Apache Camel Committer
>>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> View this message in context:
>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21388391.html
>>>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>>
>>>>>>>> /Claus Ibsen
>>>>>>>> Apache Camel Committer
>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> View this message in context:
>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21389069.html
>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>>
>>>>>> /Claus Ibsen
>>>>>> Apache Camel Committer
>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21390941.html
>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>>
>>>> /Claus Ibsen
>>>> Apache Camel Committer
>>>> Blog: http://davsclaus.blogspot.com/
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21396985.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>> 
>> 
>> 
>> -- 
>> 
>> /Claus Ibsen
>> Apache Camel Committer
>> Blog: http://davsclaus.blogspot.com/
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21400664.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: How do i call an HTTP Provider end-pont from the process method?

Posted by Liav Ezer <li...@gmail.com>.
Hi Claus,

I'm stuck with a problem that my servixmix is reporting a try to send a
request to the provider but appearantly it's not able to consume the
Provider's WS.

Here is the console:

ERROR - DeadLetterChannel              - Failed delivery for exchangeId:
ID-LIAVE02/1441-1231673232762/0-2. On delivery attempt: 0 caught:
org.apache.camel.RuntimeCamelException: o
rg.apache.servicemix.camel.JbiException:
javax.jbi.messaging.MessagingException: Could not find route for exchange:
InOnly[
  id: ID:10.236.11.194-11ec5713753-2:7
  status: Active
  role: provider  
in: <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:q0="http://service.app.esb.oxp.amdocs.com" xmlns:xsd="
http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><q0:sayHello><q0:name>liav-name</q0:name>
</q0:sayHello></soapenv:Body></soape
nv:Envelope>
] for service: null and interface: null

When i develpoed the WS i tested it via eclipse with success.

Here is the xbean definition:

<http:endpoint service="wsn:LiavHelloImplSvcService"
                 endpoint="wsn:LiavHelloImplSvc"
                 role="provider"
                
locationURI="http://localhost:8080/LiavHello2/services/LiavHelloImplSvc"
                
wsdlResource="c:/HTTPReceiverServices/LiavHelloImplSvc.wsdl"
                 defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
                 soap="true" />

Why does it report null for the service & interface?

Thanks.

Claus Ibsen-2 wrote:
> 
> On Sun, Jan 11, 2009 at 9:19 AM, Liav Ezer <li...@gmail.com> wrote:
>>
>> Hi Claus,
>>
>> Yes, i changed the body (arg2 in the sendBody method) to be a SOAP
>> request
>> like the following:
>>
>> String request = "<soapenv:Envelope
>> xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'
>> xmlns:q0='http://service.app.esb.oxp.liav.com'
>> xmlns:xsd='http://www.w3.org/2001/XMLSchema'
>> xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><soapenv:Body><q0:sayHello><q0:name>liav-name</q0:name>
>> </q0:sayHello></soapenv:Body></soapenv:Envelope>";
>>
>> 1. Is it a correct payload to send a request?
> Yeah it should be something like that. You might need the <?xml
> version...> header. But try with and without it.
> 
> 
>>
>> 2. Does this method will return the provider response - The API shows
>> that
>> it returns an Object - should i cast it to be an 'Exchange' & extract the
>> response from the provider?
> When you use Camel's producer template to do a request/reply then
> Camel will extract the response from the Exchange/IN or OUT/Message,
> so you just get the payload. The type is Object but it can be what SMX
> returns, so it could be some sort of XML holder such as
> org.w3c.Document. But try and see what kind of Object you get back.
> 
> There are type converters in Camel that can convert it back to a
> String if you want to use that, or what else there is
> http://activemq.apache.org/camel/type-converter.html
> 
> 
> 
>>
>> Thanks.
>>
>> Claus Ibsen-2 wrote:
>>>
>>> On Sat, Jan 10, 2009 at 8:51 PM, Liav Ezer <li...@gmail.com> wrote:
>>>>
>>>> Hi Claus,
>>>>
>>>> I changed the notation as needed to:
>>>>
>>>> producer.sendBody("jbi:endpoint:http://localhost:8080/LiavHello/services/LiavHelloImpl",
>>>> "Netania");
>>>>
>>>>  SMX console now output some wierd error - googling it comes up with
>>>> some
>>>> xml parsing error:
>>>>
>>>> [Fatal Error] :1:1: Content is not allowed in prolog.DEBUG -
>>>> DeliveryChannelImpl            - Exception processing:
>>>> ID:10.236.11.194-11ec1f3a450-2:291 in DeliveryChannel{servicemix-camel}
>>>> ERROR - DeadLetterChannel              - Failed delivery for
>>>> exchangeId:
>>>> ID-LIAVE02/4519-1231614935663/0-50. On delivery attempt: 0 caught:
>>>> org.apache
>>>> org.apache.servicemix.camel.JbiException:
>>>> javax.jbi.messaging.MessagingException: Could not find route for
>>>> exchange:
>>>> InOnly[
>>>>  id: ID:10.236.11.194-11ec1f3a450-2:291
>>>>  status: Active
>>>>  role: provider
>>> Yeah when you send data to SMX you must remember that its expecting
>>> the payload to be according to the JBI spec. in XML format. So you
>>> should send the data as XML.
>>>
>>> "Content is not allowed in prolog" is a bit cryptical XML parser error
>>> stating that it could not find the <?xml ... ?> declaration in top of
>>> the content it was parsing.
>>>
>>> So you should send the payload as XML.
>>>
>>> BTW: Which version of SMX and Camel are you using? I think the missing
>>> method from X mails back could be because we added it in Camel 1.4.0
>>> (I think).
>>>
>>>
>>>
>>>>
>>>> Claus Ibsen-2 wrote:
>>>>>
>>>>>
>>>>>
>>>>> This is the SMX Provider xbean:
>>>>>
>>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>>> <beans xmlns:http="http://servicemix.apache.org/http/1.0"
>>>>>        xmlns:wsn="http://com.amdocs.oxp/esb"
>>>>>        xmlns="http://www.springframework.org/schema/beans"
>>>>>        xmlns:xsi="http://http://www.w3.org/2001/XMLSchema-instance"
>>>>>        xsi:schemaLocation="http://servicemix.apache.org/http/1.0
>>>>> http://servicemix.apache.org/schema/servicemix-http-3.3.1.3-fuse.xsd
>>>>>        http://www.springframework.org/schema/beans
>>>>> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
>>>>>
>>>>>                 <http:endpoint service="wsn:LiavHelloImplService"
>>>>>                  endpoint="wsn:LiavHelloImpl"
>>>>>                  role="provider"
>>>>>
>>>>> locationURI="http://localhost:8080/LiavHello/services/LiavHelloImpl"
>>>>>
>>>>> wsdlResource="c:/HTTPReceiverServices/LiavHelloImpl.wsdl"
>>>>>                  defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>>>>                  soap="true" />
>>>>> </beans>
>>>>> Any clue?
>>>>> On Sat, Jan 10, 2009 at 4:17 PM, Liav Ezer <li...@gmail.com>
>>>>> wrote:
>>>>>>
>>>>>> Hi Claus,
>>>>>>
>>>>>> Well i'll stick with the Http SMX provider end-point. I guess it's
>>>>>> should
>>>>>> integrate with camel routing with no problem.
>>>>>>
>>>>>> Ok what i did is the advise you gave me a few answers ago:
>>>>>>
>>>>>> ProducerTemplate producer =
>>>>>> exchange.getContext().createProducerTemplate();
>>>>>> Object response =
>>>>>> producer.sendBody("http://localhost:8080/LiavHello/services/LiavHelloImpl",
>>>>>> "Daviv");
>>>>> See below
>>>>>
>>>>>
>>>>>>
>>>>>> And got this exception (SMX console after deply):
>>>>>>
>>>>>> : No endpoint could be found for:
>>>>>> http://localhost:8080/LiavHello/services/LiavHelloImpl
>>>>>> org.apache.camel.NoSuchEndpointException: No endpoint could be found
>>>>>> for:
>>>>>> http://localhost:8080/LiavHello/services/LiavHelloImpl
>>>>>>
>>>>>> LiavHelloImpl is the wsdlsoap:address location of the wsdl file
>>>>>> representing
>>>>>> the LiavHelloImp web project (under a running tomcat 6.0).
>>>>>>
>>>>>> Can you advise? It seems that the routing trying to be accomplished
>>>>>> but
>>>>>> something "configi" is messed up.
>>>>>>
>>>>>> Here is my provider xbean:
>>>>>>
>>>>>> <http:endpoint service="wsn:LiavHelloImplService"
>>>>>>                 endpoint="wsn:LiavHelloImpl"
>>>>>>                 role="provider"
>>>>>>
>>>>>> locationURI="http://localhost:8080/LiavHello/services/LiavHelloImpl"
>>>>>>
>>>>>> wsdlResource="c:/HTTPReceiverServices/LiavHelloImpl.wsdl"
>>>>>>                 defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>>>>>                 soap="true" />
>>>>> When you want from Camel to call service on SMX then you must use the
>>>>> camel-jbi component that delegates to the SU in SMX.
>>>>> So you need to add the jbi prefix in front.
>>>>> See: http://activemq.apache.org/camel/jbi.html
>>>>>
>>>>> It should be something like this. By by all means I am not SMX expert
>>>>> (yet):
>>>>> producer.sendBody("jbi:service:wsn:LiavHelloImplService", "Daviv");
>>>>>
>>>>> The jbi component have different notation so please check it out.
>>>>>
>>>>> If you manage to get it working, then please write back how to, so we
>>>>> can improve the documentation and help others in the future.
>>>>>
>>>>>
>>>>>
>>>>>>
>>>>>> Thanks!
>>>>>>
>>>>>>
>>>>>> Claus Ibsen-2 wrote:
>>>>>>>
>>>>>>> On Sat, Jan 10, 2009 at 3:02 PM, Liav Ezer <li...@gmail.com>
>>>>>>> wrote:
>>>>>>>>
>>>>>>>> Hi Claus,
>>>>>>>>
>>>>>>>> I did follow this camel example & set up a timer 'from' end-point
>>>>>>>> which
>>>>>>>> my
>>>>>>>> processor 'catched'.
>>>>>>>>
>>>>>>>> My will is to query this 'catched' data by sending it to a
>>>>>>>> different
>>>>>>>> end-point such as a service provider.
>>>>>>>>
>>>>>>>> Therefore, i deployed two SU's in my servicemix: One for the camel
>>>>>>>> routing
>>>>>>>> (timer example) & two is for
>>>>>>>>
>>>>>>>> the HTTP servicemix provider which i want to invoke in the
>>>>>>>> proceesor.
>>>>>>>>
>>>>>>>> My question seems simple as long as an API exists for it:
>>>>>>>>
>>>>>>>> When my Processor class is instansiated than the process() method
>>>>>>>> is
>>>>>>>> invoked:
>>>>>>>>
>>>>>>>> public void process(Exchange exchange) throws Exception {
>>>>>>>>
>>>>>>>> The exchange.getIn() consist my 'from' end-point data (=the timer).
>>>>>>>>
>>>>>>>> I need the API to fetch the Http servicemix provider end-point & to
>>>>>>>> send
>>>>>>>> hime a request with this data.
>>>>>>> If you want to send FROM Camel to SMX then you need to use the
>>>>>>> camel-jbi component. That is you get endpoints FROM Camel starting
>>>>>>> with the "jbi:" prefix. See camel-jbi component.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>> One extra small question: Do i need to replace my provider SU with
>>>>>>>> a
>>>>>>>> camel
>>>>>>>> http producer SU?
>>>>>>> If you are using SMX 3.x then you dont as SMX has one SU for Camel.
>>>>>>> However if you need to use any of the other camel components from
>>>>>>> SMX
>>>>>>> you need to have them in the classpath as well, such as
>>>>>>> camel-http.jar.
>>>>>>>
>>>>>>>
>>>>>>> (In SMX 4.x its all OSGi land and you need to install features into
>>>>>>> SMX.)
>>>>>>>
>>>>>>> A bit confused now. Which http provider do you want to use?
>>>>>>> - SMX Http provider
>>>>>>> - Camel http provider
>>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>> Thanks.
>>>>>>>>
>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>>
>>>>>>>>> Hi
>>>>>>>>>
>>>>>>>>> Yeah its a bit mixed up since Camel and ServiceMix have classes
>>>>>>>>> with
>>>>>>>>> common name: Endpoint, Exchange etc.
>>>>>>>>>
>>>>>>>>> All the code I have shown assumes pure Camel code.
>>>>>>>>>
>>>>>>>>> I advice to check the ServceMix docu about using Camel in
>>>>>>>>> ServiceMix.
>>>>>>>>> And get a basic example running. Such as this example
>>>>>>>>> http://servicemix.apache.org/camel-example.html
>>>>>>>>>
>>>>>>>>> You could use that as a starting point to get Camel invoking your
>>>>>>>>> HTTP
>>>>>>>>> server. Just let the timer start it.
>>>>>>>>> Then later your can connect using SMX instead of the camel timer.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Sat, Jan 10, 2009 at 12:53 PM, Liav Ezer <li...@gmail.com>
>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>> Hi Claus again,
>>>>>>>>>>
>>>>>>>>>> I addition to what i asked in my previouse response here is a
>>>>>>>>>> question
>>>>>>>>>> regarding the producer snippet which you gave in your last
>>>>>>>>>> answer:
>>>>>>>>>>
>>>>>>>>>> I indeed wrote the following in my process() method:
>>>>>>>>>>
>>>>>>>>>> ProducerTemplate producer =
>>>>>>>>>>
>>>>>>>>>> exchange.getCamelContext().createProducerTemplate();
>>>>>>>>>>                            Object response =
>>>>>>>>>>
>>>>>>>>>> producer.sendBody("http://myserver.com/myapp?foo=bar", "Liav
>>>>>>>>>> Camel
>>>>>>>>>> POC");
>>>>>>>>>>
>>>>>>>>>> but i don't have the camel context at hand (saying "The method
>>>>>>>>>> getCamelContext() is undefined for the type Exchange").
>>>>>>>>>>  & also do i need to deploy a camel http producer su instead of
>>>>>>>>>> an
>>>>>>>>>> http
>>>>>>>>>> service mix provider?
>>>>>>>>>>
>>>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>>>>
>>>>>>>>>>> Hi
>>>>>>>>>>>
>>>>>>>>>>> When you are working with ServiceMix you must use the JBI
>>>>>>>>>>> component
>>>>>>>>>>> in
>>>>>>>>>>> Camel
>>>>>>>>>>> http://activemq.apache.org/camel/jbi.html
>>>>>>>>>>>
>>>>>>>>>>> So your endpoints should starting with "jbi:XXXX"
>>>>>>>>>>>
>>>>>>>>>>> And ServiceMix has some Camel docu here:
>>>>>>>>>>> http://servicemix.apache.org/servicemix-camel.html
>>>>>>>>>>>
>>>>>>>>>>> Could you take a look at this docu a bit. There might be some
>>>>>>>>>>> help
>>>>>>>>>>> there.
>>>>>>>>>>>
>>>>>>>>>>> Try to get something more easier working with SMX and Camel and
>>>>>>>>>>> then
>>>>>>>>>>> later do the stuff you want with the dynamic add a camel
>>>>>>>>>>> context.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> On Sat, Jan 10, 2009 at 12:39 PM, Liav Ezer
>>>>>>>>>>> <li...@gmail.com>
>>>>>>>>>>> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>> Hi Claus,
>>>>>>>>>>>>
>>>>>>>>>>>> I read your tutorial & learnt from it. Thanks. I adopted the
>>>>>>>>>>>> cxf
>>>>>>>>>>>> framework
>>>>>>>>>>>> for now.
>>>>>>>>>>>>
>>>>>>>>>>>> Regarding my project (as stated above in snippets):
>>>>>>>>>>>>
>>>>>>>>>>>> I planted the following camel routing logic at my processor
>>>>>>>>>>>> class:
>>>>>>>>>>>>
>>>>>>>>>>>> process method - with camel:
>>>>>>>>>>>>
>>>>>>>>>>>> public void process(Exchange exchange) throws Exception {
>>>>>>>>>>>>
>>>>>>>>>>>>  CamelContext camel = new DefaultCamelContext();
>>>>>>>>>>>>  camel.start();
>>>>>>>>>>>>
>>>>>>>>>>>>  Component component = (Component)
>>>>>>>>>>>> camel.getComponent("http-provider-su");
>>>>>>>>>>>>
>>>>>>>>>>>>  Endpoint endpoint = (Endpoint) ((org.apache.camel.Component)
>>>>>>>>>>>> component).createEndpoint("provider:com.amdocs.oxp.esb");
>>>>>>>>>>>>
>>>>>>>>>>>>  exchange.getIn().setBody("Liav testing here!");
>>>>>>>>>>>>
>>>>>>>>>>>>  Producer producer = ((org.apache.camel.Endpoint)
>>>>>>>>>>>> endpoint).createProducer();
>>>>>>>>>>>>
>>>>>>>>>>>>  producer.start();
>>>>>>>>>>>>  producer.process(exchange);
>>>>>>>>>>>>  producer.stop();
>>>>>>>>>>>>
>>>>>>>>>>>>  //System.out.println(exchange.getIn().toString() + "process
>>>>>>>>>>>> activated
>>>>>>>>>>>> by
>>>>>>>>>>>> SU");
>>>>>>>>>>>> }
>>>>>>>>>>>>
>>>>>>>>>>>> And got the following exception while SA's jar was deployed:
>>>>>>>>>>>>
>>>>>>>>>>>> ERROR - DeadLetterChannel              - Failed delivery for
>>>>>>>>>>>> exchangeId:
>>>>>>>>>>>> ID-LIAVE02/1885-1231586726193/0-0. On delivery attemp
>>>>>>>>>>>> java.lang.NullPointerException
>>>>>>>>>>>>        at
>>>>>>>>>>>> org.apache.servicemix.tutorial.camel.MyProcessor.process(MyProcessor.java:33)
>>>>>>>>>>>> at
>>>>>>>>>>>> org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:92)
>>>>>>>>>>>>        at
>>>>>>>>>>>> org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:66)
>>>>>>>>>>>>        at
>>>>>>>>>>>> org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorT
>>>>>>>>>>>>        at
>>>>>>>>>>>> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:75)
>>>>>>>>>>>>        at
>>>>>>>>>>>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:146)
>>>>>>>>>>>>        at
>>>>>>>>>>>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:90)
>>>>>>>>>>>>        at
>>>>>>>>>>>> org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
>>>>>>>>>>>>        at
>>>>>>>>>>>> org.apache.camel.processor.Pipeline.process(Pipeline.java:85)
>>>>>>>>>>>>        at
>>>>>>>>>>>> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:39)
>>>>>>>>>>>>        at
>>>>>>>>>>>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
>>>>>>>>>>>>        at
>>>>>>>>>>>> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
>>>>>>>>>>>>        at
>>>>>>>>>>>> org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:91)
>>>>>>>>>>>>        at
>>>>>>>>>>>> org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:48)
>>>>>>>>>>>>        at java.util.TimerThread.mainLoop(Timer.java:512)
>>>>>>>>>>>>        at java.util.TimerThread.run(Timer.java:462)
>>>>>>>>>>>>
>>>>>>>>>>>> Be advise that line 33 is:Endpoint endpoint = (Endpoint)
>>>>>>>>>>>> ((org.apache.camel.Component)
>>>>>>>>>>>> component).createEndpoint("provider:com.amdocs.oxp.esb");
>>>>>>>>>>>>
>>>>>>>>>>>> My questions:
>>>>>>>>>>>>
>>>>>>>>>>>> 1. As bolded above i "fetched" my provider su component by
>>>>>>>>>>>> staing
>>>>>>>>>>>> it's
>>>>>>>>>>>> name
>>>>>>>>>>>> - is it correct?
>>>>>>>>>>>>
>>>>>>>>>>>> 2. I used the following servicemix object (not camel's) since i
>>>>>>>>>>>> work
>>>>>>>>>>>> with
>>>>>>>>>>>> servicemix provider endpoint. That's the reason for all the
>>>>>>>>>>>> casting
>>>>>>>>>>>> in
>>>>>>>>>>>> my
>>>>>>>>>>>> code:
>>>>>>>>>>>> import org.apache.servicemix.jbi.deployment.Component;
>>>>>>>>>>>> import org.apache.servicemix.jbi.framework.Endpoint;
>>>>>>>>>>>>
>>>>>>>>>>>> Is it correct?
>>>>>>>>>>>>
>>>>>>>>>>>> Thank again,
>>>>>>>>>>>> Liav Ezer.
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>> Hi
>>>>>>>>>>>>>
>>>>>>>>>>>>> You can use the producer template to call an external http
>>>>>>>>>>>>> server
>>>>>>>>>>>>> and
>>>>>>>>>>>>> get the response.
>>>>>>>>>>>>>
>>>>>>>>>>>>> See this tutorial:
>>>>>>>>>>>>> http://activemq.apache.org/camel/tutorial-axis-camel.html
>>>>>>>>>>>>>
>>>>>>>>>>>>> From the section - integrating Camel
>>>>>>>>>>>>>
>>>>>>>>>>>>> Its kinda the same but its just uses the producer template to
>>>>>>>>>>>>> save
>>>>>>>>>>>>> a
>>>>>>>>>>>>> file. Its the same API for using any of the camel components.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Little sidenote:
>>>>>>>>>>>>> And since you use InOut you should use: requestBody instread
>>>>>>>>>>>>> of
>>>>>>>>>>>>> sendBody. However Camel is not to stricky about this yet so if
>>>>>>>>>>>>> you
>>>>>>>>>>>>> use
>>>>>>>>>>>>> a send instead of request then it should work as well.
>>>>>>>>>>>>>
>>>>>>>>>>>>> The demo shows how to inject a producer template from spring
>>>>>>>>>>>>> into
>>>>>>>>>>>>> your
>>>>>>>>>>>>> bean class = your processor. when you have this template you
>>>>>>>>>>>>> can
>>>>>>>>>>>>> call
>>>>>>>>>>>>> the external http server and get the response using the
>>>>>>>>>>>>> requestBody
>>>>>>>>>>>>> method.
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> On Thu, Jan 8, 2009 at 1:46 PM, Liav Ezer
>>>>>>>>>>>>> <li...@gmail.com>
>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Hi,
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Here is my camel-context:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  <camelContext id="camel"
>>>>>>>>>>>>>> xmlns="http://activemq.apache.org/camel/schema/spring">
>>>>>>>>>>>>>>    <package>org.apache.servicemix.tutorial.camel</package>
>>>>>>>>>>>>>>  </camelContext>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  <bean id="myProcessor"
>>>>>>>>>>>>>> class="org.apache.servicemix.tutorial.camel.MyProcessor"/>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Here is my RouteBuilder java file:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> public class MyRouteBuilder extends RouteBuilder {
>>>>>>>>>>>>>>        public void configure() {
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> from("timer://tutorial?fixedRate=true&delay=3000&period=10000")
>>>>>>>>>>>>>>                .setBody(constant(".....................Liav
>>>>>>>>>>>>>> Camel
>>>>>>>>>>>>>> POC......................."))
>>>>>>>>>>>>>>                        .to("myProcessor");
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>    }
>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Here is my processor java file:
>>>>>>>>>>>>>> public class MyProcessor implements Processor {
>>>>>>>>>>>>>>          public void process(Exchange exchange) throws
>>>>>>>>>>>>>> Exception
>>>>>>>>>>>>>> {
>>>>>>>>>>>>>>              //WANT TO INITIATE A CALL TO http pROVIDER END
>>>>>>>>>>>>>> POINT
>>>>>>>>>>>>>> &
>>>>>>>>>>>>>> PASS
>>>>>>>>>>>>>> THE
>>>>>>>>>>>>>> 'FROM'
>>>>>>>>>>>>>>                  // PARAMETRS RECIEVED PROIRE TO THE
>>>>>>>>>>>>>> PROCESSOR
>>>>>>>>>>>>>> INVOKE.
>>>>>>>>>>>>>> }
>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Thanks.
>>>>>>>>>>>>>> --
>>>>>>>>>>>>>> View this message in context:
>>>>>>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21351142.html
>>>>>>>>>>>>>> Sent from the Camel - Users mailing list archive at
>>>>>>>>>>>>>> Nabble.com.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> --
>>>>>>>>>>>>>
>>>>>>>>>>>>> /Claus Ibsen
>>>>>>>>>>>>> Apache Camel Committer
>>>>>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> --
>>>>>>>>>>>> View this message in context:
>>>>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21387207.html
>>>>>>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>>>
>>>>>>>>>>> /Claus Ibsen
>>>>>>>>>>> Apache Camel Committer
>>>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> View this message in context:
>>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21387318.html
>>>>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>>
>>>>>>>>> /Claus Ibsen
>>>>>>>>> Apache Camel Committer
>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> View this message in context:
>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21388391.html
>>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>>
>>>>>>> /Claus Ibsen
>>>>>>> Apache Camel Committer
>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> --
>>>>>> View this message in context:
>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21389069.html
>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>>
>>>>> /Claus Ibsen
>>>>> Apache Camel Committer
>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>
>>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21390941.html
>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>>
>>> /Claus Ibsen
>>> Apache Camel Committer
>>> Blog: http://davsclaus.blogspot.com/
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21396985.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> 
> /Claus Ibsen
> Apache Camel Committer
> Blog: http://davsclaus.blogspot.com/
> 
> 

-- 
View this message in context: http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21398304.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: How do i call an HTTP Provider end-pont from the process method?

Posted by Claus Ibsen <cl...@gmail.com>.
On Sun, Jan 11, 2009 at 9:19 AM, Liav Ezer <li...@gmail.com> wrote:
>
> Hi Claus,
>
> Yes, i changed the body (arg2 in the sendBody method) to be a SOAP request
> like the following:
>
> String request = "<soapenv:Envelope
> xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'
> xmlns:q0='http://service.app.esb.oxp.liav.com'
> xmlns:xsd='http://www.w3.org/2001/XMLSchema'
> xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><soapenv:Body><q0:sayHello><q0:name>liav-name</q0:name>
> </q0:sayHello></soapenv:Body></soapenv:Envelope>";
>
> 1. Is it a correct payload to send a request?
Yeah it should be something like that. You might need the <?xml
version...> header. But try with and without it.


>
> 2. Does this method will return the provider response - The API shows that
> it returns an Object - should i cast it to be an 'Exchange' & extract the
> response from the provider?
When you use Camel's producer template to do a request/reply then
Camel will extract the response from the Exchange/IN or OUT/Message,
so you just get the payload. The type is Object but it can be what SMX
returns, so it could be some sort of XML holder such as
org.w3c.Document. But try and see what kind of Object you get back.

There are type converters in Camel that can convert it back to a
String if you want to use that, or what else there is
http://activemq.apache.org/camel/type-converter.html



>
> Thanks.
>
> Claus Ibsen-2 wrote:
>>
>> On Sat, Jan 10, 2009 at 8:51 PM, Liav Ezer <li...@gmail.com> wrote:
>>>
>>> Hi Claus,
>>>
>>> I changed the notation as needed to:
>>>
>>> producer.sendBody("jbi:endpoint:http://localhost:8080/LiavHello/services/LiavHelloImpl",
>>> "Netania");
>>>
>>>  SMX console now output some wierd error - googling it comes up with some
>>> xml parsing error:
>>>
>>> [Fatal Error] :1:1: Content is not allowed in prolog.DEBUG -
>>> DeliveryChannelImpl            - Exception processing:
>>> ID:10.236.11.194-11ec1f3a450-2:291 in DeliveryChannel{servicemix-camel}
>>> ERROR - DeadLetterChannel              - Failed delivery for exchangeId:
>>> ID-LIAVE02/4519-1231614935663/0-50. On delivery attempt: 0 caught:
>>> org.apache
>>> org.apache.servicemix.camel.JbiException:
>>> javax.jbi.messaging.MessagingException: Could not find route for
>>> exchange:
>>> InOnly[
>>>  id: ID:10.236.11.194-11ec1f3a450-2:291
>>>  status: Active
>>>  role: provider
>> Yeah when you send data to SMX you must remember that its expecting
>> the payload to be according to the JBI spec. in XML format. So you
>> should send the data as XML.
>>
>> "Content is not allowed in prolog" is a bit cryptical XML parser error
>> stating that it could not find the <?xml ... ?> declaration in top of
>> the content it was parsing.
>>
>> So you should send the payload as XML.
>>
>> BTW: Which version of SMX and Camel are you using? I think the missing
>> method from X mails back could be because we added it in Camel 1.4.0
>> (I think).
>>
>>
>>
>>>
>>> Claus Ibsen-2 wrote:
>>>>
>>>>
>>>>
>>>> This is the SMX Provider xbean:
>>>>
>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>> <beans xmlns:http="http://servicemix.apache.org/http/1.0"
>>>>        xmlns:wsn="http://com.amdocs.oxp/esb"
>>>>        xmlns="http://www.springframework.org/schema/beans"
>>>>        xmlns:xsi="http://http://www.w3.org/2001/XMLSchema-instance"
>>>>        xsi:schemaLocation="http://servicemix.apache.org/http/1.0
>>>> http://servicemix.apache.org/schema/servicemix-http-3.3.1.3-fuse.xsd
>>>>        http://www.springframework.org/schema/beans
>>>> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
>>>>
>>>>                 <http:endpoint service="wsn:LiavHelloImplService"
>>>>                  endpoint="wsn:LiavHelloImpl"
>>>>                  role="provider"
>>>>
>>>> locationURI="http://localhost:8080/LiavHello/services/LiavHelloImpl"
>>>>
>>>> wsdlResource="c:/HTTPReceiverServices/LiavHelloImpl.wsdl"
>>>>                  defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>>>                  soap="true" />
>>>> </beans>
>>>> Any clue?
>>>> On Sat, Jan 10, 2009 at 4:17 PM, Liav Ezer <li...@gmail.com> wrote:
>>>>>
>>>>> Hi Claus,
>>>>>
>>>>> Well i'll stick with the Http SMX provider end-point. I guess it's
>>>>> should
>>>>> integrate with camel routing with no problem.
>>>>>
>>>>> Ok what i did is the advise you gave me a few answers ago:
>>>>>
>>>>> ProducerTemplate producer =
>>>>> exchange.getContext().createProducerTemplate();
>>>>> Object response =
>>>>> producer.sendBody("http://localhost:8080/LiavHello/services/LiavHelloImpl",
>>>>> "Daviv");
>>>> See below
>>>>
>>>>
>>>>>
>>>>> And got this exception (SMX console after deply):
>>>>>
>>>>> : No endpoint could be found for:
>>>>> http://localhost:8080/LiavHello/services/LiavHelloImpl
>>>>> org.apache.camel.NoSuchEndpointException: No endpoint could be found
>>>>> for:
>>>>> http://localhost:8080/LiavHello/services/LiavHelloImpl
>>>>>
>>>>> LiavHelloImpl is the wsdlsoap:address location of the wsdl file
>>>>> representing
>>>>> the LiavHelloImp web project (under a running tomcat 6.0).
>>>>>
>>>>> Can you advise? It seems that the routing trying to be accomplished but
>>>>> something "configi" is messed up.
>>>>>
>>>>> Here is my provider xbean:
>>>>>
>>>>> <http:endpoint service="wsn:LiavHelloImplService"
>>>>>                 endpoint="wsn:LiavHelloImpl"
>>>>>                 role="provider"
>>>>>
>>>>> locationURI="http://localhost:8080/LiavHello/services/LiavHelloImpl"
>>>>>
>>>>> wsdlResource="c:/HTTPReceiverServices/LiavHelloImpl.wsdl"
>>>>>                 defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>>>>                 soap="true" />
>>>> When you want from Camel to call service on SMX then you must use the
>>>> camel-jbi component that delegates to the SU in SMX.
>>>> So you need to add the jbi prefix in front.
>>>> See: http://activemq.apache.org/camel/jbi.html
>>>>
>>>> It should be something like this. By by all means I am not SMX expert
>>>> (yet):
>>>> producer.sendBody("jbi:service:wsn:LiavHelloImplService", "Daviv");
>>>>
>>>> The jbi component have different notation so please check it out.
>>>>
>>>> If you manage to get it working, then please write back how to, so we
>>>> can improve the documentation and help others in the future.
>>>>
>>>>
>>>>
>>>>>
>>>>> Thanks!
>>>>>
>>>>>
>>>>> Claus Ibsen-2 wrote:
>>>>>>
>>>>>> On Sat, Jan 10, 2009 at 3:02 PM, Liav Ezer <li...@gmail.com>
>>>>>> wrote:
>>>>>>>
>>>>>>> Hi Claus,
>>>>>>>
>>>>>>> I did follow this camel example & set up a timer 'from' end-point
>>>>>>> which
>>>>>>> my
>>>>>>> processor 'catched'.
>>>>>>>
>>>>>>> My will is to query this 'catched' data by sending it to a different
>>>>>>> end-point such as a service provider.
>>>>>>>
>>>>>>> Therefore, i deployed two SU's in my servicemix: One for the camel
>>>>>>> routing
>>>>>>> (timer example) & two is for
>>>>>>>
>>>>>>> the HTTP servicemix provider which i want to invoke in the proceesor.
>>>>>>>
>>>>>>> My question seems simple as long as an API exists for it:
>>>>>>>
>>>>>>> When my Processor class is instansiated than the process() method is
>>>>>>> invoked:
>>>>>>>
>>>>>>> public void process(Exchange exchange) throws Exception {
>>>>>>>
>>>>>>> The exchange.getIn() consist my 'from' end-point data (=the timer).
>>>>>>>
>>>>>>> I need the API to fetch the Http servicemix provider end-point & to
>>>>>>> send
>>>>>>> hime a request with this data.
>>>>>> If you want to send FROM Camel to SMX then you need to use the
>>>>>> camel-jbi component. That is you get endpoints FROM Camel starting
>>>>>> with the "jbi:" prefix. See camel-jbi component.
>>>>>>
>>>>>>
>>>>>>
>>>>>>>
>>>>>>> One extra small question: Do i need to replace my provider SU with a
>>>>>>> camel
>>>>>>> http producer SU?
>>>>>> If you are using SMX 3.x then you dont as SMX has one SU for Camel.
>>>>>> However if you need to use any of the other camel components from SMX
>>>>>> you need to have them in the classpath as well, such as
>>>>>> camel-http.jar.
>>>>>>
>>>>>>
>>>>>> (In SMX 4.x its all OSGi land and you need to install features into
>>>>>> SMX.)
>>>>>>
>>>>>> A bit confused now. Which http provider do you want to use?
>>>>>> - SMX Http provider
>>>>>> - Camel http provider
>>>>>>
>>>>>>
>>>>>>>
>>>>>>> Thanks.
>>>>>>>
>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>
>>>>>>>> Hi
>>>>>>>>
>>>>>>>> Yeah its a bit mixed up since Camel and ServiceMix have classes with
>>>>>>>> common name: Endpoint, Exchange etc.
>>>>>>>>
>>>>>>>> All the code I have shown assumes pure Camel code.
>>>>>>>>
>>>>>>>> I advice to check the ServceMix docu about using Camel in
>>>>>>>> ServiceMix.
>>>>>>>> And get a basic example running. Such as this example
>>>>>>>> http://servicemix.apache.org/camel-example.html
>>>>>>>>
>>>>>>>> You could use that as a starting point to get Camel invoking your
>>>>>>>> HTTP
>>>>>>>> server. Just let the timer start it.
>>>>>>>> Then later your can connect using SMX instead of the camel timer.
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On Sat, Jan 10, 2009 at 12:53 PM, Liav Ezer <li...@gmail.com>
>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>> Hi Claus again,
>>>>>>>>>
>>>>>>>>> I addition to what i asked in my previouse response here is a
>>>>>>>>> question
>>>>>>>>> regarding the producer snippet which you gave in your last answer:
>>>>>>>>>
>>>>>>>>> I indeed wrote the following in my process() method:
>>>>>>>>>
>>>>>>>>> ProducerTemplate producer =
>>>>>>>>>
>>>>>>>>> exchange.getCamelContext().createProducerTemplate();
>>>>>>>>>                            Object response =
>>>>>>>>>
>>>>>>>>> producer.sendBody("http://myserver.com/myapp?foo=bar", "Liav Camel
>>>>>>>>> POC");
>>>>>>>>>
>>>>>>>>> but i don't have the camel context at hand (saying "The method
>>>>>>>>> getCamelContext() is undefined for the type Exchange").
>>>>>>>>>  & also do i need to deploy a camel http producer su instead of an
>>>>>>>>> http
>>>>>>>>> service mix provider?
>>>>>>>>>
>>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>>>
>>>>>>>>>> Hi
>>>>>>>>>>
>>>>>>>>>> When you are working with ServiceMix you must use the JBI
>>>>>>>>>> component
>>>>>>>>>> in
>>>>>>>>>> Camel
>>>>>>>>>> http://activemq.apache.org/camel/jbi.html
>>>>>>>>>>
>>>>>>>>>> So your endpoints should starting with "jbi:XXXX"
>>>>>>>>>>
>>>>>>>>>> And ServiceMix has some Camel docu here:
>>>>>>>>>> http://servicemix.apache.org/servicemix-camel.html
>>>>>>>>>>
>>>>>>>>>> Could you take a look at this docu a bit. There might be some help
>>>>>>>>>> there.
>>>>>>>>>>
>>>>>>>>>> Try to get something more easier working with SMX and Camel and
>>>>>>>>>> then
>>>>>>>>>> later do the stuff you want with the dynamic add a camel context.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Sat, Jan 10, 2009 at 12:39 PM, Liav Ezer <li...@gmail.com>
>>>>>>>>>> wrote:
>>>>>>>>>>>
>>>>>>>>>>> Hi Claus,
>>>>>>>>>>>
>>>>>>>>>>> I read your tutorial & learnt from it. Thanks. I adopted the cxf
>>>>>>>>>>> framework
>>>>>>>>>>> for now.
>>>>>>>>>>>
>>>>>>>>>>> Regarding my project (as stated above in snippets):
>>>>>>>>>>>
>>>>>>>>>>> I planted the following camel routing logic at my processor
>>>>>>>>>>> class:
>>>>>>>>>>>
>>>>>>>>>>> process method - with camel:
>>>>>>>>>>>
>>>>>>>>>>> public void process(Exchange exchange) throws Exception {
>>>>>>>>>>>
>>>>>>>>>>>  CamelContext camel = new DefaultCamelContext();
>>>>>>>>>>>  camel.start();
>>>>>>>>>>>
>>>>>>>>>>>  Component component = (Component)
>>>>>>>>>>> camel.getComponent("http-provider-su");
>>>>>>>>>>>
>>>>>>>>>>>  Endpoint endpoint = (Endpoint) ((org.apache.camel.Component)
>>>>>>>>>>> component).createEndpoint("provider:com.amdocs.oxp.esb");
>>>>>>>>>>>
>>>>>>>>>>>  exchange.getIn().setBody("Liav testing here!");
>>>>>>>>>>>
>>>>>>>>>>>  Producer producer = ((org.apache.camel.Endpoint)
>>>>>>>>>>> endpoint).createProducer();
>>>>>>>>>>>
>>>>>>>>>>>  producer.start();
>>>>>>>>>>>  producer.process(exchange);
>>>>>>>>>>>  producer.stop();
>>>>>>>>>>>
>>>>>>>>>>>  //System.out.println(exchange.getIn().toString() + "process
>>>>>>>>>>> activated
>>>>>>>>>>> by
>>>>>>>>>>> SU");
>>>>>>>>>>> }
>>>>>>>>>>>
>>>>>>>>>>> And got the following exception while SA's jar was deployed:
>>>>>>>>>>>
>>>>>>>>>>> ERROR - DeadLetterChannel              - Failed delivery for
>>>>>>>>>>> exchangeId:
>>>>>>>>>>> ID-LIAVE02/1885-1231586726193/0-0. On delivery attemp
>>>>>>>>>>> java.lang.NullPointerException
>>>>>>>>>>>        at
>>>>>>>>>>> org.apache.servicemix.tutorial.camel.MyProcessor.process(MyProcessor.java:33)
>>>>>>>>>>> at
>>>>>>>>>>> org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:92)
>>>>>>>>>>>        at
>>>>>>>>>>> org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:66)
>>>>>>>>>>>        at
>>>>>>>>>>> org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorT
>>>>>>>>>>>        at
>>>>>>>>>>> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:75)
>>>>>>>>>>>        at
>>>>>>>>>>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:146)
>>>>>>>>>>>        at
>>>>>>>>>>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:90)
>>>>>>>>>>>        at
>>>>>>>>>>> org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
>>>>>>>>>>>        at
>>>>>>>>>>> org.apache.camel.processor.Pipeline.process(Pipeline.java:85)
>>>>>>>>>>>        at
>>>>>>>>>>> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:39)
>>>>>>>>>>>        at
>>>>>>>>>>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
>>>>>>>>>>>        at
>>>>>>>>>>> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
>>>>>>>>>>>        at
>>>>>>>>>>> org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:91)
>>>>>>>>>>>        at
>>>>>>>>>>> org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:48)
>>>>>>>>>>>        at java.util.TimerThread.mainLoop(Timer.java:512)
>>>>>>>>>>>        at java.util.TimerThread.run(Timer.java:462)
>>>>>>>>>>>
>>>>>>>>>>> Be advise that line 33 is:Endpoint endpoint = (Endpoint)
>>>>>>>>>>> ((org.apache.camel.Component)
>>>>>>>>>>> component).createEndpoint("provider:com.amdocs.oxp.esb");
>>>>>>>>>>>
>>>>>>>>>>> My questions:
>>>>>>>>>>>
>>>>>>>>>>> 1. As bolded above i "fetched" my provider su component by staing
>>>>>>>>>>> it's
>>>>>>>>>>> name
>>>>>>>>>>> - is it correct?
>>>>>>>>>>>
>>>>>>>>>>> 2. I used the following servicemix object (not camel's) since i
>>>>>>>>>>> work
>>>>>>>>>>> with
>>>>>>>>>>> servicemix provider endpoint. That's the reason for all the
>>>>>>>>>>> casting
>>>>>>>>>>> in
>>>>>>>>>>> my
>>>>>>>>>>> code:
>>>>>>>>>>> import org.apache.servicemix.jbi.deployment.Component;
>>>>>>>>>>> import org.apache.servicemix.jbi.framework.Endpoint;
>>>>>>>>>>>
>>>>>>>>>>> Is it correct?
>>>>>>>>>>>
>>>>>>>>>>> Thank again,
>>>>>>>>>>> Liav Ezer.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>>>>>
>>>>>>>>>>>> Hi
>>>>>>>>>>>>
>>>>>>>>>>>> You can use the producer template to call an external http
>>>>>>>>>>>> server
>>>>>>>>>>>> and
>>>>>>>>>>>> get the response.
>>>>>>>>>>>>
>>>>>>>>>>>> See this tutorial:
>>>>>>>>>>>> http://activemq.apache.org/camel/tutorial-axis-camel.html
>>>>>>>>>>>>
>>>>>>>>>>>> From the section - integrating Camel
>>>>>>>>>>>>
>>>>>>>>>>>> Its kinda the same but its just uses the producer template to
>>>>>>>>>>>> save
>>>>>>>>>>>> a
>>>>>>>>>>>> file. Its the same API for using any of the camel components.
>>>>>>>>>>>>
>>>>>>>>>>>> Little sidenote:
>>>>>>>>>>>> And since you use InOut you should use: requestBody instread of
>>>>>>>>>>>> sendBody. However Camel is not to stricky about this yet so if
>>>>>>>>>>>> you
>>>>>>>>>>>> use
>>>>>>>>>>>> a send instead of request then it should work as well.
>>>>>>>>>>>>
>>>>>>>>>>>> The demo shows how to inject a producer template from spring
>>>>>>>>>>>> into
>>>>>>>>>>>> your
>>>>>>>>>>>> bean class = your processor. when you have this template you can
>>>>>>>>>>>> call
>>>>>>>>>>>> the external http server and get the response using the
>>>>>>>>>>>> requestBody
>>>>>>>>>>>> method.
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> On Thu, Jan 8, 2009 at 1:46 PM, Liav Ezer <li...@gmail.com>
>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>> Hi,
>>>>>>>>>>>>>
>>>>>>>>>>>>> Here is my camel-context:
>>>>>>>>>>>>>
>>>>>>>>>>>>>  <camelContext id="camel"
>>>>>>>>>>>>> xmlns="http://activemq.apache.org/camel/schema/spring">
>>>>>>>>>>>>>    <package>org.apache.servicemix.tutorial.camel</package>
>>>>>>>>>>>>>  </camelContext>
>>>>>>>>>>>>>
>>>>>>>>>>>>>  <bean id="myProcessor"
>>>>>>>>>>>>> class="org.apache.servicemix.tutorial.camel.MyProcessor"/>
>>>>>>>>>>>>>
>>>>>>>>>>>>> Here is my RouteBuilder java file:
>>>>>>>>>>>>>
>>>>>>>>>>>>> public class MyRouteBuilder extends RouteBuilder {
>>>>>>>>>>>>>        public void configure() {
>>>>>>>>>>>>>
>>>>>>>>>>>>> from("timer://tutorial?fixedRate=true&delay=3000&period=10000")
>>>>>>>>>>>>>                .setBody(constant(".....................Liav
>>>>>>>>>>>>> Camel
>>>>>>>>>>>>> POC......................."))
>>>>>>>>>>>>>                        .to("myProcessor");
>>>>>>>>>>>>>
>>>>>>>>>>>>>    }
>>>>>>>>>>>>> }
>>>>>>>>>>>>>
>>>>>>>>>>>>> Here is my processor java file:
>>>>>>>>>>>>> public class MyProcessor implements Processor {
>>>>>>>>>>>>>          public void process(Exchange exchange) throws
>>>>>>>>>>>>> Exception
>>>>>>>>>>>>> {
>>>>>>>>>>>>>              //WANT TO INITIATE A CALL TO http pROVIDER END
>>>>>>>>>>>>> POINT
>>>>>>>>>>>>> &
>>>>>>>>>>>>> PASS
>>>>>>>>>>>>> THE
>>>>>>>>>>>>> 'FROM'
>>>>>>>>>>>>>                  // PARAMETRS RECIEVED PROIRE TO THE PROCESSOR
>>>>>>>>>>>>> INVOKE.
>>>>>>>>>>>>> }
>>>>>>>>>>>>> }
>>>>>>>>>>>>>
>>>>>>>>>>>>> Thanks.
>>>>>>>>>>>>> --
>>>>>>>>>>>>> View this message in context:
>>>>>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21351142.html
>>>>>>>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> --
>>>>>>>>>>>>
>>>>>>>>>>>> /Claus Ibsen
>>>>>>>>>>>> Apache Camel Committer
>>>>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>>> View this message in context:
>>>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21387207.html
>>>>>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>>
>>>>>>>>>> /Claus Ibsen
>>>>>>>>>> Apache Camel Committer
>>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> View this message in context:
>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21387318.html
>>>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>>
>>>>>>>> /Claus Ibsen
>>>>>>>> Apache Camel Committer
>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> View this message in context:
>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21388391.html
>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>>
>>>>>> /Claus Ibsen
>>>>>> Apache Camel Committer
>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21389069.html
>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>>
>>>> /Claus Ibsen
>>>> Apache Camel Committer
>>>> Blog: http://davsclaus.blogspot.com/
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21390941.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>>
>> /Claus Ibsen
>> Apache Camel Committer
>> Blog: http://davsclaus.blogspot.com/
>>
>>
>
> --
> View this message in context: http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21396985.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 

/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/

Re: How do i call an HTTP Provider end-pont from the process method?

Posted by Liav Ezer <li...@gmail.com>.
Hi Claus,

Yes, i changed the body (arg2 in the sendBody method) to be a SOAP request
like the following:

String request = "<soapenv:Envelope
xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'
xmlns:q0='http://service.app.esb.oxp.liav.com'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><soapenv:Body><q0:sayHello><q0:name>liav-name</q0:name>
</q0:sayHello></soapenv:Body></soapenv:Envelope>";

1. Is it a correct payload to send a request?

2. Does this method will return the provider response - The API shows that
it returns an Object - should i cast it to be an 'Exchange' & extract the
response from the provider?

Thanks.

Claus Ibsen-2 wrote:
> 
> On Sat, Jan 10, 2009 at 8:51 PM, Liav Ezer <li...@gmail.com> wrote:
>>
>> Hi Claus,
>>
>> I changed the notation as needed to:
>>
>> producer.sendBody("jbi:endpoint:http://localhost:8080/LiavHello/services/LiavHelloImpl",
>> "Netania");
>>
>>  SMX console now output some wierd error - googling it comes up with some
>> xml parsing error:
>>
>> [Fatal Error] :1:1: Content is not allowed in prolog.DEBUG -
>> DeliveryChannelImpl            - Exception processing:
>> ID:10.236.11.194-11ec1f3a450-2:291 in DeliveryChannel{servicemix-camel}
>> ERROR - DeadLetterChannel              - Failed delivery for exchangeId:
>> ID-LIAVE02/4519-1231614935663/0-50. On delivery attempt: 0 caught:
>> org.apache
>> org.apache.servicemix.camel.JbiException:
>> javax.jbi.messaging.MessagingException: Could not find route for
>> exchange:
>> InOnly[
>>  id: ID:10.236.11.194-11ec1f3a450-2:291
>>  status: Active
>>  role: provider
> Yeah when you send data to SMX you must remember that its expecting
> the payload to be according to the JBI spec. in XML format. So you
> should send the data as XML.
> 
> "Content is not allowed in prolog" is a bit cryptical XML parser error
> stating that it could not find the <?xml ... ?> declaration in top of
> the content it was parsing.
> 
> So you should send the payload as XML.
> 
> BTW: Which version of SMX and Camel are you using? I think the missing
> method from X mails back could be because we added it in Camel 1.4.0
> (I think).
> 
> 
> 
>>
>> Claus Ibsen-2 wrote:
>>>
>>>
>>>
>>> This is the SMX Provider xbean:
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <beans xmlns:http="http://servicemix.apache.org/http/1.0"
>>>        xmlns:wsn="http://com.amdocs.oxp/esb"
>>>        xmlns="http://www.springframework.org/schema/beans"
>>>        xmlns:xsi="http://http://www.w3.org/2001/XMLSchema-instance"
>>>        xsi:schemaLocation="http://servicemix.apache.org/http/1.0
>>> http://servicemix.apache.org/schema/servicemix-http-3.3.1.3-fuse.xsd
>>>        http://www.springframework.org/schema/beans
>>> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
>>>
>>>                 <http:endpoint service="wsn:LiavHelloImplService"
>>>                  endpoint="wsn:LiavHelloImpl"
>>>                  role="provider"
>>>
>>> locationURI="http://localhost:8080/LiavHello/services/LiavHelloImpl"
>>>                 
>>> wsdlResource="c:/HTTPReceiverServices/LiavHelloImpl.wsdl"
>>>                  defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>>                  soap="true" />
>>> </beans>
>>> Any clue?
>>> On Sat, Jan 10, 2009 at 4:17 PM, Liav Ezer <li...@gmail.com> wrote:
>>>>
>>>> Hi Claus,
>>>>
>>>> Well i'll stick with the Http SMX provider end-point. I guess it's
>>>> should
>>>> integrate with camel routing with no problem.
>>>>
>>>> Ok what i did is the advise you gave me a few answers ago:
>>>>
>>>> ProducerTemplate producer =
>>>> exchange.getContext().createProducerTemplate();
>>>> Object response =
>>>> producer.sendBody("http://localhost:8080/LiavHello/services/LiavHelloImpl",
>>>> "Daviv");
>>> See below
>>>
>>>
>>>>
>>>> And got this exception (SMX console after deply):
>>>>
>>>> : No endpoint could be found for:
>>>> http://localhost:8080/LiavHello/services/LiavHelloImpl
>>>> org.apache.camel.NoSuchEndpointException: No endpoint could be found
>>>> for:
>>>> http://localhost:8080/LiavHello/services/LiavHelloImpl
>>>>
>>>> LiavHelloImpl is the wsdlsoap:address location of the wsdl file
>>>> representing
>>>> the LiavHelloImp web project (under a running tomcat 6.0).
>>>>
>>>> Can you advise? It seems that the routing trying to be accomplished but
>>>> something "configi" is messed up.
>>>>
>>>> Here is my provider xbean:
>>>>
>>>> <http:endpoint service="wsn:LiavHelloImplService"
>>>>                 endpoint="wsn:LiavHelloImpl"
>>>>                 role="provider"
>>>>
>>>> locationURI="http://localhost:8080/LiavHello/services/LiavHelloImpl"
>>>>                
>>>> wsdlResource="c:/HTTPReceiverServices/LiavHelloImpl.wsdl"
>>>>                 defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>>>                 soap="true" />
>>> When you want from Camel to call service on SMX then you must use the
>>> camel-jbi component that delegates to the SU in SMX.
>>> So you need to add the jbi prefix in front.
>>> See: http://activemq.apache.org/camel/jbi.html
>>>
>>> It should be something like this. By by all means I am not SMX expert
>>> (yet):
>>> producer.sendBody("jbi:service:wsn:LiavHelloImplService", "Daviv");
>>>
>>> The jbi component have different notation so please check it out.
>>>
>>> If you manage to get it working, then please write back how to, so we
>>> can improve the documentation and help others in the future.
>>>
>>>
>>>
>>>>
>>>> Thanks!
>>>>
>>>>
>>>> Claus Ibsen-2 wrote:
>>>>>
>>>>> On Sat, Jan 10, 2009 at 3:02 PM, Liav Ezer <li...@gmail.com>
>>>>> wrote:
>>>>>>
>>>>>> Hi Claus,
>>>>>>
>>>>>> I did follow this camel example & set up a timer 'from' end-point
>>>>>> which
>>>>>> my
>>>>>> processor 'catched'.
>>>>>>
>>>>>> My will is to query this 'catched' data by sending it to a different
>>>>>> end-point such as a service provider.
>>>>>>
>>>>>> Therefore, i deployed two SU's in my servicemix: One for the camel
>>>>>> routing
>>>>>> (timer example) & two is for
>>>>>>
>>>>>> the HTTP servicemix provider which i want to invoke in the proceesor.
>>>>>>
>>>>>> My question seems simple as long as an API exists for it:
>>>>>>
>>>>>> When my Processor class is instansiated than the process() method is
>>>>>> invoked:
>>>>>>
>>>>>> public void process(Exchange exchange) throws Exception {
>>>>>>
>>>>>> The exchange.getIn() consist my 'from' end-point data (=the timer).
>>>>>>
>>>>>> I need the API to fetch the Http servicemix provider end-point & to
>>>>>> send
>>>>>> hime a request with this data.
>>>>> If you want to send FROM Camel to SMX then you need to use the
>>>>> camel-jbi component. That is you get endpoints FROM Camel starting
>>>>> with the "jbi:" prefix. See camel-jbi component.
>>>>>
>>>>>
>>>>>
>>>>>>
>>>>>> One extra small question: Do i need to replace my provider SU with a
>>>>>> camel
>>>>>> http producer SU?
>>>>> If you are using SMX 3.x then you dont as SMX has one SU for Camel.
>>>>> However if you need to use any of the other camel components from SMX
>>>>> you need to have them in the classpath as well, such as
>>>>> camel-http.jar.
>>>>>
>>>>>
>>>>> (In SMX 4.x its all OSGi land and you need to install features into
>>>>> SMX.)
>>>>>
>>>>> A bit confused now. Which http provider do you want to use?
>>>>> - SMX Http provider
>>>>> - Camel http provider
>>>>>
>>>>>
>>>>>>
>>>>>> Thanks.
>>>>>>
>>>>>> Claus Ibsen-2 wrote:
>>>>>>>
>>>>>>> Hi
>>>>>>>
>>>>>>> Yeah its a bit mixed up since Camel and ServiceMix have classes with
>>>>>>> common name: Endpoint, Exchange etc.
>>>>>>>
>>>>>>> All the code I have shown assumes pure Camel code.
>>>>>>>
>>>>>>> I advice to check the ServceMix docu about using Camel in
>>>>>>> ServiceMix.
>>>>>>> And get a basic example running. Such as this example
>>>>>>> http://servicemix.apache.org/camel-example.html
>>>>>>>
>>>>>>> You could use that as a starting point to get Camel invoking your
>>>>>>> HTTP
>>>>>>> server. Just let the timer start it.
>>>>>>> Then later your can connect using SMX instead of the camel timer.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Sat, Jan 10, 2009 at 12:53 PM, Liav Ezer <li...@gmail.com>
>>>>>>> wrote:
>>>>>>>>
>>>>>>>> Hi Claus again,
>>>>>>>>
>>>>>>>> I addition to what i asked in my previouse response here is a
>>>>>>>> question
>>>>>>>> regarding the producer snippet which you gave in your last answer:
>>>>>>>>
>>>>>>>> I indeed wrote the following in my process() method:
>>>>>>>>
>>>>>>>> ProducerTemplate producer =
>>>>>>>>
>>>>>>>> exchange.getCamelContext().createProducerTemplate();
>>>>>>>>                            Object response =
>>>>>>>>
>>>>>>>> producer.sendBody("http://myserver.com/myapp?foo=bar", "Liav Camel
>>>>>>>> POC");
>>>>>>>>
>>>>>>>> but i don't have the camel context at hand (saying "The method
>>>>>>>> getCamelContext() is undefined for the type Exchange").
>>>>>>>>  & also do i need to deploy a camel http producer su instead of an
>>>>>>>> http
>>>>>>>> service mix provider?
>>>>>>>>
>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>>
>>>>>>>>> Hi
>>>>>>>>>
>>>>>>>>> When you are working with ServiceMix you must use the JBI
>>>>>>>>> component
>>>>>>>>> in
>>>>>>>>> Camel
>>>>>>>>> http://activemq.apache.org/camel/jbi.html
>>>>>>>>>
>>>>>>>>> So your endpoints should starting with "jbi:XXXX"
>>>>>>>>>
>>>>>>>>> And ServiceMix has some Camel docu here:
>>>>>>>>> http://servicemix.apache.org/servicemix-camel.html
>>>>>>>>>
>>>>>>>>> Could you take a look at this docu a bit. There might be some help
>>>>>>>>> there.
>>>>>>>>>
>>>>>>>>> Try to get something more easier working with SMX and Camel and
>>>>>>>>> then
>>>>>>>>> later do the stuff you want with the dynamic add a camel context.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Sat, Jan 10, 2009 at 12:39 PM, Liav Ezer <li...@gmail.com>
>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>> Hi Claus,
>>>>>>>>>>
>>>>>>>>>> I read your tutorial & learnt from it. Thanks. I adopted the cxf
>>>>>>>>>> framework
>>>>>>>>>> for now.
>>>>>>>>>>
>>>>>>>>>> Regarding my project (as stated above in snippets):
>>>>>>>>>>
>>>>>>>>>> I planted the following camel routing logic at my processor
>>>>>>>>>> class:
>>>>>>>>>>
>>>>>>>>>> process method - with camel:
>>>>>>>>>>
>>>>>>>>>> public void process(Exchange exchange) throws Exception {
>>>>>>>>>>
>>>>>>>>>>  CamelContext camel = new DefaultCamelContext();
>>>>>>>>>>  camel.start();
>>>>>>>>>>
>>>>>>>>>>  Component component = (Component)
>>>>>>>>>> camel.getComponent("http-provider-su");
>>>>>>>>>>
>>>>>>>>>>  Endpoint endpoint = (Endpoint) ((org.apache.camel.Component)
>>>>>>>>>> component).createEndpoint("provider:com.amdocs.oxp.esb");
>>>>>>>>>>
>>>>>>>>>>  exchange.getIn().setBody("Liav testing here!");
>>>>>>>>>>
>>>>>>>>>>  Producer producer = ((org.apache.camel.Endpoint)
>>>>>>>>>> endpoint).createProducer();
>>>>>>>>>>
>>>>>>>>>>  producer.start();
>>>>>>>>>>  producer.process(exchange);
>>>>>>>>>>  producer.stop();
>>>>>>>>>>
>>>>>>>>>>  //System.out.println(exchange.getIn().toString() + "process
>>>>>>>>>> activated
>>>>>>>>>> by
>>>>>>>>>> SU");
>>>>>>>>>> }
>>>>>>>>>>
>>>>>>>>>> And got the following exception while SA's jar was deployed:
>>>>>>>>>>
>>>>>>>>>> ERROR - DeadLetterChannel              - Failed delivery for
>>>>>>>>>> exchangeId:
>>>>>>>>>> ID-LIAVE02/1885-1231586726193/0-0. On delivery attemp
>>>>>>>>>> java.lang.NullPointerException
>>>>>>>>>>        at
>>>>>>>>>> org.apache.servicemix.tutorial.camel.MyProcessor.process(MyProcessor.java:33)
>>>>>>>>>> at
>>>>>>>>>> org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:92)
>>>>>>>>>>        at
>>>>>>>>>> org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:66)
>>>>>>>>>>        at
>>>>>>>>>> org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorT
>>>>>>>>>>        at
>>>>>>>>>> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:75)
>>>>>>>>>>        at
>>>>>>>>>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:146)
>>>>>>>>>>        at
>>>>>>>>>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:90)
>>>>>>>>>>        at
>>>>>>>>>> org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
>>>>>>>>>>        at
>>>>>>>>>> org.apache.camel.processor.Pipeline.process(Pipeline.java:85)
>>>>>>>>>>        at
>>>>>>>>>> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:39)
>>>>>>>>>>        at
>>>>>>>>>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
>>>>>>>>>>        at
>>>>>>>>>> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
>>>>>>>>>>        at
>>>>>>>>>> org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:91)
>>>>>>>>>>        at
>>>>>>>>>> org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:48)
>>>>>>>>>>        at java.util.TimerThread.mainLoop(Timer.java:512)
>>>>>>>>>>        at java.util.TimerThread.run(Timer.java:462)
>>>>>>>>>>
>>>>>>>>>> Be advise that line 33 is:Endpoint endpoint = (Endpoint)
>>>>>>>>>> ((org.apache.camel.Component)
>>>>>>>>>> component).createEndpoint("provider:com.amdocs.oxp.esb");
>>>>>>>>>>
>>>>>>>>>> My questions:
>>>>>>>>>>
>>>>>>>>>> 1. As bolded above i "fetched" my provider su component by staing
>>>>>>>>>> it's
>>>>>>>>>> name
>>>>>>>>>> - is it correct?
>>>>>>>>>>
>>>>>>>>>> 2. I used the following servicemix object (not camel's) since i
>>>>>>>>>> work
>>>>>>>>>> with
>>>>>>>>>> servicemix provider endpoint. That's the reason for all the
>>>>>>>>>> casting
>>>>>>>>>> in
>>>>>>>>>> my
>>>>>>>>>> code:
>>>>>>>>>> import org.apache.servicemix.jbi.deployment.Component;
>>>>>>>>>> import org.apache.servicemix.jbi.framework.Endpoint;
>>>>>>>>>>
>>>>>>>>>> Is it correct?
>>>>>>>>>>
>>>>>>>>>> Thank again,
>>>>>>>>>> Liav Ezer.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>>>>
>>>>>>>>>>> Hi
>>>>>>>>>>>
>>>>>>>>>>> You can use the producer template to call an external http
>>>>>>>>>>> server
>>>>>>>>>>> and
>>>>>>>>>>> get the response.
>>>>>>>>>>>
>>>>>>>>>>> See this tutorial:
>>>>>>>>>>> http://activemq.apache.org/camel/tutorial-axis-camel.html
>>>>>>>>>>>
>>>>>>>>>>> From the section - integrating Camel
>>>>>>>>>>>
>>>>>>>>>>> Its kinda the same but its just uses the producer template to
>>>>>>>>>>> save
>>>>>>>>>>> a
>>>>>>>>>>> file. Its the same API for using any of the camel components.
>>>>>>>>>>>
>>>>>>>>>>> Little sidenote:
>>>>>>>>>>> And since you use InOut you should use: requestBody instread of
>>>>>>>>>>> sendBody. However Camel is not to stricky about this yet so if
>>>>>>>>>>> you
>>>>>>>>>>> use
>>>>>>>>>>> a send instead of request then it should work as well.
>>>>>>>>>>>
>>>>>>>>>>> The demo shows how to inject a producer template from spring
>>>>>>>>>>> into
>>>>>>>>>>> your
>>>>>>>>>>> bean class = your processor. when you have this template you can
>>>>>>>>>>> call
>>>>>>>>>>> the external http server and get the response using the
>>>>>>>>>>> requestBody
>>>>>>>>>>> method.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> On Thu, Jan 8, 2009 at 1:46 PM, Liav Ezer <li...@gmail.com>
>>>>>>>>>>> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>> Hi,
>>>>>>>>>>>>
>>>>>>>>>>>> Here is my camel-context:
>>>>>>>>>>>>
>>>>>>>>>>>>  <camelContext id="camel"
>>>>>>>>>>>> xmlns="http://activemq.apache.org/camel/schema/spring">
>>>>>>>>>>>>    <package>org.apache.servicemix.tutorial.camel</package>
>>>>>>>>>>>>  </camelContext>
>>>>>>>>>>>>
>>>>>>>>>>>>  <bean id="myProcessor"
>>>>>>>>>>>> class="org.apache.servicemix.tutorial.camel.MyProcessor"/>
>>>>>>>>>>>>
>>>>>>>>>>>> Here is my RouteBuilder java file:
>>>>>>>>>>>>
>>>>>>>>>>>> public class MyRouteBuilder extends RouteBuilder {
>>>>>>>>>>>>        public void configure() {
>>>>>>>>>>>>
>>>>>>>>>>>> from("timer://tutorial?fixedRate=true&delay=3000&period=10000")
>>>>>>>>>>>>                .setBody(constant(".....................Liav
>>>>>>>>>>>> Camel
>>>>>>>>>>>> POC......................."))
>>>>>>>>>>>>                        .to("myProcessor");
>>>>>>>>>>>>
>>>>>>>>>>>>    }
>>>>>>>>>>>> }
>>>>>>>>>>>>
>>>>>>>>>>>> Here is my processor java file:
>>>>>>>>>>>> public class MyProcessor implements Processor {
>>>>>>>>>>>>          public void process(Exchange exchange) throws
>>>>>>>>>>>> Exception
>>>>>>>>>>>> {
>>>>>>>>>>>>              //WANT TO INITIATE A CALL TO http pROVIDER END
>>>>>>>>>>>> POINT
>>>>>>>>>>>> &
>>>>>>>>>>>> PASS
>>>>>>>>>>>> THE
>>>>>>>>>>>> 'FROM'
>>>>>>>>>>>>                  // PARAMETRS RECIEVED PROIRE TO THE PROCESSOR
>>>>>>>>>>>> INVOKE.
>>>>>>>>>>>> }
>>>>>>>>>>>> }
>>>>>>>>>>>>
>>>>>>>>>>>> Thanks.
>>>>>>>>>>>> --
>>>>>>>>>>>> View this message in context:
>>>>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21351142.html
>>>>>>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>>>
>>>>>>>>>>> /Claus Ibsen
>>>>>>>>>>> Apache Camel Committer
>>>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> View this message in context:
>>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21387207.html
>>>>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>>
>>>>>>>>> /Claus Ibsen
>>>>>>>>> Apache Camel Committer
>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> View this message in context:
>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21387318.html
>>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>>
>>>>>>> /Claus Ibsen
>>>>>>> Apache Camel Committer
>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> --
>>>>>> View this message in context:
>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21388391.html
>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>>
>>>>> /Claus Ibsen
>>>>> Apache Camel Committer
>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>
>>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21389069.html
>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>>
>>> /Claus Ibsen
>>> Apache Camel Committer
>>> Blog: http://davsclaus.blogspot.com/
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21390941.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> 
> /Claus Ibsen
> Apache Camel Committer
> Blog: http://davsclaus.blogspot.com/
> 
> 

-- 
View this message in context: http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21396985.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: How do i call an HTTP Provider end-pont from the process method?

Posted by Claus Ibsen <cl...@gmail.com>.
On Sat, Jan 10, 2009 at 8:51 PM, Liav Ezer <li...@gmail.com> wrote:
>
> Hi Claus,
>
> I changed the notation as needed to:
>
> producer.sendBody("jbi:endpoint:http://localhost:8080/LiavHello/services/LiavHelloImpl",
> "Netania");
>
>  SMX console now output some wierd error - googling it comes up with some
> xml parsing error:
>
> [Fatal Error] :1:1: Content is not allowed in prolog.DEBUG -
> DeliveryChannelImpl            - Exception processing:
> ID:10.236.11.194-11ec1f3a450-2:291 in DeliveryChannel{servicemix-camel}
> ERROR - DeadLetterChannel              - Failed delivery for exchangeId:
> ID-LIAVE02/4519-1231614935663/0-50. On delivery attempt: 0 caught:
> org.apache
> org.apache.servicemix.camel.JbiException:
> javax.jbi.messaging.MessagingException: Could not find route for exchange:
> InOnly[
>  id: ID:10.236.11.194-11ec1f3a450-2:291
>  status: Active
>  role: provider
Yeah when you send data to SMX you must remember that its expecting
the payload to be according to the JBI spec. in XML format. So you
should send the data as XML.

"Content is not allowed in prolog" is a bit cryptical XML parser error
stating that it could not find the <?xml ... ?> declaration in top of
the content it was parsing.

So you should send the payload as XML.

BTW: Which version of SMX and Camel are you using? I think the missing
method from X mails back could be because we added it in Camel 1.4.0
(I think).



>
> Claus Ibsen-2 wrote:
>>
>>
>>
>> This is the SMX Provider xbean:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <beans xmlns:http="http://servicemix.apache.org/http/1.0"
>>        xmlns:wsn="http://com.amdocs.oxp/esb"
>>        xmlns="http://www.springframework.org/schema/beans"
>>        xmlns:xsi="http://http://www.w3.org/2001/XMLSchema-instance"
>>        xsi:schemaLocation="http://servicemix.apache.org/http/1.0
>> http://servicemix.apache.org/schema/servicemix-http-3.3.1.3-fuse.xsd
>>        http://www.springframework.org/schema/beans
>> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
>>
>>                 <http:endpoint service="wsn:LiavHelloImplService"
>>                  endpoint="wsn:LiavHelloImpl"
>>                  role="provider"
>>
>> locationURI="http://localhost:8080/LiavHello/services/LiavHelloImpl"
>>                  wsdlResource="c:/HTTPReceiverServices/LiavHelloImpl.wsdl"
>>                  defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>                  soap="true" />
>> </beans>
>> Any clue?
>> On Sat, Jan 10, 2009 at 4:17 PM, Liav Ezer <li...@gmail.com> wrote:
>>>
>>> Hi Claus,
>>>
>>> Well i'll stick with the Http SMX provider end-point. I guess it's should
>>> integrate with camel routing with no problem.
>>>
>>> Ok what i did is the advise you gave me a few answers ago:
>>>
>>> ProducerTemplate producer =
>>> exchange.getContext().createProducerTemplate();
>>> Object response =
>>> producer.sendBody("http://localhost:8080/LiavHello/services/LiavHelloImpl",
>>> "Daviv");
>> See below
>>
>>
>>>
>>> And got this exception (SMX console after deply):
>>>
>>> : No endpoint could be found for:
>>> http://localhost:8080/LiavHello/services/LiavHelloImpl
>>> org.apache.camel.NoSuchEndpointException: No endpoint could be found for:
>>> http://localhost:8080/LiavHello/services/LiavHelloImpl
>>>
>>> LiavHelloImpl is the wsdlsoap:address location of the wsdl file
>>> representing
>>> the LiavHelloImp web project (under a running tomcat 6.0).
>>>
>>> Can you advise? It seems that the routing trying to be accomplished but
>>> something "configi" is messed up.
>>>
>>> Here is my provider xbean:
>>>
>>> <http:endpoint service="wsn:LiavHelloImplService"
>>>                 endpoint="wsn:LiavHelloImpl"
>>>                 role="provider"
>>>
>>> locationURI="http://localhost:8080/LiavHello/services/LiavHelloImpl"
>>>                 wsdlResource="c:/HTTPReceiverServices/LiavHelloImpl.wsdl"
>>>                 defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>>                 soap="true" />
>> When you want from Camel to call service on SMX then you must use the
>> camel-jbi component that delegates to the SU in SMX.
>> So you need to add the jbi prefix in front.
>> See: http://activemq.apache.org/camel/jbi.html
>>
>> It should be something like this. By by all means I am not SMX expert
>> (yet):
>> producer.sendBody("jbi:service:wsn:LiavHelloImplService", "Daviv");
>>
>> The jbi component have different notation so please check it out.
>>
>> If you manage to get it working, then please write back how to, so we
>> can improve the documentation and help others in the future.
>>
>>
>>
>>>
>>> Thanks!
>>>
>>>
>>> Claus Ibsen-2 wrote:
>>>>
>>>> On Sat, Jan 10, 2009 at 3:02 PM, Liav Ezer <li...@gmail.com> wrote:
>>>>>
>>>>> Hi Claus,
>>>>>
>>>>> I did follow this camel example & set up a timer 'from' end-point which
>>>>> my
>>>>> processor 'catched'.
>>>>>
>>>>> My will is to query this 'catched' data by sending it to a different
>>>>> end-point such as a service provider.
>>>>>
>>>>> Therefore, i deployed two SU's in my servicemix: One for the camel
>>>>> routing
>>>>> (timer example) & two is for
>>>>>
>>>>> the HTTP servicemix provider which i want to invoke in the proceesor.
>>>>>
>>>>> My question seems simple as long as an API exists for it:
>>>>>
>>>>> When my Processor class is instansiated than the process() method is
>>>>> invoked:
>>>>>
>>>>> public void process(Exchange exchange) throws Exception {
>>>>>
>>>>> The exchange.getIn() consist my 'from' end-point data (=the timer).
>>>>>
>>>>> I need the API to fetch the Http servicemix provider end-point & to
>>>>> send
>>>>> hime a request with this data.
>>>> If you want to send FROM Camel to SMX then you need to use the
>>>> camel-jbi component. That is you get endpoints FROM Camel starting
>>>> with the "jbi:" prefix. See camel-jbi component.
>>>>
>>>>
>>>>
>>>>>
>>>>> One extra small question: Do i need to replace my provider SU with a
>>>>> camel
>>>>> http producer SU?
>>>> If you are using SMX 3.x then you dont as SMX has one SU for Camel.
>>>> However if you need to use any of the other camel components from SMX
>>>> you need to have them in the classpath as well, such as
>>>> camel-http.jar.
>>>>
>>>>
>>>> (In SMX 4.x its all OSGi land and you need to install features into
>>>> SMX.)
>>>>
>>>> A bit confused now. Which http provider do you want to use?
>>>> - SMX Http provider
>>>> - Camel http provider
>>>>
>>>>
>>>>>
>>>>> Thanks.
>>>>>
>>>>> Claus Ibsen-2 wrote:
>>>>>>
>>>>>> Hi
>>>>>>
>>>>>> Yeah its a bit mixed up since Camel and ServiceMix have classes with
>>>>>> common name: Endpoint, Exchange etc.
>>>>>>
>>>>>> All the code I have shown assumes pure Camel code.
>>>>>>
>>>>>> I advice to check the ServceMix docu about using Camel in ServiceMix.
>>>>>> And get a basic example running. Such as this example
>>>>>> http://servicemix.apache.org/camel-example.html
>>>>>>
>>>>>> You could use that as a starting point to get Camel invoking your HTTP
>>>>>> server. Just let the timer start it.
>>>>>> Then later your can connect using SMX instead of the camel timer.
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Sat, Jan 10, 2009 at 12:53 PM, Liav Ezer <li...@gmail.com>
>>>>>> wrote:
>>>>>>>
>>>>>>> Hi Claus again,
>>>>>>>
>>>>>>> I addition to what i asked in my previouse response here is a
>>>>>>> question
>>>>>>> regarding the producer snippet which you gave in your last answer:
>>>>>>>
>>>>>>> I indeed wrote the following in my process() method:
>>>>>>>
>>>>>>> ProducerTemplate producer =
>>>>>>>
>>>>>>> exchange.getCamelContext().createProducerTemplate();
>>>>>>>                            Object response =
>>>>>>>
>>>>>>> producer.sendBody("http://myserver.com/myapp?foo=bar", "Liav Camel
>>>>>>> POC");
>>>>>>>
>>>>>>> but i don't have the camel context at hand (saying "The method
>>>>>>> getCamelContext() is undefined for the type Exchange").
>>>>>>>  & also do i need to deploy a camel http producer su instead of an
>>>>>>> http
>>>>>>> service mix provider?
>>>>>>>
>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>
>>>>>>>> Hi
>>>>>>>>
>>>>>>>> When you are working with ServiceMix you must use the JBI component
>>>>>>>> in
>>>>>>>> Camel
>>>>>>>> http://activemq.apache.org/camel/jbi.html
>>>>>>>>
>>>>>>>> So your endpoints should starting with "jbi:XXXX"
>>>>>>>>
>>>>>>>> And ServiceMix has some Camel docu here:
>>>>>>>> http://servicemix.apache.org/servicemix-camel.html
>>>>>>>>
>>>>>>>> Could you take a look at this docu a bit. There might be some help
>>>>>>>> there.
>>>>>>>>
>>>>>>>> Try to get something more easier working with SMX and Camel and then
>>>>>>>> later do the stuff you want with the dynamic add a camel context.
>>>>>>>>
>>>>>>>>
>>>>>>>> On Sat, Jan 10, 2009 at 12:39 PM, Liav Ezer <li...@gmail.com>
>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>> Hi Claus,
>>>>>>>>>
>>>>>>>>> I read your tutorial & learnt from it. Thanks. I adopted the cxf
>>>>>>>>> framework
>>>>>>>>> for now.
>>>>>>>>>
>>>>>>>>> Regarding my project (as stated above in snippets):
>>>>>>>>>
>>>>>>>>> I planted the following camel routing logic at my processor class:
>>>>>>>>>
>>>>>>>>> process method - with camel:
>>>>>>>>>
>>>>>>>>> public void process(Exchange exchange) throws Exception {
>>>>>>>>>
>>>>>>>>>  CamelContext camel = new DefaultCamelContext();
>>>>>>>>>  camel.start();
>>>>>>>>>
>>>>>>>>>  Component component = (Component)
>>>>>>>>> camel.getComponent("http-provider-su");
>>>>>>>>>
>>>>>>>>>  Endpoint endpoint = (Endpoint) ((org.apache.camel.Component)
>>>>>>>>> component).createEndpoint("provider:com.amdocs.oxp.esb");
>>>>>>>>>
>>>>>>>>>  exchange.getIn().setBody("Liav testing here!");
>>>>>>>>>
>>>>>>>>>  Producer producer = ((org.apache.camel.Endpoint)
>>>>>>>>> endpoint).createProducer();
>>>>>>>>>
>>>>>>>>>  producer.start();
>>>>>>>>>  producer.process(exchange);
>>>>>>>>>  producer.stop();
>>>>>>>>>
>>>>>>>>>  //System.out.println(exchange.getIn().toString() + "process
>>>>>>>>> activated
>>>>>>>>> by
>>>>>>>>> SU");
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> And got the following exception while SA's jar was deployed:
>>>>>>>>>
>>>>>>>>> ERROR - DeadLetterChannel              - Failed delivery for
>>>>>>>>> exchangeId:
>>>>>>>>> ID-LIAVE02/1885-1231586726193/0-0. On delivery attemp
>>>>>>>>> java.lang.NullPointerException
>>>>>>>>>        at
>>>>>>>>> org.apache.servicemix.tutorial.camel.MyProcessor.process(MyProcessor.java:33)
>>>>>>>>> at
>>>>>>>>> org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:92)
>>>>>>>>>        at
>>>>>>>>> org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:66)
>>>>>>>>>        at
>>>>>>>>> org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorT
>>>>>>>>>        at
>>>>>>>>> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:75)
>>>>>>>>>        at
>>>>>>>>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:146)
>>>>>>>>>        at
>>>>>>>>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:90)
>>>>>>>>>        at
>>>>>>>>> org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
>>>>>>>>>        at
>>>>>>>>> org.apache.camel.processor.Pipeline.process(Pipeline.java:85)
>>>>>>>>>        at
>>>>>>>>> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:39)
>>>>>>>>>        at
>>>>>>>>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
>>>>>>>>>        at
>>>>>>>>> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
>>>>>>>>>        at
>>>>>>>>> org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:91)
>>>>>>>>>        at
>>>>>>>>> org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:48)
>>>>>>>>>        at java.util.TimerThread.mainLoop(Timer.java:512)
>>>>>>>>>        at java.util.TimerThread.run(Timer.java:462)
>>>>>>>>>
>>>>>>>>> Be advise that line 33 is:Endpoint endpoint = (Endpoint)
>>>>>>>>> ((org.apache.camel.Component)
>>>>>>>>> component).createEndpoint("provider:com.amdocs.oxp.esb");
>>>>>>>>>
>>>>>>>>> My questions:
>>>>>>>>>
>>>>>>>>> 1. As bolded above i "fetched" my provider su component by staing
>>>>>>>>> it's
>>>>>>>>> name
>>>>>>>>> - is it correct?
>>>>>>>>>
>>>>>>>>> 2. I used the following servicemix object (not camel's) since i
>>>>>>>>> work
>>>>>>>>> with
>>>>>>>>> servicemix provider endpoint. That's the reason for all the casting
>>>>>>>>> in
>>>>>>>>> my
>>>>>>>>> code:
>>>>>>>>> import org.apache.servicemix.jbi.deployment.Component;
>>>>>>>>> import org.apache.servicemix.jbi.framework.Endpoint;
>>>>>>>>>
>>>>>>>>> Is it correct?
>>>>>>>>>
>>>>>>>>> Thank again,
>>>>>>>>> Liav Ezer.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>>>
>>>>>>>>>> Hi
>>>>>>>>>>
>>>>>>>>>> You can use the producer template to call an external http server
>>>>>>>>>> and
>>>>>>>>>> get the response.
>>>>>>>>>>
>>>>>>>>>> See this tutorial:
>>>>>>>>>> http://activemq.apache.org/camel/tutorial-axis-camel.html
>>>>>>>>>>
>>>>>>>>>> From the section - integrating Camel
>>>>>>>>>>
>>>>>>>>>> Its kinda the same but its just uses the producer template to save
>>>>>>>>>> a
>>>>>>>>>> file. Its the same API for using any of the camel components.
>>>>>>>>>>
>>>>>>>>>> Little sidenote:
>>>>>>>>>> And since you use InOut you should use: requestBody instread of
>>>>>>>>>> sendBody. However Camel is not to stricky about this yet so if you
>>>>>>>>>> use
>>>>>>>>>> a send instead of request then it should work as well.
>>>>>>>>>>
>>>>>>>>>> The demo shows how to inject a producer template from spring into
>>>>>>>>>> your
>>>>>>>>>> bean class = your processor. when you have this template you can
>>>>>>>>>> call
>>>>>>>>>> the external http server and get the response using the
>>>>>>>>>> requestBody
>>>>>>>>>> method.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Thu, Jan 8, 2009 at 1:46 PM, Liav Ezer <li...@gmail.com>
>>>>>>>>>> wrote:
>>>>>>>>>>>
>>>>>>>>>>> Hi,
>>>>>>>>>>>
>>>>>>>>>>> Here is my camel-context:
>>>>>>>>>>>
>>>>>>>>>>>  <camelContext id="camel"
>>>>>>>>>>> xmlns="http://activemq.apache.org/camel/schema/spring">
>>>>>>>>>>>    <package>org.apache.servicemix.tutorial.camel</package>
>>>>>>>>>>>  </camelContext>
>>>>>>>>>>>
>>>>>>>>>>>  <bean id="myProcessor"
>>>>>>>>>>> class="org.apache.servicemix.tutorial.camel.MyProcessor"/>
>>>>>>>>>>>
>>>>>>>>>>> Here is my RouteBuilder java file:
>>>>>>>>>>>
>>>>>>>>>>> public class MyRouteBuilder extends RouteBuilder {
>>>>>>>>>>>        public void configure() {
>>>>>>>>>>>
>>>>>>>>>>> from("timer://tutorial?fixedRate=true&delay=3000&period=10000")
>>>>>>>>>>>                .setBody(constant(".....................Liav Camel
>>>>>>>>>>> POC......................."))
>>>>>>>>>>>                        .to("myProcessor");
>>>>>>>>>>>
>>>>>>>>>>>    }
>>>>>>>>>>> }
>>>>>>>>>>>
>>>>>>>>>>> Here is my processor java file:
>>>>>>>>>>> public class MyProcessor implements Processor {
>>>>>>>>>>>          public void process(Exchange exchange) throws Exception
>>>>>>>>>>> {
>>>>>>>>>>>              //WANT TO INITIATE A CALL TO http pROVIDER END POINT
>>>>>>>>>>> &
>>>>>>>>>>> PASS
>>>>>>>>>>> THE
>>>>>>>>>>> 'FROM'
>>>>>>>>>>>                  // PARAMETRS RECIEVED PROIRE TO THE PROCESSOR
>>>>>>>>>>> INVOKE.
>>>>>>>>>>> }
>>>>>>>>>>> }
>>>>>>>>>>>
>>>>>>>>>>> Thanks.
>>>>>>>>>>> --
>>>>>>>>>>> View this message in context:
>>>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21351142.html
>>>>>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>>
>>>>>>>>>> /Claus Ibsen
>>>>>>>>>> Apache Camel Committer
>>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> View this message in context:
>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21387207.html
>>>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>>
>>>>>>>> /Claus Ibsen
>>>>>>>> Apache Camel Committer
>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> View this message in context:
>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21387318.html
>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>>
>>>>>> /Claus Ibsen
>>>>>> Apache Camel Committer
>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21388391.html
>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>>
>>>> /Claus Ibsen
>>>> Apache Camel Committer
>>>> Blog: http://davsclaus.blogspot.com/
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21389069.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>>
>> /Claus Ibsen
>> Apache Camel Committer
>> Blog: http://davsclaus.blogspot.com/
>>
>>
>
> --
> View this message in context: http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21390941.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 

/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/

Re: How do i call an HTTP Provider end-pont from the process method?

Posted by Liav Ezer <li...@gmail.com>.
Hi Claus,

I changed the notation as needed to: 

producer.sendBody("jbi:endpoint:http://localhost:8080/LiavHello/services/LiavHelloImpl",
"Netania");

 SMX console now output some wierd error - googling it comes up with some
xml parsing error:

[Fatal Error] :1:1: Content is not allowed in prolog.DEBUG -
DeliveryChannelImpl            - Exception processing:
ID:10.236.11.194-11ec1f3a450-2:291 in DeliveryChannel{servicemix-camel}
ERROR - DeadLetterChannel              - Failed delivery for exchangeId:
ID-LIAVE02/4519-1231614935663/0-50. On delivery attempt: 0 caught:
org.apache
org.apache.servicemix.camel.JbiException:
javax.jbi.messaging.MessagingException: Could not find route for exchange:
InOnly[
  id: ID:10.236.11.194-11ec1f3a450-2:291
  status: Active
  role: provider

Claus Ibsen-2 wrote:
> 
> 
> 
> This is the SMX Provider xbean:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns:http="http://servicemix.apache.org/http/1.0"
>        xmlns:wsn="http://com.amdocs.oxp/esb"
>        xmlns="http://www.springframework.org/schema/beans"
>        xmlns:xsi="http://http://www.w3.org/2001/XMLSchema-instance"
>        xsi:schemaLocation="http://servicemix.apache.org/http/1.0
> http://servicemix.apache.org/schema/servicemix-http-3.3.1.3-fuse.xsd
>        http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
>                  
>                 <http:endpoint service="wsn:LiavHelloImplService"
>                  endpoint="wsn:LiavHelloImpl"
>                  role="provider"
>                 
> locationURI="http://localhost:8080/LiavHello/services/LiavHelloImpl"
>                  wsdlResource="c:/HTTPReceiverServices/LiavHelloImpl.wsdl"
>                  defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>                  soap="true" />
> </beans>
> Any clue?
> On Sat, Jan 10, 2009 at 4:17 PM, Liav Ezer <li...@gmail.com> wrote:
>>
>> Hi Claus,
>>
>> Well i'll stick with the Http SMX provider end-point. I guess it's should
>> integrate with camel routing with no problem.
>>
>> Ok what i did is the advise you gave me a few answers ago:
>>
>> ProducerTemplate producer =
>> exchange.getContext().createProducerTemplate();
>> Object response =
>> producer.sendBody("http://localhost:8080/LiavHello/services/LiavHelloImpl",
>> "Daviv");
> See below
> 
> 
>>
>> And got this exception (SMX console after deply):
>>
>> : No endpoint could be found for:
>> http://localhost:8080/LiavHello/services/LiavHelloImpl
>> org.apache.camel.NoSuchEndpointException: No endpoint could be found for:
>> http://localhost:8080/LiavHello/services/LiavHelloImpl
>>
>> LiavHelloImpl is the wsdlsoap:address location of the wsdl file
>> representing
>> the LiavHelloImp web project (under a running tomcat 6.0).
>>
>> Can you advise? It seems that the routing trying to be accomplished but
>> something "configi" is messed up.
>>
>> Here is my provider xbean:
>>
>> <http:endpoint service="wsn:LiavHelloImplService"
>>                 endpoint="wsn:LiavHelloImpl"
>>                 role="provider"
>>
>> locationURI="http://localhost:8080/LiavHello/services/LiavHelloImpl"
>>                 wsdlResource="c:/HTTPReceiverServices/LiavHelloImpl.wsdl"
>>                 defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>>                 soap="true" />
> When you want from Camel to call service on SMX then you must use the
> camel-jbi component that delegates to the SU in SMX.
> So you need to add the jbi prefix in front.
> See: http://activemq.apache.org/camel/jbi.html
> 
> It should be something like this. By by all means I am not SMX expert
> (yet):
> producer.sendBody("jbi:service:wsn:LiavHelloImplService", "Daviv");
> 
> The jbi component have different notation so please check it out.
> 
> If you manage to get it working, then please write back how to, so we
> can improve the documentation and help others in the future.
> 
> 
> 
>>
>> Thanks!
>>
>>
>> Claus Ibsen-2 wrote:
>>>
>>> On Sat, Jan 10, 2009 at 3:02 PM, Liav Ezer <li...@gmail.com> wrote:
>>>>
>>>> Hi Claus,
>>>>
>>>> I did follow this camel example & set up a timer 'from' end-point which
>>>> my
>>>> processor 'catched'.
>>>>
>>>> My will is to query this 'catched' data by sending it to a different
>>>> end-point such as a service provider.
>>>>
>>>> Therefore, i deployed two SU's in my servicemix: One for the camel
>>>> routing
>>>> (timer example) & two is for
>>>>
>>>> the HTTP servicemix provider which i want to invoke in the proceesor.
>>>>
>>>> My question seems simple as long as an API exists for it:
>>>>
>>>> When my Processor class is instansiated than the process() method is
>>>> invoked:
>>>>
>>>> public void process(Exchange exchange) throws Exception {
>>>>
>>>> The exchange.getIn() consist my 'from' end-point data (=the timer).
>>>>
>>>> I need the API to fetch the Http servicemix provider end-point & to
>>>> send
>>>> hime a request with this data.
>>> If you want to send FROM Camel to SMX then you need to use the
>>> camel-jbi component. That is you get endpoints FROM Camel starting
>>> with the "jbi:" prefix. See camel-jbi component.
>>>
>>>
>>>
>>>>
>>>> One extra small question: Do i need to replace my provider SU with a
>>>> camel
>>>> http producer SU?
>>> If you are using SMX 3.x then you dont as SMX has one SU for Camel.
>>> However if you need to use any of the other camel components from SMX
>>> you need to have them in the classpath as well, such as
>>> camel-http.jar.
>>>
>>>
>>> (In SMX 4.x its all OSGi land and you need to install features into
>>> SMX.)
>>>
>>> A bit confused now. Which http provider do you want to use?
>>> - SMX Http provider
>>> - Camel http provider
>>>
>>>
>>>>
>>>> Thanks.
>>>>
>>>> Claus Ibsen-2 wrote:
>>>>>
>>>>> Hi
>>>>>
>>>>> Yeah its a bit mixed up since Camel and ServiceMix have classes with
>>>>> common name: Endpoint, Exchange etc.
>>>>>
>>>>> All the code I have shown assumes pure Camel code.
>>>>>
>>>>> I advice to check the ServceMix docu about using Camel in ServiceMix.
>>>>> And get a basic example running. Such as this example
>>>>> http://servicemix.apache.org/camel-example.html
>>>>>
>>>>> You could use that as a starting point to get Camel invoking your HTTP
>>>>> server. Just let the timer start it.
>>>>> Then later your can connect using SMX instead of the camel timer.
>>>>>
>>>>>
>>>>>
>>>>> On Sat, Jan 10, 2009 at 12:53 PM, Liav Ezer <li...@gmail.com>
>>>>> wrote:
>>>>>>
>>>>>> Hi Claus again,
>>>>>>
>>>>>> I addition to what i asked in my previouse response here is a
>>>>>> question
>>>>>> regarding the producer snippet which you gave in your last answer:
>>>>>>
>>>>>> I indeed wrote the following in my process() method:
>>>>>>
>>>>>> ProducerTemplate producer =
>>>>>>
>>>>>> exchange.getCamelContext().createProducerTemplate();
>>>>>>                            Object response =
>>>>>>
>>>>>> producer.sendBody("http://myserver.com/myapp?foo=bar", "Liav Camel
>>>>>> POC");
>>>>>>
>>>>>> but i don't have the camel context at hand (saying "The method
>>>>>> getCamelContext() is undefined for the type Exchange").
>>>>>>  & also do i need to deploy a camel http producer su instead of an
>>>>>> http
>>>>>> service mix provider?
>>>>>>
>>>>>> Claus Ibsen-2 wrote:
>>>>>>>
>>>>>>> Hi
>>>>>>>
>>>>>>> When you are working with ServiceMix you must use the JBI component
>>>>>>> in
>>>>>>> Camel
>>>>>>> http://activemq.apache.org/camel/jbi.html
>>>>>>>
>>>>>>> So your endpoints should starting with "jbi:XXXX"
>>>>>>>
>>>>>>> And ServiceMix has some Camel docu here:
>>>>>>> http://servicemix.apache.org/servicemix-camel.html
>>>>>>>
>>>>>>> Could you take a look at this docu a bit. There might be some help
>>>>>>> there.
>>>>>>>
>>>>>>> Try to get something more easier working with SMX and Camel and then
>>>>>>> later do the stuff you want with the dynamic add a camel context.
>>>>>>>
>>>>>>>
>>>>>>> On Sat, Jan 10, 2009 at 12:39 PM, Liav Ezer <li...@gmail.com>
>>>>>>> wrote:
>>>>>>>>
>>>>>>>> Hi Claus,
>>>>>>>>
>>>>>>>> I read your tutorial & learnt from it. Thanks. I adopted the cxf
>>>>>>>> framework
>>>>>>>> for now.
>>>>>>>>
>>>>>>>> Regarding my project (as stated above in snippets):
>>>>>>>>
>>>>>>>> I planted the following camel routing logic at my processor class:
>>>>>>>>
>>>>>>>> process method - with camel:
>>>>>>>>
>>>>>>>> public void process(Exchange exchange) throws Exception {
>>>>>>>>
>>>>>>>>  CamelContext camel = new DefaultCamelContext();
>>>>>>>>  camel.start();
>>>>>>>>
>>>>>>>>  Component component = (Component)
>>>>>>>> camel.getComponent("http-provider-su");
>>>>>>>>
>>>>>>>>  Endpoint endpoint = (Endpoint) ((org.apache.camel.Component)
>>>>>>>> component).createEndpoint("provider:com.amdocs.oxp.esb");
>>>>>>>>
>>>>>>>>  exchange.getIn().setBody("Liav testing here!");
>>>>>>>>
>>>>>>>>  Producer producer = ((org.apache.camel.Endpoint)
>>>>>>>> endpoint).createProducer();
>>>>>>>>
>>>>>>>>  producer.start();
>>>>>>>>  producer.process(exchange);
>>>>>>>>  producer.stop();
>>>>>>>>
>>>>>>>>  //System.out.println(exchange.getIn().toString() + "process
>>>>>>>> activated
>>>>>>>> by
>>>>>>>> SU");
>>>>>>>> }
>>>>>>>>
>>>>>>>> And got the following exception while SA's jar was deployed:
>>>>>>>>
>>>>>>>> ERROR - DeadLetterChannel              - Failed delivery for
>>>>>>>> exchangeId:
>>>>>>>> ID-LIAVE02/1885-1231586726193/0-0. On delivery attemp
>>>>>>>> java.lang.NullPointerException
>>>>>>>>        at
>>>>>>>> org.apache.servicemix.tutorial.camel.MyProcessor.process(MyProcessor.java:33)
>>>>>>>> at
>>>>>>>> org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:92)
>>>>>>>>        at
>>>>>>>> org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:66)
>>>>>>>>        at
>>>>>>>> org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorT
>>>>>>>>        at
>>>>>>>> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:75)
>>>>>>>>        at
>>>>>>>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:146)
>>>>>>>>        at
>>>>>>>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:90)
>>>>>>>>        at
>>>>>>>> org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
>>>>>>>>        at
>>>>>>>> org.apache.camel.processor.Pipeline.process(Pipeline.java:85)
>>>>>>>>        at
>>>>>>>> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:39)
>>>>>>>>        at
>>>>>>>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
>>>>>>>>        at
>>>>>>>> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
>>>>>>>>        at
>>>>>>>> org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:91)
>>>>>>>>        at
>>>>>>>> org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:48)
>>>>>>>>        at java.util.TimerThread.mainLoop(Timer.java:512)
>>>>>>>>        at java.util.TimerThread.run(Timer.java:462)
>>>>>>>>
>>>>>>>> Be advise that line 33 is:Endpoint endpoint = (Endpoint)
>>>>>>>> ((org.apache.camel.Component)
>>>>>>>> component).createEndpoint("provider:com.amdocs.oxp.esb");
>>>>>>>>
>>>>>>>> My questions:
>>>>>>>>
>>>>>>>> 1. As bolded above i "fetched" my provider su component by staing
>>>>>>>> it's
>>>>>>>> name
>>>>>>>> - is it correct?
>>>>>>>>
>>>>>>>> 2. I used the following servicemix object (not camel's) since i
>>>>>>>> work
>>>>>>>> with
>>>>>>>> servicemix provider endpoint. That's the reason for all the casting
>>>>>>>> in
>>>>>>>> my
>>>>>>>> code:
>>>>>>>> import org.apache.servicemix.jbi.deployment.Component;
>>>>>>>> import org.apache.servicemix.jbi.framework.Endpoint;
>>>>>>>>
>>>>>>>> Is it correct?
>>>>>>>>
>>>>>>>> Thank again,
>>>>>>>> Liav Ezer.
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>>
>>>>>>>>> Hi
>>>>>>>>>
>>>>>>>>> You can use the producer template to call an external http server
>>>>>>>>> and
>>>>>>>>> get the response.
>>>>>>>>>
>>>>>>>>> See this tutorial:
>>>>>>>>> http://activemq.apache.org/camel/tutorial-axis-camel.html
>>>>>>>>>
>>>>>>>>> From the section - integrating Camel
>>>>>>>>>
>>>>>>>>> Its kinda the same but its just uses the producer template to save
>>>>>>>>> a
>>>>>>>>> file. Its the same API for using any of the camel components.
>>>>>>>>>
>>>>>>>>> Little sidenote:
>>>>>>>>> And since you use InOut you should use: requestBody instread of
>>>>>>>>> sendBody. However Camel is not to stricky about this yet so if you
>>>>>>>>> use
>>>>>>>>> a send instead of request then it should work as well.
>>>>>>>>>
>>>>>>>>> The demo shows how to inject a producer template from spring into
>>>>>>>>> your
>>>>>>>>> bean class = your processor. when you have this template you can
>>>>>>>>> call
>>>>>>>>> the external http server and get the response using the
>>>>>>>>> requestBody
>>>>>>>>> method.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Thu, Jan 8, 2009 at 1:46 PM, Liav Ezer <li...@gmail.com>
>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>> Hi,
>>>>>>>>>>
>>>>>>>>>> Here is my camel-context:
>>>>>>>>>>
>>>>>>>>>>  <camelContext id="camel"
>>>>>>>>>> xmlns="http://activemq.apache.org/camel/schema/spring">
>>>>>>>>>>    <package>org.apache.servicemix.tutorial.camel</package>
>>>>>>>>>>  </camelContext>
>>>>>>>>>>
>>>>>>>>>>  <bean id="myProcessor"
>>>>>>>>>> class="org.apache.servicemix.tutorial.camel.MyProcessor"/>
>>>>>>>>>>
>>>>>>>>>> Here is my RouteBuilder java file:
>>>>>>>>>>
>>>>>>>>>> public class MyRouteBuilder extends RouteBuilder {
>>>>>>>>>>        public void configure() {
>>>>>>>>>>
>>>>>>>>>> from("timer://tutorial?fixedRate=true&delay=3000&period=10000")
>>>>>>>>>>                .setBody(constant(".....................Liav Camel
>>>>>>>>>> POC......................."))
>>>>>>>>>>                        .to("myProcessor");
>>>>>>>>>>
>>>>>>>>>>    }
>>>>>>>>>> }
>>>>>>>>>>
>>>>>>>>>> Here is my processor java file:
>>>>>>>>>> public class MyProcessor implements Processor {
>>>>>>>>>>          public void process(Exchange exchange) throws Exception
>>>>>>>>>> {
>>>>>>>>>>              //WANT TO INITIATE A CALL TO http pROVIDER END POINT
>>>>>>>>>> &
>>>>>>>>>> PASS
>>>>>>>>>> THE
>>>>>>>>>> 'FROM'
>>>>>>>>>>                  // PARAMETRS RECIEVED PROIRE TO THE PROCESSOR
>>>>>>>>>> INVOKE.
>>>>>>>>>> }
>>>>>>>>>> }
>>>>>>>>>>
>>>>>>>>>> Thanks.
>>>>>>>>>> --
>>>>>>>>>> View this message in context:
>>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21351142.html
>>>>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>>
>>>>>>>>> /Claus Ibsen
>>>>>>>>> Apache Camel Committer
>>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> View this message in context:
>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21387207.html
>>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>>
>>>>>>> /Claus Ibsen
>>>>>>> Apache Camel Committer
>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> --
>>>>>> View this message in context:
>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21387318.html
>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>>
>>>>> /Claus Ibsen
>>>>> Apache Camel Committer
>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>
>>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21388391.html
>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>>
>>> /Claus Ibsen
>>> Apache Camel Committer
>>> Blog: http://davsclaus.blogspot.com/
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21389069.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> 
> /Claus Ibsen
> Apache Camel Committer
> Blog: http://davsclaus.blogspot.com/
> 
> 

-- 
View this message in context: http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21390941.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: How do i call an HTTP Provider end-pont from the process method?

Posted by Claus Ibsen <cl...@gmail.com>.
On Sat, Jan 10, 2009 at 4:17 PM, Liav Ezer <li...@gmail.com> wrote:
>
> Hi Claus,
>
> Well i'll stick with the Http SMX provider end-point. I guess it's should
> integrate with camel routing with no problem.
>
> Ok what i did is the advise you gave me a few answers ago:
>
> ProducerTemplate producer = exchange.getContext().createProducerTemplate();
> Object response =
> producer.sendBody("http://localhost:8080/LiavHello/services/LiavHelloImpl",
> "Daviv");
See below


>
> And got this exception (SMX console after deply):
>
> : No endpoint could be found for:
> http://localhost:8080/LiavHello/services/LiavHelloImpl
> org.apache.camel.NoSuchEndpointException: No endpoint could be found for:
> http://localhost:8080/LiavHello/services/LiavHelloImpl
>
> LiavHelloImpl is the wsdlsoap:address location of the wsdl file representing
> the LiavHelloImp web project (under a running tomcat 6.0).
>
> Can you advise? It seems that the routing trying to be accomplished but
> something "configi" is messed up.
>
> Here is my provider xbean:
>
> <http:endpoint service="wsn:LiavHelloImplService"
>                 endpoint="wsn:LiavHelloImpl"
>                 role="provider"
>
> locationURI="http://localhost:8080/LiavHello/services/LiavHelloImpl"
>                 wsdlResource="c:/HTTPReceiverServices/LiavHelloImpl.wsdl"
>                 defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>                 soap="true" />
When you want from Camel to call service on SMX then you must use the
camel-jbi component that delegates to the SU in SMX.
So you need to add the jbi prefix in front.
See: http://activemq.apache.org/camel/jbi.html

It should be something like this. By by all means I am not SMX expert (yet):
producer.sendBody("jbi:service:wsn:LiavHelloImplService", "Daviv");

The jbi component have different notation so please check it out.

If you manage to get it working, then please write back how to, so we
can improve the documentation and help others in the future.



>
> Thanks!
>
>
> Claus Ibsen-2 wrote:
>>
>> On Sat, Jan 10, 2009 at 3:02 PM, Liav Ezer <li...@gmail.com> wrote:
>>>
>>> Hi Claus,
>>>
>>> I did follow this camel example & set up a timer 'from' end-point which
>>> my
>>> processor 'catched'.
>>>
>>> My will is to query this 'catched' data by sending it to a different
>>> end-point such as a service provider.
>>>
>>> Therefore, i deployed two SU's in my servicemix: One for the camel
>>> routing
>>> (timer example) & two is for
>>>
>>> the HTTP servicemix provider which i want to invoke in the proceesor.
>>>
>>> My question seems simple as long as an API exists for it:
>>>
>>> When my Processor class is instansiated than the process() method is
>>> invoked:
>>>
>>> public void process(Exchange exchange) throws Exception {
>>>
>>> The exchange.getIn() consist my 'from' end-point data (=the timer).
>>>
>>> I need the API to fetch the Http servicemix provider end-point & to send
>>> hime a request with this data.
>> If you want to send FROM Camel to SMX then you need to use the
>> camel-jbi component. That is you get endpoints FROM Camel starting
>> with the "jbi:" prefix. See camel-jbi component.
>>
>>
>>
>>>
>>> One extra small question: Do i need to replace my provider SU with a
>>> camel
>>> http producer SU?
>> If you are using SMX 3.x then you dont as SMX has one SU for Camel.
>> However if you need to use any of the other camel components from SMX
>> you need to have them in the classpath as well, such as
>> camel-http.jar.
>>
>>
>> (In SMX 4.x its all OSGi land and you need to install features into SMX.)
>>
>> A bit confused now. Which http provider do you want to use?
>> - SMX Http provider
>> - Camel http provider
>>
>>
>>>
>>> Thanks.
>>>
>>> Claus Ibsen-2 wrote:
>>>>
>>>> Hi
>>>>
>>>> Yeah its a bit mixed up since Camel and ServiceMix have classes with
>>>> common name: Endpoint, Exchange etc.
>>>>
>>>> All the code I have shown assumes pure Camel code.
>>>>
>>>> I advice to check the ServceMix docu about using Camel in ServiceMix.
>>>> And get a basic example running. Such as this example
>>>> http://servicemix.apache.org/camel-example.html
>>>>
>>>> You could use that as a starting point to get Camel invoking your HTTP
>>>> server. Just let the timer start it.
>>>> Then later your can connect using SMX instead of the camel timer.
>>>>
>>>>
>>>>
>>>> On Sat, Jan 10, 2009 at 12:53 PM, Liav Ezer <li...@gmail.com> wrote:
>>>>>
>>>>> Hi Claus again,
>>>>>
>>>>> I addition to what i asked in my previouse response here is a question
>>>>> regarding the producer snippet which you gave in your last answer:
>>>>>
>>>>> I indeed wrote the following in my process() method:
>>>>>
>>>>> ProducerTemplate producer =
>>>>>
>>>>> exchange.getCamelContext().createProducerTemplate();
>>>>>                            Object response =
>>>>>
>>>>> producer.sendBody("http://myserver.com/myapp?foo=bar", "Liav Camel
>>>>> POC");
>>>>>
>>>>> but i don't have the camel context at hand (saying "The method
>>>>> getCamelContext() is undefined for the type Exchange").
>>>>>  & also do i need to deploy a camel http producer su instead of an http
>>>>> service mix provider?
>>>>>
>>>>> Claus Ibsen-2 wrote:
>>>>>>
>>>>>> Hi
>>>>>>
>>>>>> When you are working with ServiceMix you must use the JBI component in
>>>>>> Camel
>>>>>> http://activemq.apache.org/camel/jbi.html
>>>>>>
>>>>>> So your endpoints should starting with "jbi:XXXX"
>>>>>>
>>>>>> And ServiceMix has some Camel docu here:
>>>>>> http://servicemix.apache.org/servicemix-camel.html
>>>>>>
>>>>>> Could you take a look at this docu a bit. There might be some help
>>>>>> there.
>>>>>>
>>>>>> Try to get something more easier working with SMX and Camel and then
>>>>>> later do the stuff you want with the dynamic add a camel context.
>>>>>>
>>>>>>
>>>>>> On Sat, Jan 10, 2009 at 12:39 PM, Liav Ezer <li...@gmail.com>
>>>>>> wrote:
>>>>>>>
>>>>>>> Hi Claus,
>>>>>>>
>>>>>>> I read your tutorial & learnt from it. Thanks. I adopted the cxf
>>>>>>> framework
>>>>>>> for now.
>>>>>>>
>>>>>>> Regarding my project (as stated above in snippets):
>>>>>>>
>>>>>>> I planted the following camel routing logic at my processor class:
>>>>>>>
>>>>>>> process method - with camel:
>>>>>>>
>>>>>>> public void process(Exchange exchange) throws Exception {
>>>>>>>
>>>>>>>  CamelContext camel = new DefaultCamelContext();
>>>>>>>  camel.start();
>>>>>>>
>>>>>>>  Component component = (Component)
>>>>>>> camel.getComponent("http-provider-su");
>>>>>>>
>>>>>>>  Endpoint endpoint = (Endpoint) ((org.apache.camel.Component)
>>>>>>> component).createEndpoint("provider:com.amdocs.oxp.esb");
>>>>>>>
>>>>>>>  exchange.getIn().setBody("Liav testing here!");
>>>>>>>
>>>>>>>  Producer producer = ((org.apache.camel.Endpoint)
>>>>>>> endpoint).createProducer();
>>>>>>>
>>>>>>>  producer.start();
>>>>>>>  producer.process(exchange);
>>>>>>>  producer.stop();
>>>>>>>
>>>>>>>  //System.out.println(exchange.getIn().toString() + "process
>>>>>>> activated
>>>>>>> by
>>>>>>> SU");
>>>>>>> }
>>>>>>>
>>>>>>> And got the following exception while SA's jar was deployed:
>>>>>>>
>>>>>>> ERROR - DeadLetterChannel              - Failed delivery for
>>>>>>> exchangeId:
>>>>>>> ID-LIAVE02/1885-1231586726193/0-0. On delivery attemp
>>>>>>> java.lang.NullPointerException
>>>>>>>        at
>>>>>>> org.apache.servicemix.tutorial.camel.MyProcessor.process(MyProcessor.java:33)
>>>>>>> at
>>>>>>> org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:92)
>>>>>>>        at
>>>>>>> org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:66)
>>>>>>>        at
>>>>>>> org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorT
>>>>>>>        at
>>>>>>> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:75)
>>>>>>>        at
>>>>>>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:146)
>>>>>>>        at
>>>>>>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:90)
>>>>>>>        at
>>>>>>> org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
>>>>>>>        at
>>>>>>> org.apache.camel.processor.Pipeline.process(Pipeline.java:85)
>>>>>>>        at
>>>>>>> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:39)
>>>>>>>        at
>>>>>>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
>>>>>>>        at
>>>>>>> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
>>>>>>>        at
>>>>>>> org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:91)
>>>>>>>        at
>>>>>>> org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:48)
>>>>>>>        at java.util.TimerThread.mainLoop(Timer.java:512)
>>>>>>>        at java.util.TimerThread.run(Timer.java:462)
>>>>>>>
>>>>>>> Be advise that line 33 is:Endpoint endpoint = (Endpoint)
>>>>>>> ((org.apache.camel.Component)
>>>>>>> component).createEndpoint("provider:com.amdocs.oxp.esb");
>>>>>>>
>>>>>>> My questions:
>>>>>>>
>>>>>>> 1. As bolded above i "fetched" my provider su component by staing
>>>>>>> it's
>>>>>>> name
>>>>>>> - is it correct?
>>>>>>>
>>>>>>> 2. I used the following servicemix object (not camel's) since i work
>>>>>>> with
>>>>>>> servicemix provider endpoint. That's the reason for all the casting
>>>>>>> in
>>>>>>> my
>>>>>>> code:
>>>>>>> import org.apache.servicemix.jbi.deployment.Component;
>>>>>>> import org.apache.servicemix.jbi.framework.Endpoint;
>>>>>>>
>>>>>>> Is it correct?
>>>>>>>
>>>>>>> Thank again,
>>>>>>> Liav Ezer.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>
>>>>>>>> Hi
>>>>>>>>
>>>>>>>> You can use the producer template to call an external http server
>>>>>>>> and
>>>>>>>> get the response.
>>>>>>>>
>>>>>>>> See this tutorial:
>>>>>>>> http://activemq.apache.org/camel/tutorial-axis-camel.html
>>>>>>>>
>>>>>>>> From the section - integrating Camel
>>>>>>>>
>>>>>>>> Its kinda the same but its just uses the producer template to save a
>>>>>>>> file. Its the same API for using any of the camel components.
>>>>>>>>
>>>>>>>> Little sidenote:
>>>>>>>> And since you use InOut you should use: requestBody instread of
>>>>>>>> sendBody. However Camel is not to stricky about this yet so if you
>>>>>>>> use
>>>>>>>> a send instead of request then it should work as well.
>>>>>>>>
>>>>>>>> The demo shows how to inject a producer template from spring into
>>>>>>>> your
>>>>>>>> bean class = your processor. when you have this template you can
>>>>>>>> call
>>>>>>>> the external http server and get the response using the requestBody
>>>>>>>> method.
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On Thu, Jan 8, 2009 at 1:46 PM, Liav Ezer <li...@gmail.com>
>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>> Hi,
>>>>>>>>>
>>>>>>>>> Here is my camel-context:
>>>>>>>>>
>>>>>>>>>  <camelContext id="camel"
>>>>>>>>> xmlns="http://activemq.apache.org/camel/schema/spring">
>>>>>>>>>    <package>org.apache.servicemix.tutorial.camel</package>
>>>>>>>>>  </camelContext>
>>>>>>>>>
>>>>>>>>>  <bean id="myProcessor"
>>>>>>>>> class="org.apache.servicemix.tutorial.camel.MyProcessor"/>
>>>>>>>>>
>>>>>>>>> Here is my RouteBuilder java file:
>>>>>>>>>
>>>>>>>>> public class MyRouteBuilder extends RouteBuilder {
>>>>>>>>>        public void configure() {
>>>>>>>>>
>>>>>>>>> from("timer://tutorial?fixedRate=true&delay=3000&period=10000")
>>>>>>>>>                .setBody(constant(".....................Liav Camel
>>>>>>>>> POC......................."))
>>>>>>>>>                        .to("myProcessor");
>>>>>>>>>
>>>>>>>>>    }
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> Here is my processor java file:
>>>>>>>>> public class MyProcessor implements Processor {
>>>>>>>>>          public void process(Exchange exchange) throws Exception {
>>>>>>>>>              //WANT TO INITIATE A CALL TO http pROVIDER END POINT &
>>>>>>>>> PASS
>>>>>>>>> THE
>>>>>>>>> 'FROM'
>>>>>>>>>                  // PARAMETRS RECIEVED PROIRE TO THE PROCESSOR
>>>>>>>>> INVOKE.
>>>>>>>>> }
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> Thanks.
>>>>>>>>> --
>>>>>>>>> View this message in context:
>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21351142.html
>>>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>>
>>>>>>>> /Claus Ibsen
>>>>>>>> Apache Camel Committer
>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> View this message in context:
>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21387207.html
>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>>
>>>>>> /Claus Ibsen
>>>>>> Apache Camel Committer
>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21387318.html
>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>>
>>>> /Claus Ibsen
>>>> Apache Camel Committer
>>>> Blog: http://davsclaus.blogspot.com/
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21388391.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>>
>> /Claus Ibsen
>> Apache Camel Committer
>> Blog: http://davsclaus.blogspot.com/
>>
>>
>
> --
> View this message in context: http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21389069.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 

/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/

Re: How do i call an HTTP Provider end-pont from the process method?

Posted by Liav Ezer <li...@gmail.com>.
Hi Claus,

In addition to what i just wrote:

I saw your thread regarding similar problem:
http://www.nabble.com/Problem-with-jetty-endpoint-td21228613s22882.html

I tries adding all  the camel-http dependencies
(http://activemq.apache.org/camel/maven/camel-http/dependencies.html), ran
mvn install but the problem still exists.

Thanks.

Liav Ezer wrote:
> 
> Hi Claus,
> 
> Well i'll stick with the Http SMX provider end-point. I guess it's should
> integrate with camel routing with no problem.
> 
> Ok what i did is the advise you gave me a few answers ago:
> 
> ProducerTemplate producer =
> exchange.getContext().createProducerTemplate(); 
> Object response =
> producer.sendBody("http://localhost:8080/LiavHello/services/LiavHelloImpl",
> "Daviv");
> 
> And got this exception (SMX console after deply):
> 
> : No endpoint could be found for:
> http://localhost:8080/LiavHello/services/LiavHelloImpl
> org.apache.camel.NoSuchEndpointException: No endpoint could be found for:
> http://localhost:8080/LiavHello/services/LiavHelloImpl
> 
> LiavHelloImpl is the wsdlsoap:address location of the wsdl file
> representing the LiavHelloImp web project (under a running tomcat 6.0).
> 
> Can you advise? It seems that the routing trying to be accomplished but
> something "configi" is messed up.
> 
> Here is my provider xbean:
> 
> <http:endpoint service="wsn:LiavHelloImplService"
>                  endpoint="wsn:LiavHelloImpl"
>                  role="provider" 
>                 
> locationURI="http://localhost:8080/LiavHello/services/LiavHelloImpl"
>                  wsdlResource="c:/HTTPReceiverServices/LiavHelloImpl.wsdl"
>                  defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>                  soap="true" /> 
> 
> Thanks!
> 
> 
> Claus Ibsen-2 wrote:
>> 
>> On Sat, Jan 10, 2009 at 3:02 PM, Liav Ezer <li...@gmail.com> wrote:
>>>
>>> Hi Claus,
>>>
>>> I did follow this camel example & set up a timer 'from' end-point which
>>> my
>>> processor 'catched'.
>>>
>>> My will is to query this 'catched' data by sending it to a different
>>> end-point such as a service provider.
>>>
>>> Therefore, i deployed two SU's in my servicemix: One for the camel
>>> routing
>>> (timer example) & two is for
>>>
>>> the HTTP servicemix provider which i want to invoke in the proceesor.
>>>
>>> My question seems simple as long as an API exists for it:
>>>
>>> When my Processor class is instansiated than the process() method is
>>> invoked:
>>>
>>> public void process(Exchange exchange) throws Exception {
>>>
>>> The exchange.getIn() consist my 'from' end-point data (=the timer).
>>>
>>> I need the API to fetch the Http servicemix provider end-point & to send
>>> hime a request with this data.
>> If you want to send FROM Camel to SMX then you need to use the
>> camel-jbi component. That is you get endpoints FROM Camel starting
>> with the "jbi:" prefix. See camel-jbi component.
>> 
>> 
>> 
>>>
>>> One extra small question: Do i need to replace my provider SU with a
>>> camel
>>> http producer SU?
>> If you are using SMX 3.x then you dont as SMX has one SU for Camel.
>> However if you need to use any of the other camel components from SMX
>> you need to have them in the classpath as well, such as
>> camel-http.jar.
>> 
>> 
>> (In SMX 4.x its all OSGi land and you need to install features into SMX.)
>> 
>> A bit confused now. Which http provider do you want to use?
>> - SMX Http provider
>> - Camel http provider
>> 
>> 
>>>
>>> Thanks.
>>>
>>> Claus Ibsen-2 wrote:
>>>>
>>>> Hi
>>>>
>>>> Yeah its a bit mixed up since Camel and ServiceMix have classes with
>>>> common name: Endpoint, Exchange etc.
>>>>
>>>> All the code I have shown assumes pure Camel code.
>>>>
>>>> I advice to check the ServceMix docu about using Camel in ServiceMix.
>>>> And get a basic example running. Such as this example
>>>> http://servicemix.apache.org/camel-example.html
>>>>
>>>> You could use that as a starting point to get Camel invoking your HTTP
>>>> server. Just let the timer start it.
>>>> Then later your can connect using SMX instead of the camel timer.
>>>>
>>>>
>>>>
>>>> On Sat, Jan 10, 2009 at 12:53 PM, Liav Ezer <li...@gmail.com>
>>>> wrote:
>>>>>
>>>>> Hi Claus again,
>>>>>
>>>>> I addition to what i asked in my previouse response here is a question
>>>>> regarding the producer snippet which you gave in your last answer:
>>>>>
>>>>> I indeed wrote the following in my process() method:
>>>>>
>>>>> ProducerTemplate producer =
>>>>>
>>>>> exchange.getCamelContext().createProducerTemplate();
>>>>>                            Object response =
>>>>>
>>>>> producer.sendBody("http://myserver.com/myapp?foo=bar", "Liav Camel
>>>>> POC");
>>>>>
>>>>> but i don't have the camel context at hand (saying "The method
>>>>> getCamelContext() is undefined for the type Exchange").
>>>>>  & also do i need to deploy a camel http producer su instead of an
>>>>> http
>>>>> service mix provider?
>>>>>
>>>>> Claus Ibsen-2 wrote:
>>>>>>
>>>>>> Hi
>>>>>>
>>>>>> When you are working with ServiceMix you must use the JBI component
>>>>>> in
>>>>>> Camel
>>>>>> http://activemq.apache.org/camel/jbi.html
>>>>>>
>>>>>> So your endpoints should starting with "jbi:XXXX"
>>>>>>
>>>>>> And ServiceMix has some Camel docu here:
>>>>>> http://servicemix.apache.org/servicemix-camel.html
>>>>>>
>>>>>> Could you take a look at this docu a bit. There might be some help
>>>>>> there.
>>>>>>
>>>>>> Try to get something more easier working with SMX and Camel and then
>>>>>> later do the stuff you want with the dynamic add a camel context.
>>>>>>
>>>>>>
>>>>>> On Sat, Jan 10, 2009 at 12:39 PM, Liav Ezer <li...@gmail.com>
>>>>>> wrote:
>>>>>>>
>>>>>>> Hi Claus,
>>>>>>>
>>>>>>> I read your tutorial & learnt from it. Thanks. I adopted the cxf
>>>>>>> framework
>>>>>>> for now.
>>>>>>>
>>>>>>> Regarding my project (as stated above in snippets):
>>>>>>>
>>>>>>> I planted the following camel routing logic at my processor class:
>>>>>>>
>>>>>>> process method - with camel:
>>>>>>>
>>>>>>> public void process(Exchange exchange) throws Exception {
>>>>>>>
>>>>>>>  CamelContext camel = new DefaultCamelContext();
>>>>>>>  camel.start();
>>>>>>>
>>>>>>>  Component component = (Component)
>>>>>>> camel.getComponent("http-provider-su");
>>>>>>>
>>>>>>>  Endpoint endpoint = (Endpoint) ((org.apache.camel.Component)
>>>>>>> component).createEndpoint("provider:com.amdocs.oxp.esb");
>>>>>>>
>>>>>>>  exchange.getIn().setBody("Liav testing here!");
>>>>>>>
>>>>>>>  Producer producer = ((org.apache.camel.Endpoint)
>>>>>>> endpoint).createProducer();
>>>>>>>
>>>>>>>  producer.start();
>>>>>>>  producer.process(exchange);
>>>>>>>  producer.stop();
>>>>>>>
>>>>>>>  //System.out.println(exchange.getIn().toString() + "process
>>>>>>> activated
>>>>>>> by
>>>>>>> SU");
>>>>>>> }
>>>>>>>
>>>>>>> And got the following exception while SA's jar was deployed:
>>>>>>>
>>>>>>> ERROR - DeadLetterChannel              - Failed delivery for
>>>>>>> exchangeId:
>>>>>>> ID-LIAVE02/1885-1231586726193/0-0. On delivery attemp
>>>>>>> java.lang.NullPointerException
>>>>>>>        at
>>>>>>> org.apache.servicemix.tutorial.camel.MyProcessor.process(MyProcessor.java:33)
>>>>>>> at
>>>>>>> org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:92)
>>>>>>>        at
>>>>>>> org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:66)
>>>>>>>        at
>>>>>>> org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorT
>>>>>>>        at
>>>>>>> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:75)
>>>>>>>        at
>>>>>>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:146)
>>>>>>>        at
>>>>>>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:90)
>>>>>>>        at
>>>>>>> org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
>>>>>>>        at
>>>>>>> org.apache.camel.processor.Pipeline.process(Pipeline.java:85)
>>>>>>>        at
>>>>>>> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:39)
>>>>>>>        at
>>>>>>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
>>>>>>>        at
>>>>>>> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
>>>>>>>        at
>>>>>>> org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:91)
>>>>>>>        at
>>>>>>> org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:48)
>>>>>>>        at java.util.TimerThread.mainLoop(Timer.java:512)
>>>>>>>        at java.util.TimerThread.run(Timer.java:462)
>>>>>>>
>>>>>>> Be advise that line 33 is:Endpoint endpoint = (Endpoint)
>>>>>>> ((org.apache.camel.Component)
>>>>>>> component).createEndpoint("provider:com.amdocs.oxp.esb");
>>>>>>>
>>>>>>> My questions:
>>>>>>>
>>>>>>> 1. As bolded above i "fetched" my provider su component by staing
>>>>>>> it's
>>>>>>> name
>>>>>>> - is it correct?
>>>>>>>
>>>>>>> 2. I used the following servicemix object (not camel's) since i work
>>>>>>> with
>>>>>>> servicemix provider endpoint. That's the reason for all the casting
>>>>>>> in
>>>>>>> my
>>>>>>> code:
>>>>>>> import org.apache.servicemix.jbi.deployment.Component;
>>>>>>> import org.apache.servicemix.jbi.framework.Endpoint;
>>>>>>>
>>>>>>> Is it correct?
>>>>>>>
>>>>>>> Thank again,
>>>>>>> Liav Ezer.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Claus Ibsen-2 wrote:
>>>>>>>>
>>>>>>>> Hi
>>>>>>>>
>>>>>>>> You can use the producer template to call an external http server
>>>>>>>> and
>>>>>>>> get the response.
>>>>>>>>
>>>>>>>> See this tutorial:
>>>>>>>> http://activemq.apache.org/camel/tutorial-axis-camel.html
>>>>>>>>
>>>>>>>> From the section - integrating Camel
>>>>>>>>
>>>>>>>> Its kinda the same but its just uses the producer template to save
>>>>>>>> a
>>>>>>>> file. Its the same API for using any of the camel components.
>>>>>>>>
>>>>>>>> Little sidenote:
>>>>>>>> And since you use InOut you should use: requestBody instread of
>>>>>>>> sendBody. However Camel is not to stricky about this yet so if you
>>>>>>>> use
>>>>>>>> a send instead of request then it should work as well.
>>>>>>>>
>>>>>>>> The demo shows how to inject a producer template from spring into
>>>>>>>> your
>>>>>>>> bean class = your processor. when you have this template you can
>>>>>>>> call
>>>>>>>> the external http server and get the response using the requestBody
>>>>>>>> method.
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On Thu, Jan 8, 2009 at 1:46 PM, Liav Ezer <li...@gmail.com>
>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>> Hi,
>>>>>>>>>
>>>>>>>>> Here is my camel-context:
>>>>>>>>>
>>>>>>>>>  <camelContext id="camel"
>>>>>>>>> xmlns="http://activemq.apache.org/camel/schema/spring">
>>>>>>>>>    <package>org.apache.servicemix.tutorial.camel</package>
>>>>>>>>>  </camelContext>
>>>>>>>>>
>>>>>>>>>  <bean id="myProcessor"
>>>>>>>>> class="org.apache.servicemix.tutorial.camel.MyProcessor"/>
>>>>>>>>>
>>>>>>>>> Here is my RouteBuilder java file:
>>>>>>>>>
>>>>>>>>> public class MyRouteBuilder extends RouteBuilder {
>>>>>>>>>        public void configure() {
>>>>>>>>>
>>>>>>>>> from("timer://tutorial?fixedRate=true&delay=3000&period=10000")
>>>>>>>>>                .setBody(constant(".....................Liav Camel
>>>>>>>>> POC......................."))
>>>>>>>>>                        .to("myProcessor");
>>>>>>>>>
>>>>>>>>>    }
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> Here is my processor java file:
>>>>>>>>> public class MyProcessor implements Processor {
>>>>>>>>>          public void process(Exchange exchange) throws Exception {
>>>>>>>>>              //WANT TO INITIATE A CALL TO http pROVIDER END POINT
>>>>>>>>> &
>>>>>>>>> PASS
>>>>>>>>> THE
>>>>>>>>> 'FROM'
>>>>>>>>>                  // PARAMETRS RECIEVED PROIRE TO THE PROCESSOR
>>>>>>>>> INVOKE.
>>>>>>>>> }
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> Thanks.
>>>>>>>>> --
>>>>>>>>> View this message in context:
>>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21351142.html
>>>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>>
>>>>>>>> /Claus Ibsen
>>>>>>>> Apache Camel Committer
>>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> View this message in context:
>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21387207.html
>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>>
>>>>>> /Claus Ibsen
>>>>>> Apache Camel Committer
>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21387318.html
>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>>
>>>> /Claus Ibsen
>>>> Apache Camel Committer
>>>> Blog: http://davsclaus.blogspot.com/
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21388391.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>> 
>> 
>> 
>> -- 
>> 
>> /Claus Ibsen
>> Apache Camel Committer
>> Blog: http://davsclaus.blogspot.com/
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21389401.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: How do i call an HTTP Provider end-pont from the process method?

Posted by Liav Ezer <li...@gmail.com>.
Hi Claus,

Well i'll stick with the Http SMX provider end-point. I guess it's should
integrate with camel routing with no problem.

Ok what i did is the advise you gave me a few answers ago:

ProducerTemplate producer = exchange.getContext().createProducerTemplate(); 
Object response =
producer.sendBody("http://localhost:8080/LiavHello/services/LiavHelloImpl",
"Daviv");

And got this exception (SMX console after deply):

: No endpoint could be found for:
http://localhost:8080/LiavHello/services/LiavHelloImpl
org.apache.camel.NoSuchEndpointException: No endpoint could be found for:
http://localhost:8080/LiavHello/services/LiavHelloImpl

LiavHelloImpl is the wsdlsoap:address location of the wsdl file representing
the LiavHelloImp web project (under a running tomcat 6.0).

Can you advise? It seems that the routing trying to be accomplished but
something "configi" is messed up.

Here is my provider xbean:

<http:endpoint service="wsn:LiavHelloImplService"
                 endpoint="wsn:LiavHelloImpl"
                 role="provider" 
                
locationURI="http://localhost:8080/LiavHello/services/LiavHelloImpl"
                 wsdlResource="c:/HTTPReceiverServices/LiavHelloImpl.wsdl"
                 defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
                 soap="true" /> 

Thanks!


Claus Ibsen-2 wrote:
> 
> On Sat, Jan 10, 2009 at 3:02 PM, Liav Ezer <li...@gmail.com> wrote:
>>
>> Hi Claus,
>>
>> I did follow this camel example & set up a timer 'from' end-point which
>> my
>> processor 'catched'.
>>
>> My will is to query this 'catched' data by sending it to a different
>> end-point such as a service provider.
>>
>> Therefore, i deployed two SU's in my servicemix: One for the camel
>> routing
>> (timer example) & two is for
>>
>> the HTTP servicemix provider which i want to invoke in the proceesor.
>>
>> My question seems simple as long as an API exists for it:
>>
>> When my Processor class is instansiated than the process() method is
>> invoked:
>>
>> public void process(Exchange exchange) throws Exception {
>>
>> The exchange.getIn() consist my 'from' end-point data (=the timer).
>>
>> I need the API to fetch the Http servicemix provider end-point & to send
>> hime a request with this data.
> If you want to send FROM Camel to SMX then you need to use the
> camel-jbi component. That is you get endpoints FROM Camel starting
> with the "jbi:" prefix. See camel-jbi component.
> 
> 
> 
>>
>> One extra small question: Do i need to replace my provider SU with a
>> camel
>> http producer SU?
> If you are using SMX 3.x then you dont as SMX has one SU for Camel.
> However if you need to use any of the other camel components from SMX
> you need to have them in the classpath as well, such as
> camel-http.jar.
> 
> 
> (In SMX 4.x its all OSGi land and you need to install features into SMX.)
> 
> A bit confused now. Which http provider do you want to use?
> - SMX Http provider
> - Camel http provider
> 
> 
>>
>> Thanks.
>>
>> Claus Ibsen-2 wrote:
>>>
>>> Hi
>>>
>>> Yeah its a bit mixed up since Camel and ServiceMix have classes with
>>> common name: Endpoint, Exchange etc.
>>>
>>> All the code I have shown assumes pure Camel code.
>>>
>>> I advice to check the ServceMix docu about using Camel in ServiceMix.
>>> And get a basic example running. Such as this example
>>> http://servicemix.apache.org/camel-example.html
>>>
>>> You could use that as a starting point to get Camel invoking your HTTP
>>> server. Just let the timer start it.
>>> Then later your can connect using SMX instead of the camel timer.
>>>
>>>
>>>
>>> On Sat, Jan 10, 2009 at 12:53 PM, Liav Ezer <li...@gmail.com> wrote:
>>>>
>>>> Hi Claus again,
>>>>
>>>> I addition to what i asked in my previouse response here is a question
>>>> regarding the producer snippet which you gave in your last answer:
>>>>
>>>> I indeed wrote the following in my process() method:
>>>>
>>>> ProducerTemplate producer =
>>>>
>>>> exchange.getCamelContext().createProducerTemplate();
>>>>                            Object response =
>>>>
>>>> producer.sendBody("http://myserver.com/myapp?foo=bar", "Liav Camel
>>>> POC");
>>>>
>>>> but i don't have the camel context at hand (saying "The method
>>>> getCamelContext() is undefined for the type Exchange").
>>>>  & also do i need to deploy a camel http producer su instead of an http
>>>> service mix provider?
>>>>
>>>> Claus Ibsen-2 wrote:
>>>>>
>>>>> Hi
>>>>>
>>>>> When you are working with ServiceMix you must use the JBI component in
>>>>> Camel
>>>>> http://activemq.apache.org/camel/jbi.html
>>>>>
>>>>> So your endpoints should starting with "jbi:XXXX"
>>>>>
>>>>> And ServiceMix has some Camel docu here:
>>>>> http://servicemix.apache.org/servicemix-camel.html
>>>>>
>>>>> Could you take a look at this docu a bit. There might be some help
>>>>> there.
>>>>>
>>>>> Try to get something more easier working with SMX and Camel and then
>>>>> later do the stuff you want with the dynamic add a camel context.
>>>>>
>>>>>
>>>>> On Sat, Jan 10, 2009 at 12:39 PM, Liav Ezer <li...@gmail.com>
>>>>> wrote:
>>>>>>
>>>>>> Hi Claus,
>>>>>>
>>>>>> I read your tutorial & learnt from it. Thanks. I adopted the cxf
>>>>>> framework
>>>>>> for now.
>>>>>>
>>>>>> Regarding my project (as stated above in snippets):
>>>>>>
>>>>>> I planted the following camel routing logic at my processor class:
>>>>>>
>>>>>> process method - with camel:
>>>>>>
>>>>>> public void process(Exchange exchange) throws Exception {
>>>>>>
>>>>>>  CamelContext camel = new DefaultCamelContext();
>>>>>>  camel.start();
>>>>>>
>>>>>>  Component component = (Component)
>>>>>> camel.getComponent("http-provider-su");
>>>>>>
>>>>>>  Endpoint endpoint = (Endpoint) ((org.apache.camel.Component)
>>>>>> component).createEndpoint("provider:com.amdocs.oxp.esb");
>>>>>>
>>>>>>  exchange.getIn().setBody("Liav testing here!");
>>>>>>
>>>>>>  Producer producer = ((org.apache.camel.Endpoint)
>>>>>> endpoint).createProducer();
>>>>>>
>>>>>>  producer.start();
>>>>>>  producer.process(exchange);
>>>>>>  producer.stop();
>>>>>>
>>>>>>  //System.out.println(exchange.getIn().toString() + "process
>>>>>> activated
>>>>>> by
>>>>>> SU");
>>>>>> }
>>>>>>
>>>>>> And got the following exception while SA's jar was deployed:
>>>>>>
>>>>>> ERROR - DeadLetterChannel              - Failed delivery for
>>>>>> exchangeId:
>>>>>> ID-LIAVE02/1885-1231586726193/0-0. On delivery attemp
>>>>>> java.lang.NullPointerException
>>>>>>        at
>>>>>> org.apache.servicemix.tutorial.camel.MyProcessor.process(MyProcessor.java:33)
>>>>>> at
>>>>>> org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:92)
>>>>>>        at
>>>>>> org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:66)
>>>>>>        at
>>>>>> org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorT
>>>>>>        at
>>>>>> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:75)
>>>>>>        at
>>>>>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:146)
>>>>>>        at
>>>>>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:90)
>>>>>>        at
>>>>>> org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
>>>>>>        at
>>>>>> org.apache.camel.processor.Pipeline.process(Pipeline.java:85)
>>>>>>        at
>>>>>> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:39)
>>>>>>        at
>>>>>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
>>>>>>        at
>>>>>> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
>>>>>>        at
>>>>>> org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:91)
>>>>>>        at
>>>>>> org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:48)
>>>>>>        at java.util.TimerThread.mainLoop(Timer.java:512)
>>>>>>        at java.util.TimerThread.run(Timer.java:462)
>>>>>>
>>>>>> Be advise that line 33 is:Endpoint endpoint = (Endpoint)
>>>>>> ((org.apache.camel.Component)
>>>>>> component).createEndpoint("provider:com.amdocs.oxp.esb");
>>>>>>
>>>>>> My questions:
>>>>>>
>>>>>> 1. As bolded above i "fetched" my provider su component by staing
>>>>>> it's
>>>>>> name
>>>>>> - is it correct?
>>>>>>
>>>>>> 2. I used the following servicemix object (not camel's) since i work
>>>>>> with
>>>>>> servicemix provider endpoint. That's the reason for all the casting
>>>>>> in
>>>>>> my
>>>>>> code:
>>>>>> import org.apache.servicemix.jbi.deployment.Component;
>>>>>> import org.apache.servicemix.jbi.framework.Endpoint;
>>>>>>
>>>>>> Is it correct?
>>>>>>
>>>>>> Thank again,
>>>>>> Liav Ezer.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> Claus Ibsen-2 wrote:
>>>>>>>
>>>>>>> Hi
>>>>>>>
>>>>>>> You can use the producer template to call an external http server
>>>>>>> and
>>>>>>> get the response.
>>>>>>>
>>>>>>> See this tutorial:
>>>>>>> http://activemq.apache.org/camel/tutorial-axis-camel.html
>>>>>>>
>>>>>>> From the section - integrating Camel
>>>>>>>
>>>>>>> Its kinda the same but its just uses the producer template to save a
>>>>>>> file. Its the same API for using any of the camel components.
>>>>>>>
>>>>>>> Little sidenote:
>>>>>>> And since you use InOut you should use: requestBody instread of
>>>>>>> sendBody. However Camel is not to stricky about this yet so if you
>>>>>>> use
>>>>>>> a send instead of request then it should work as well.
>>>>>>>
>>>>>>> The demo shows how to inject a producer template from spring into
>>>>>>> your
>>>>>>> bean class = your processor. when you have this template you can
>>>>>>> call
>>>>>>> the external http server and get the response using the requestBody
>>>>>>> method.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Thu, Jan 8, 2009 at 1:46 PM, Liav Ezer <li...@gmail.com>
>>>>>>> wrote:
>>>>>>>>
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> Here is my camel-context:
>>>>>>>>
>>>>>>>>  <camelContext id="camel"
>>>>>>>> xmlns="http://activemq.apache.org/camel/schema/spring">
>>>>>>>>    <package>org.apache.servicemix.tutorial.camel</package>
>>>>>>>>  </camelContext>
>>>>>>>>
>>>>>>>>  <bean id="myProcessor"
>>>>>>>> class="org.apache.servicemix.tutorial.camel.MyProcessor"/>
>>>>>>>>
>>>>>>>> Here is my RouteBuilder java file:
>>>>>>>>
>>>>>>>> public class MyRouteBuilder extends RouteBuilder {
>>>>>>>>        public void configure() {
>>>>>>>>
>>>>>>>> from("timer://tutorial?fixedRate=true&delay=3000&period=10000")
>>>>>>>>                .setBody(constant(".....................Liav Camel
>>>>>>>> POC......................."))
>>>>>>>>                        .to("myProcessor");
>>>>>>>>
>>>>>>>>    }
>>>>>>>> }
>>>>>>>>
>>>>>>>> Here is my processor java file:
>>>>>>>> public class MyProcessor implements Processor {
>>>>>>>>          public void process(Exchange exchange) throws Exception {
>>>>>>>>              //WANT TO INITIATE A CALL TO http pROVIDER END POINT &
>>>>>>>> PASS
>>>>>>>> THE
>>>>>>>> 'FROM'
>>>>>>>>                  // PARAMETRS RECIEVED PROIRE TO THE PROCESSOR
>>>>>>>> INVOKE.
>>>>>>>> }
>>>>>>>> }
>>>>>>>>
>>>>>>>> Thanks.
>>>>>>>> --
>>>>>>>> View this message in context:
>>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21351142.html
>>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>>
>>>>>>> /Claus Ibsen
>>>>>>> Apache Camel Committer
>>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> --
>>>>>> View this message in context:
>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21387207.html
>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>>
>>>>> /Claus Ibsen
>>>>> Apache Camel Committer
>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>
>>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21387318.html
>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>>
>>> /Claus Ibsen
>>> Apache Camel Committer
>>> Blog: http://davsclaus.blogspot.com/
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21388391.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> 
> /Claus Ibsen
> Apache Camel Committer
> Blog: http://davsclaus.blogspot.com/
> 
> 

-- 
View this message in context: http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21389069.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: How do i call an HTTP Provider end-pont from the process method?

Posted by Claus Ibsen <cl...@gmail.com>.
On Sat, Jan 10, 2009 at 3:02 PM, Liav Ezer <li...@gmail.com> wrote:
>
> Hi Claus,
>
> I did follow this camel example & set up a timer 'from' end-point which my
> processor 'catched'.
>
> My will is to query this 'catched' data by sending it to a different
> end-point such as a service provider.
>
> Therefore, i deployed two SU's in my servicemix: One for the camel routing
> (timer example) & two is for
>
> the HTTP servicemix provider which i want to invoke in the proceesor.
>
> My question seems simple as long as an API exists for it:
>
> When my Processor class is instansiated than the process() method is
> invoked:
>
> public void process(Exchange exchange) throws Exception {
>
> The exchange.getIn() consist my 'from' end-point data (=the timer).
>
> I need the API to fetch the Http servicemix provider end-point & to send
> hime a request with this data.
If you want to send FROM Camel to SMX then you need to use the
camel-jbi component. That is you get endpoints FROM Camel starting
with the "jbi:" prefix. See camel-jbi component.



>
> One extra small question: Do i need to replace my provider SU with a camel
> http producer SU?
If you are using SMX 3.x then you dont as SMX has one SU for Camel.
However if you need to use any of the other camel components from SMX
you need to have them in the classpath as well, such as
camel-http.jar.


(In SMX 4.x its all OSGi land and you need to install features into SMX.)

A bit confused now. Which http provider do you want to use?
- SMX Http provider
- Camel http provider


>
> Thanks.
>
> Claus Ibsen-2 wrote:
>>
>> Hi
>>
>> Yeah its a bit mixed up since Camel and ServiceMix have classes with
>> common name: Endpoint, Exchange etc.
>>
>> All the code I have shown assumes pure Camel code.
>>
>> I advice to check the ServceMix docu about using Camel in ServiceMix.
>> And get a basic example running. Such as this example
>> http://servicemix.apache.org/camel-example.html
>>
>> You could use that as a starting point to get Camel invoking your HTTP
>> server. Just let the timer start it.
>> Then later your can connect using SMX instead of the camel timer.
>>
>>
>>
>> On Sat, Jan 10, 2009 at 12:53 PM, Liav Ezer <li...@gmail.com> wrote:
>>>
>>> Hi Claus again,
>>>
>>> I addition to what i asked in my previouse response here is a question
>>> regarding the producer snippet which you gave in your last answer:
>>>
>>> I indeed wrote the following in my process() method:
>>>
>>> ProducerTemplate producer =
>>>
>>> exchange.getCamelContext().createProducerTemplate();
>>>                            Object response =
>>>
>>> producer.sendBody("http://myserver.com/myapp?foo=bar", "Liav Camel
>>> POC");
>>>
>>> but i don't have the camel context at hand (saying "The method
>>> getCamelContext() is undefined for the type Exchange").
>>>  & also do i need to deploy a camel http producer su instead of an http
>>> service mix provider?
>>>
>>> Claus Ibsen-2 wrote:
>>>>
>>>> Hi
>>>>
>>>> When you are working with ServiceMix you must use the JBI component in
>>>> Camel
>>>> http://activemq.apache.org/camel/jbi.html
>>>>
>>>> So your endpoints should starting with "jbi:XXXX"
>>>>
>>>> And ServiceMix has some Camel docu here:
>>>> http://servicemix.apache.org/servicemix-camel.html
>>>>
>>>> Could you take a look at this docu a bit. There might be some help
>>>> there.
>>>>
>>>> Try to get something more easier working with SMX and Camel and then
>>>> later do the stuff you want with the dynamic add a camel context.
>>>>
>>>>
>>>> On Sat, Jan 10, 2009 at 12:39 PM, Liav Ezer <li...@gmail.com> wrote:
>>>>>
>>>>> Hi Claus,
>>>>>
>>>>> I read your tutorial & learnt from it. Thanks. I adopted the cxf
>>>>> framework
>>>>> for now.
>>>>>
>>>>> Regarding my project (as stated above in snippets):
>>>>>
>>>>> I planted the following camel routing logic at my processor class:
>>>>>
>>>>> process method - with camel:
>>>>>
>>>>> public void process(Exchange exchange) throws Exception {
>>>>>
>>>>>  CamelContext camel = new DefaultCamelContext();
>>>>>  camel.start();
>>>>>
>>>>>  Component component = (Component)
>>>>> camel.getComponent("http-provider-su");
>>>>>
>>>>>  Endpoint endpoint = (Endpoint) ((org.apache.camel.Component)
>>>>> component).createEndpoint("provider:com.amdocs.oxp.esb");
>>>>>
>>>>>  exchange.getIn().setBody("Liav testing here!");
>>>>>
>>>>>  Producer producer = ((org.apache.camel.Endpoint)
>>>>> endpoint).createProducer();
>>>>>
>>>>>  producer.start();
>>>>>  producer.process(exchange);
>>>>>  producer.stop();
>>>>>
>>>>>  //System.out.println(exchange.getIn().toString() + "process activated
>>>>> by
>>>>> SU");
>>>>> }
>>>>>
>>>>> And got the following exception while SA's jar was deployed:
>>>>>
>>>>> ERROR - DeadLetterChannel              - Failed delivery for
>>>>> exchangeId:
>>>>> ID-LIAVE02/1885-1231586726193/0-0. On delivery attemp
>>>>> java.lang.NullPointerException
>>>>>        at
>>>>> org.apache.servicemix.tutorial.camel.MyProcessor.process(MyProcessor.java:33)
>>>>> at
>>>>> org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:92)
>>>>>        at
>>>>> org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:66)
>>>>>        at
>>>>> org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorT
>>>>>        at
>>>>> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:75)
>>>>>        at
>>>>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:146)
>>>>>        at
>>>>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:90)
>>>>>        at
>>>>> org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
>>>>>        at org.apache.camel.processor.Pipeline.process(Pipeline.java:85)
>>>>>        at
>>>>> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:39)
>>>>>        at
>>>>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
>>>>>        at
>>>>> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
>>>>>        at
>>>>> org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:91)
>>>>>        at
>>>>> org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:48)
>>>>>        at java.util.TimerThread.mainLoop(Timer.java:512)
>>>>>        at java.util.TimerThread.run(Timer.java:462)
>>>>>
>>>>> Be advise that line 33 is:Endpoint endpoint = (Endpoint)
>>>>> ((org.apache.camel.Component)
>>>>> component).createEndpoint("provider:com.amdocs.oxp.esb");
>>>>>
>>>>> My questions:
>>>>>
>>>>> 1. As bolded above i "fetched" my provider su component by staing it's
>>>>> name
>>>>> - is it correct?
>>>>>
>>>>> 2. I used the following servicemix object (not camel's) since i work
>>>>> with
>>>>> servicemix provider endpoint. That's the reason for all the casting in
>>>>> my
>>>>> code:
>>>>> import org.apache.servicemix.jbi.deployment.Component;
>>>>> import org.apache.servicemix.jbi.framework.Endpoint;
>>>>>
>>>>> Is it correct?
>>>>>
>>>>> Thank again,
>>>>> Liav Ezer.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Claus Ibsen-2 wrote:
>>>>>>
>>>>>> Hi
>>>>>>
>>>>>> You can use the producer template to call an external http server and
>>>>>> get the response.
>>>>>>
>>>>>> See this tutorial:
>>>>>> http://activemq.apache.org/camel/tutorial-axis-camel.html
>>>>>>
>>>>>> From the section - integrating Camel
>>>>>>
>>>>>> Its kinda the same but its just uses the producer template to save a
>>>>>> file. Its the same API for using any of the camel components.
>>>>>>
>>>>>> Little sidenote:
>>>>>> And since you use InOut you should use: requestBody instread of
>>>>>> sendBody. However Camel is not to stricky about this yet so if you use
>>>>>> a send instead of request then it should work as well.
>>>>>>
>>>>>> The demo shows how to inject a producer template from spring into your
>>>>>> bean class = your processor. when you have this template you can call
>>>>>> the external http server and get the response using the requestBody
>>>>>> method.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Thu, Jan 8, 2009 at 1:46 PM, Liav Ezer <li...@gmail.com> wrote:
>>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> Here is my camel-context:
>>>>>>>
>>>>>>>  <camelContext id="camel"
>>>>>>> xmlns="http://activemq.apache.org/camel/schema/spring">
>>>>>>>    <package>org.apache.servicemix.tutorial.camel</package>
>>>>>>>  </camelContext>
>>>>>>>
>>>>>>>  <bean id="myProcessor"
>>>>>>> class="org.apache.servicemix.tutorial.camel.MyProcessor"/>
>>>>>>>
>>>>>>> Here is my RouteBuilder java file:
>>>>>>>
>>>>>>> public class MyRouteBuilder extends RouteBuilder {
>>>>>>>        public void configure() {
>>>>>>>
>>>>>>> from("timer://tutorial?fixedRate=true&delay=3000&period=10000")
>>>>>>>                .setBody(constant(".....................Liav Camel
>>>>>>> POC......................."))
>>>>>>>                        .to("myProcessor");
>>>>>>>
>>>>>>>    }
>>>>>>> }
>>>>>>>
>>>>>>> Here is my processor java file:
>>>>>>> public class MyProcessor implements Processor {
>>>>>>>          public void process(Exchange exchange) throws Exception {
>>>>>>>              //WANT TO INITIATE A CALL TO http pROVIDER END POINT &
>>>>>>> PASS
>>>>>>> THE
>>>>>>> 'FROM'
>>>>>>>                  // PARAMETRS RECIEVED PROIRE TO THE PROCESSOR
>>>>>>> INVOKE.
>>>>>>> }
>>>>>>> }
>>>>>>>
>>>>>>> Thanks.
>>>>>>> --
>>>>>>> View this message in context:
>>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21351142.html
>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>>
>>>>>> /Claus Ibsen
>>>>>> Apache Camel Committer
>>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21387207.html
>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>>
>>>> /Claus Ibsen
>>>> Apache Camel Committer
>>>> Blog: http://davsclaus.blogspot.com/
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21387318.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>>
>> /Claus Ibsen
>> Apache Camel Committer
>> Blog: http://davsclaus.blogspot.com/
>>
>>
>
> --
> View this message in context: http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21388391.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 

/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/

Re: How do i call an HTTP Provider end-pont from the process method?

Posted by Liav Ezer <li...@gmail.com>.
Hi Claus,

I did follow this camel example & set up a timer 'from' end-point which my
processor 'catched'.

My will is to query this 'catched' data by sending it to a different
end-point such as a service provider.

Therefore, i deployed two SU's in my servicemix: One for the camel routing
(timer example) & two is for 

the HTTP servicemix provider which i want to invoke in the proceesor.

My question seems simple as long as an API exists for it:

When my Processor class is instansiated than the process() method is
invoked:

public void process(Exchange exchange) throws Exception {

The exchange.getIn() consist my 'from' end-point data (=the timer).

I need the API to fetch the Http servicemix provider end-point & to send
hime a request with this data.

One extra small question: Do i need to replace my provider SU with a camel
http producer SU?

Thanks.

Claus Ibsen-2 wrote:
> 
> Hi
> 
> Yeah its a bit mixed up since Camel and ServiceMix have classes with
> common name: Endpoint, Exchange etc.
> 
> All the code I have shown assumes pure Camel code.
> 
> I advice to check the ServceMix docu about using Camel in ServiceMix.
> And get a basic example running. Such as this example
> http://servicemix.apache.org/camel-example.html
> 
> You could use that as a starting point to get Camel invoking your HTTP
> server. Just let the timer start it.
> Then later your can connect using SMX instead of the camel timer.
> 
> 
> 
> On Sat, Jan 10, 2009 at 12:53 PM, Liav Ezer <li...@gmail.com> wrote:
>>
>> Hi Claus again,
>>
>> I addition to what i asked in my previouse response here is a question
>> regarding the producer snippet which you gave in your last answer:
>>
>> I indeed wrote the following in my process() method:
>>
>> ProducerTemplate producer =
>>                         
>> exchange.getCamelContext().createProducerTemplate();
>>                            Object response =
>>                         
>> producer.sendBody("http://myserver.com/myapp?foo=bar", "Liav Camel
>> POC");
>>
>> but i don't have the camel context at hand (saying "The method
>> getCamelContext() is undefined for the type Exchange").
>>  & also do i need to deploy a camel http producer su instead of an http
>> service mix provider?
>>
>> Claus Ibsen-2 wrote:
>>>
>>> Hi
>>>
>>> When you are working with ServiceMix you must use the JBI component in
>>> Camel
>>> http://activemq.apache.org/camel/jbi.html
>>>
>>> So your endpoints should starting with "jbi:XXXX"
>>>
>>> And ServiceMix has some Camel docu here:
>>> http://servicemix.apache.org/servicemix-camel.html
>>>
>>> Could you take a look at this docu a bit. There might be some help
>>> there.
>>>
>>> Try to get something more easier working with SMX and Camel and then
>>> later do the stuff you want with the dynamic add a camel context.
>>>
>>>
>>> On Sat, Jan 10, 2009 at 12:39 PM, Liav Ezer <li...@gmail.com> wrote:
>>>>
>>>> Hi Claus,
>>>>
>>>> I read your tutorial & learnt from it. Thanks. I adopted the cxf
>>>> framework
>>>> for now.
>>>>
>>>> Regarding my project (as stated above in snippets):
>>>>
>>>> I planted the following camel routing logic at my processor class:
>>>>
>>>> process method - with camel:
>>>>
>>>> public void process(Exchange exchange) throws Exception {
>>>>
>>>>  CamelContext camel = new DefaultCamelContext();
>>>>  camel.start();
>>>>
>>>>  Component component = (Component)
>>>> camel.getComponent("http-provider-su");
>>>>
>>>>  Endpoint endpoint = (Endpoint) ((org.apache.camel.Component)
>>>> component).createEndpoint("provider:com.amdocs.oxp.esb");
>>>>
>>>>  exchange.getIn().setBody("Liav testing here!");
>>>>
>>>>  Producer producer = ((org.apache.camel.Endpoint)
>>>> endpoint).createProducer();
>>>>
>>>>  producer.start();
>>>>  producer.process(exchange);
>>>>  producer.stop();
>>>>
>>>>  //System.out.println(exchange.getIn().toString() + "process activated
>>>> by
>>>> SU");
>>>> }
>>>>
>>>> And got the following exception while SA's jar was deployed:
>>>>
>>>> ERROR - DeadLetterChannel              - Failed delivery for
>>>> exchangeId:
>>>> ID-LIAVE02/1885-1231586726193/0-0. On delivery attemp
>>>> java.lang.NullPointerException
>>>>        at
>>>> org.apache.servicemix.tutorial.camel.MyProcessor.process(MyProcessor.java:33)
>>>> at
>>>> org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:92)
>>>>        at
>>>> org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:66)
>>>>        at
>>>> org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorT
>>>>        at
>>>> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:75)
>>>>        at
>>>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:146)
>>>>        at
>>>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:90)
>>>>        at
>>>> org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
>>>>        at org.apache.camel.processor.Pipeline.process(Pipeline.java:85)
>>>>        at
>>>> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:39)
>>>>        at
>>>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
>>>>        at
>>>> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
>>>>        at
>>>> org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:91)
>>>>        at
>>>> org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:48)
>>>>        at java.util.TimerThread.mainLoop(Timer.java:512)
>>>>        at java.util.TimerThread.run(Timer.java:462)
>>>>
>>>> Be advise that line 33 is:Endpoint endpoint = (Endpoint)
>>>> ((org.apache.camel.Component)
>>>> component).createEndpoint("provider:com.amdocs.oxp.esb");
>>>>
>>>> My questions:
>>>>
>>>> 1. As bolded above i "fetched" my provider su component by staing it's
>>>> name
>>>> - is it correct?
>>>>
>>>> 2. I used the following servicemix object (not camel's) since i work
>>>> with
>>>> servicemix provider endpoint. That's the reason for all the casting in
>>>> my
>>>> code:
>>>> import org.apache.servicemix.jbi.deployment.Component;
>>>> import org.apache.servicemix.jbi.framework.Endpoint;
>>>>
>>>> Is it correct?
>>>>
>>>> Thank again,
>>>> Liav Ezer.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Claus Ibsen-2 wrote:
>>>>>
>>>>> Hi
>>>>>
>>>>> You can use the producer template to call an external http server and
>>>>> get the response.
>>>>>
>>>>> See this tutorial:
>>>>> http://activemq.apache.org/camel/tutorial-axis-camel.html
>>>>>
>>>>> From the section - integrating Camel
>>>>>
>>>>> Its kinda the same but its just uses the producer template to save a
>>>>> file. Its the same API for using any of the camel components.
>>>>>
>>>>> Little sidenote:
>>>>> And since you use InOut you should use: requestBody instread of
>>>>> sendBody. However Camel is not to stricky about this yet so if you use
>>>>> a send instead of request then it should work as well.
>>>>>
>>>>> The demo shows how to inject a producer template from spring into your
>>>>> bean class = your processor. when you have this template you can call
>>>>> the external http server and get the response using the requestBody
>>>>> method.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Thu, Jan 8, 2009 at 1:46 PM, Liav Ezer <li...@gmail.com> wrote:
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> Here is my camel-context:
>>>>>>
>>>>>>  <camelContext id="camel"
>>>>>> xmlns="http://activemq.apache.org/camel/schema/spring">
>>>>>>    <package>org.apache.servicemix.tutorial.camel</package>
>>>>>>  </camelContext>
>>>>>>
>>>>>>  <bean id="myProcessor"
>>>>>> class="org.apache.servicemix.tutorial.camel.MyProcessor"/>
>>>>>>
>>>>>> Here is my RouteBuilder java file:
>>>>>>
>>>>>> public class MyRouteBuilder extends RouteBuilder {
>>>>>>        public void configure() {
>>>>>>       
>>>>>> from("timer://tutorial?fixedRate=true&delay=3000&period=10000")
>>>>>>                .setBody(constant(".....................Liav Camel
>>>>>> POC......................."))
>>>>>>                        .to("myProcessor");
>>>>>>
>>>>>>    }
>>>>>> }
>>>>>>
>>>>>> Here is my processor java file:
>>>>>> public class MyProcessor implements Processor {
>>>>>>          public void process(Exchange exchange) throws Exception {
>>>>>>              //WANT TO INITIATE A CALL TO http pROVIDER END POINT &
>>>>>> PASS
>>>>>> THE
>>>>>> 'FROM'
>>>>>>                  // PARAMETRS RECIEVED PROIRE TO THE PROCESSOR
>>>>>> INVOKE.
>>>>>> }
>>>>>> }
>>>>>>
>>>>>> Thanks.
>>>>>> --
>>>>>> View this message in context:
>>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21351142.html
>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>>
>>>>> /Claus Ibsen
>>>>> Apache Camel Committer
>>>>> Blog: http://davsclaus.blogspot.com/
>>>>>
>>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21387207.html
>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>>
>>> /Claus Ibsen
>>> Apache Camel Committer
>>> Blog: http://davsclaus.blogspot.com/
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21387318.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> 
> /Claus Ibsen
> Apache Camel Committer
> Blog: http://davsclaus.blogspot.com/
> 
> 

-- 
View this message in context: http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21388391.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: How do i call an HTTP Provider end-pont from the process method?

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Yeah its a bit mixed up since Camel and ServiceMix have classes with
common name: Endpoint, Exchange etc.

All the code I have shown assumes pure Camel code.

I advice to check the ServceMix docu about using Camel in ServiceMix.
And get a basic example running. Such as this example
http://servicemix.apache.org/camel-example.html

You could use that as a starting point to get Camel invoking your HTTP
server. Just let the timer start it.
Then later your can connect using SMX instead of the camel timer.



On Sat, Jan 10, 2009 at 12:53 PM, Liav Ezer <li...@gmail.com> wrote:
>
> Hi Claus again,
>
> I addition to what i asked in my previouse response here is a question
> regarding the producer snippet which you gave in your last answer:
>
> I indeed wrote the following in my process() method:
>
> ProducerTemplate producer =
>                          exchange.getCamelContext().createProducerTemplate();
>                            Object response =
>                          producer.sendBody("http://myserver.com/myapp?foo=bar", "Liav Camel
> POC");
>
> but i don't have the camel context at hand (saying "The method
> getCamelContext() is undefined for the type Exchange").
>  & also do i need to deploy a camel http producer su instead of an http
> service mix provider?
>
> Claus Ibsen-2 wrote:
>>
>> Hi
>>
>> When you are working with ServiceMix you must use the JBI component in
>> Camel
>> http://activemq.apache.org/camel/jbi.html
>>
>> So your endpoints should starting with "jbi:XXXX"
>>
>> And ServiceMix has some Camel docu here:
>> http://servicemix.apache.org/servicemix-camel.html
>>
>> Could you take a look at this docu a bit. There might be some help there.
>>
>> Try to get something more easier working with SMX and Camel and then
>> later do the stuff you want with the dynamic add a camel context.
>>
>>
>> On Sat, Jan 10, 2009 at 12:39 PM, Liav Ezer <li...@gmail.com> wrote:
>>>
>>> Hi Claus,
>>>
>>> I read your tutorial & learnt from it. Thanks. I adopted the cxf
>>> framework
>>> for now.
>>>
>>> Regarding my project (as stated above in snippets):
>>>
>>> I planted the following camel routing logic at my processor class:
>>>
>>> process method - with camel:
>>>
>>> public void process(Exchange exchange) throws Exception {
>>>
>>>  CamelContext camel = new DefaultCamelContext();
>>>  camel.start();
>>>
>>>  Component component = (Component)
>>> camel.getComponent("http-provider-su");
>>>
>>>  Endpoint endpoint = (Endpoint) ((org.apache.camel.Component)
>>> component).createEndpoint("provider:com.amdocs.oxp.esb");
>>>
>>>  exchange.getIn().setBody("Liav testing here!");
>>>
>>>  Producer producer = ((org.apache.camel.Endpoint)
>>> endpoint).createProducer();
>>>
>>>  producer.start();
>>>  producer.process(exchange);
>>>  producer.stop();
>>>
>>>  //System.out.println(exchange.getIn().toString() + "process activated by
>>> SU");
>>> }
>>>
>>> And got the following exception while SA's jar was deployed:
>>>
>>> ERROR - DeadLetterChannel              - Failed delivery for exchangeId:
>>> ID-LIAVE02/1885-1231586726193/0-0. On delivery attemp
>>> java.lang.NullPointerException
>>>        at
>>> org.apache.servicemix.tutorial.camel.MyProcessor.process(MyProcessor.java:33)
>>> at
>>> org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:92)
>>>        at
>>> org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:66)
>>>        at
>>> org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorT
>>>        at
>>> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:75)
>>>        at
>>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:146)
>>>        at
>>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:90)
>>>        at org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
>>>        at org.apache.camel.processor.Pipeline.process(Pipeline.java:85)
>>>        at
>>> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:39)
>>>        at
>>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
>>>        at
>>> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
>>>        at
>>> org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:91)
>>>        at
>>> org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:48)
>>>        at java.util.TimerThread.mainLoop(Timer.java:512)
>>>        at java.util.TimerThread.run(Timer.java:462)
>>>
>>> Be advise that line 33 is:Endpoint endpoint = (Endpoint)
>>> ((org.apache.camel.Component)
>>> component).createEndpoint("provider:com.amdocs.oxp.esb");
>>>
>>> My questions:
>>>
>>> 1. As bolded above i "fetched" my provider su component by staing it's
>>> name
>>> - is it correct?
>>>
>>> 2. I used the following servicemix object (not camel's) since i work with
>>> servicemix provider endpoint. That's the reason for all the casting in my
>>> code:
>>> import org.apache.servicemix.jbi.deployment.Component;
>>> import org.apache.servicemix.jbi.framework.Endpoint;
>>>
>>> Is it correct?
>>>
>>> Thank again,
>>> Liav Ezer.
>>>
>>>
>>>
>>>
>>>
>>> Claus Ibsen-2 wrote:
>>>>
>>>> Hi
>>>>
>>>> You can use the producer template to call an external http server and
>>>> get the response.
>>>>
>>>> See this tutorial:
>>>> http://activemq.apache.org/camel/tutorial-axis-camel.html
>>>>
>>>> From the section - integrating Camel
>>>>
>>>> Its kinda the same but its just uses the producer template to save a
>>>> file. Its the same API for using any of the camel components.
>>>>
>>>> Little sidenote:
>>>> And since you use InOut you should use: requestBody instread of
>>>> sendBody. However Camel is not to stricky about this yet so if you use
>>>> a send instead of request then it should work as well.
>>>>
>>>> The demo shows how to inject a producer template from spring into your
>>>> bean class = your processor. when you have this template you can call
>>>> the external http server and get the response using the requestBody
>>>> method.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> On Thu, Jan 8, 2009 at 1:46 PM, Liav Ezer <li...@gmail.com> wrote:
>>>>>
>>>>> Hi,
>>>>>
>>>>> Here is my camel-context:
>>>>>
>>>>>  <camelContext id="camel"
>>>>> xmlns="http://activemq.apache.org/camel/schema/spring">
>>>>>    <package>org.apache.servicemix.tutorial.camel</package>
>>>>>  </camelContext>
>>>>>
>>>>>  <bean id="myProcessor"
>>>>> class="org.apache.servicemix.tutorial.camel.MyProcessor"/>
>>>>>
>>>>> Here is my RouteBuilder java file:
>>>>>
>>>>> public class MyRouteBuilder extends RouteBuilder {
>>>>>        public void configure() {
>>>>>        from("timer://tutorial?fixedRate=true&delay=3000&period=10000")
>>>>>                .setBody(constant(".....................Liav Camel
>>>>> POC......................."))
>>>>>                        .to("myProcessor");
>>>>>
>>>>>    }
>>>>> }
>>>>>
>>>>> Here is my processor java file:
>>>>> public class MyProcessor implements Processor {
>>>>>          public void process(Exchange exchange) throws Exception {
>>>>>              //WANT TO INITIATE A CALL TO http pROVIDER END POINT &
>>>>> PASS
>>>>> THE
>>>>> 'FROM'
>>>>>                  // PARAMETRS RECIEVED PROIRE TO THE PROCESSOR INVOKE.
>>>>> }
>>>>> }
>>>>>
>>>>> Thanks.
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21351142.html
>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>>
>>>> /Claus Ibsen
>>>> Apache Camel Committer
>>>> Blog: http://davsclaus.blogspot.com/
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21387207.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>>
>> /Claus Ibsen
>> Apache Camel Committer
>> Blog: http://davsclaus.blogspot.com/
>>
>>
>
> --
> View this message in context: http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21387318.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 

/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/

Re: How do i call an HTTP Provider end-pont from the process method?

Posted by Liav Ezer <li...@gmail.com>.
Hi Claus again,

I addition to what i asked in my previouse response here is a question
regarding the producer snippet which you gave in your last answer:

I indeed wrote the following in my process() method:

ProducerTemplate producer = 
			  exchange.getCamelContext().createProducerTemplate(); 
			    Object response = 
			  producer.sendBody("http://myserver.com/myapp?foo=bar", "Liav Camel
POC"); 

but i don't have the camel context at hand (saying "The method
getCamelContext() is undefined for the type Exchange").
 & also do i need to deploy a camel http producer su instead of an http
service mix provider?

Claus Ibsen-2 wrote:
> 
> Hi
> 
> When you are working with ServiceMix you must use the JBI component in
> Camel
> http://activemq.apache.org/camel/jbi.html
> 
> So your endpoints should starting with "jbi:XXXX"
> 
> And ServiceMix has some Camel docu here:
> http://servicemix.apache.org/servicemix-camel.html
> 
> Could you take a look at this docu a bit. There might be some help there.
> 
> Try to get something more easier working with SMX and Camel and then
> later do the stuff you want with the dynamic add a camel context.
> 
> 
> On Sat, Jan 10, 2009 at 12:39 PM, Liav Ezer <li...@gmail.com> wrote:
>>
>> Hi Claus,
>>
>> I read your tutorial & learnt from it. Thanks. I adopted the cxf
>> framework
>> for now.
>>
>> Regarding my project (as stated above in snippets):
>>
>> I planted the following camel routing logic at my processor class:
>>
>> process method - with camel:
>>
>> public void process(Exchange exchange) throws Exception {
>>
>>  CamelContext camel = new DefaultCamelContext();
>>  camel.start();
>>
>>  Component component = (Component)
>> camel.getComponent("http-provider-su");
>>
>>  Endpoint endpoint = (Endpoint) ((org.apache.camel.Component)
>> component).createEndpoint("provider:com.amdocs.oxp.esb");
>>
>>  exchange.getIn().setBody("Liav testing here!");
>>
>>  Producer producer = ((org.apache.camel.Endpoint)
>> endpoint).createProducer();
>>
>>  producer.start();
>>  producer.process(exchange);
>>  producer.stop();
>>
>>  //System.out.println(exchange.getIn().toString() + "process activated by
>> SU");
>> }
>>
>> And got the following exception while SA's jar was deployed:
>>
>> ERROR - DeadLetterChannel              - Failed delivery for exchangeId:
>> ID-LIAVE02/1885-1231586726193/0-0. On delivery attemp
>> java.lang.NullPointerException
>>        at
>> org.apache.servicemix.tutorial.camel.MyProcessor.process(MyProcessor.java:33)
>> at
>> org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:92)
>>        at
>> org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:66)
>>        at
>> org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorT
>>        at
>> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:75)
>>        at
>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:146)
>>        at
>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:90)
>>        at org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
>>        at org.apache.camel.processor.Pipeline.process(Pipeline.java:85)
>>        at
>> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:39)
>>        at
>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
>>        at
>> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
>>        at
>> org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:91)
>>        at
>> org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:48)
>>        at java.util.TimerThread.mainLoop(Timer.java:512)
>>        at java.util.TimerThread.run(Timer.java:462)
>>
>> Be advise that line 33 is:Endpoint endpoint = (Endpoint)
>> ((org.apache.camel.Component)
>> component).createEndpoint("provider:com.amdocs.oxp.esb");
>>
>> My questions:
>>
>> 1. As bolded above i "fetched" my provider su component by staing it's
>> name
>> - is it correct?
>>
>> 2. I used the following servicemix object (not camel's) since i work with
>> servicemix provider endpoint. That's the reason for all the casting in my
>> code:
>> import org.apache.servicemix.jbi.deployment.Component;
>> import org.apache.servicemix.jbi.framework.Endpoint;
>>
>> Is it correct?
>>
>> Thank again,
>> Liav Ezer.
>>
>>
>>
>>
>>
>> Claus Ibsen-2 wrote:
>>>
>>> Hi
>>>
>>> You can use the producer template to call an external http server and
>>> get the response.
>>>
>>> See this tutorial:
>>> http://activemq.apache.org/camel/tutorial-axis-camel.html
>>>
>>> From the section - integrating Camel
>>>
>>> Its kinda the same but its just uses the producer template to save a
>>> file. Its the same API for using any of the camel components.
>>>
>>> Little sidenote:
>>> And since you use InOut you should use: requestBody instread of
>>> sendBody. However Camel is not to stricky about this yet so if you use
>>> a send instead of request then it should work as well.
>>>
>>> The demo shows how to inject a producer template from spring into your
>>> bean class = your processor. when you have this template you can call
>>> the external http server and get the response using the requestBody
>>> method.
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> On Thu, Jan 8, 2009 at 1:46 PM, Liav Ezer <li...@gmail.com> wrote:
>>>>
>>>> Hi,
>>>>
>>>> Here is my camel-context:
>>>>
>>>>  <camelContext id="camel"
>>>> xmlns="http://activemq.apache.org/camel/schema/spring">
>>>>    <package>org.apache.servicemix.tutorial.camel</package>
>>>>  </camelContext>
>>>>
>>>>  <bean id="myProcessor"
>>>> class="org.apache.servicemix.tutorial.camel.MyProcessor"/>
>>>>
>>>> Here is my RouteBuilder java file:
>>>>
>>>> public class MyRouteBuilder extends RouteBuilder {
>>>>        public void configure() {
>>>>        from("timer://tutorial?fixedRate=true&delay=3000&period=10000")
>>>>                .setBody(constant(".....................Liav Camel
>>>> POC......................."))
>>>>                        .to("myProcessor");
>>>>
>>>>    }
>>>> }
>>>>
>>>> Here is my processor java file:
>>>> public class MyProcessor implements Processor {
>>>>          public void process(Exchange exchange) throws Exception {
>>>>              //WANT TO INITIATE A CALL TO http pROVIDER END POINT &
>>>> PASS
>>>> THE
>>>> 'FROM'
>>>>                  // PARAMETRS RECIEVED PROIRE TO THE PROCESSOR INVOKE.
>>>> }
>>>> }
>>>>
>>>> Thanks.
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21351142.html
>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>>
>>> /Claus Ibsen
>>> Apache Camel Committer
>>> Blog: http://davsclaus.blogspot.com/
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21387207.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> 
> /Claus Ibsen
> Apache Camel Committer
> Blog: http://davsclaus.blogspot.com/
> 
> 

-- 
View this message in context: http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21387318.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: How do i call an HTTP Provider end-pont from the process method?

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

When you are working with ServiceMix you must use the JBI component in Camel
http://activemq.apache.org/camel/jbi.html

So your endpoints should starting with "jbi:XXXX"

And ServiceMix has some Camel docu here:
http://servicemix.apache.org/servicemix-camel.html

Could you take a look at this docu a bit. There might be some help there.

Try to get something more easier working with SMX and Camel and then
later do the stuff you want with the dynamic add a camel context.


On Sat, Jan 10, 2009 at 12:39 PM, Liav Ezer <li...@gmail.com> wrote:
>
> Hi Claus,
>
> I read your tutorial & learnt from it. Thanks. I adopted the cxf framework
> for now.
>
> Regarding my project (as stated above in snippets):
>
> I planted the following camel routing logic at my processor class:
>
> process method - with camel:
>
> public void process(Exchange exchange) throws Exception {
>
>  CamelContext camel = new DefaultCamelContext();
>  camel.start();
>
>  Component component = (Component) camel.getComponent("http-provider-su");
>
>  Endpoint endpoint = (Endpoint) ((org.apache.camel.Component)
> component).createEndpoint("provider:com.amdocs.oxp.esb");
>
>  exchange.getIn().setBody("Liav testing here!");
>
>  Producer producer = ((org.apache.camel.Endpoint)
> endpoint).createProducer();
>
>  producer.start();
>  producer.process(exchange);
>  producer.stop();
>
>  //System.out.println(exchange.getIn().toString() + "process activated by
> SU");
> }
>
> And got the following exception while SA's jar was deployed:
>
> ERROR - DeadLetterChannel              - Failed delivery for exchangeId:
> ID-LIAVE02/1885-1231586726193/0-0. On delivery attemp
> java.lang.NullPointerException
>        at
> org.apache.servicemix.tutorial.camel.MyProcessor.process(MyProcessor.java:33)
> at
> org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:92)
>        at
> org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:66)
>        at
> org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorT
>        at
> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:75)
>        at
> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:146)
>        at
> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:90)
>        at org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
>        at org.apache.camel.processor.Pipeline.process(Pipeline.java:85)
>        at
> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:39)
>        at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
>        at
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
>        at
> org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:91)
>        at
> org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:48)
>        at java.util.TimerThread.mainLoop(Timer.java:512)
>        at java.util.TimerThread.run(Timer.java:462)
>
> Be advise that line 33 is:Endpoint endpoint = (Endpoint)
> ((org.apache.camel.Component)
> component).createEndpoint("provider:com.amdocs.oxp.esb");
>
> My questions:
>
> 1. As bolded above i "fetched" my provider su component by staing it's name
> - is it correct?
>
> 2. I used the following servicemix object (not camel's) since i work with
> servicemix provider endpoint. That's the reason for all the casting in my
> code:
> import org.apache.servicemix.jbi.deployment.Component;
> import org.apache.servicemix.jbi.framework.Endpoint;
>
> Is it correct?
>
> Thank again,
> Liav Ezer.
>
>
>
>
>
> Claus Ibsen-2 wrote:
>>
>> Hi
>>
>> You can use the producer template to call an external http server and
>> get the response.
>>
>> See this tutorial:
>> http://activemq.apache.org/camel/tutorial-axis-camel.html
>>
>> From the section - integrating Camel
>>
>> Its kinda the same but its just uses the producer template to save a
>> file. Its the same API for using any of the camel components.
>>
>> Little sidenote:
>> And since you use InOut you should use: requestBody instread of
>> sendBody. However Camel is not to stricky about this yet so if you use
>> a send instead of request then it should work as well.
>>
>> The demo shows how to inject a producer template from spring into your
>> bean class = your processor. when you have this template you can call
>> the external http server and get the response using the requestBody
>> method.
>>
>>
>>
>>
>>
>>
>>
>> On Thu, Jan 8, 2009 at 1:46 PM, Liav Ezer <li...@gmail.com> wrote:
>>>
>>> Hi,
>>>
>>> Here is my camel-context:
>>>
>>>  <camelContext id="camel"
>>> xmlns="http://activemq.apache.org/camel/schema/spring">
>>>    <package>org.apache.servicemix.tutorial.camel</package>
>>>  </camelContext>
>>>
>>>  <bean id="myProcessor"
>>> class="org.apache.servicemix.tutorial.camel.MyProcessor"/>
>>>
>>> Here is my RouteBuilder java file:
>>>
>>> public class MyRouteBuilder extends RouteBuilder {
>>>        public void configure() {
>>>        from("timer://tutorial?fixedRate=true&delay=3000&period=10000")
>>>                .setBody(constant(".....................Liav Camel
>>> POC......................."))
>>>                        .to("myProcessor");
>>>
>>>    }
>>> }
>>>
>>> Here is my processor java file:
>>> public class MyProcessor implements Processor {
>>>          public void process(Exchange exchange) throws Exception {
>>>              //WANT TO INITIATE A CALL TO http pROVIDER END POINT & PASS
>>> THE
>>> 'FROM'
>>>                  // PARAMETRS RECIEVED PROIRE TO THE PROCESSOR INVOKE.
>>> }
>>> }
>>>
>>> Thanks.
>>> --
>>> View this message in context:
>>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21351142.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>>
>> /Claus Ibsen
>> Apache Camel Committer
>> Blog: http://davsclaus.blogspot.com/
>>
>>
>
> --
> View this message in context: http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21387207.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 

/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/

Re: How do i call an HTTP Provider end-pont from the process method?

Posted by Liav Ezer <li...@gmail.com>.
Hi Claus,

I read your tutorial & learnt from it. Thanks. I adopted the cxf framework
for now.

Regarding my project (as stated above in snippets):

I planted the following camel routing logic at my processor class:

process method - with camel:

public void process(Exchange exchange) throws Exception {

  CamelContext camel = new DefaultCamelContext();
  camel.start();

  Component component = (Component) camel.getComponent("http-provider-su");

  Endpoint endpoint = (Endpoint) ((org.apache.camel.Component)
component).createEndpoint("provider:com.amdocs.oxp.esb");

  exchange.getIn().setBody("Liav testing here!");

  Producer producer = ((org.apache.camel.Endpoint)
endpoint).createProducer();
  
  producer.start();
  producer.process(exchange);
  producer.stop();

 //System.out.println(exchange.getIn().toString() + "process activated by
SU");
}

And got the following exception while SA's jar was deployed:

ERROR - DeadLetterChannel              - Failed delivery for exchangeId:
ID-LIAVE02/1885-1231586726193/0-0. On delivery attemp
java.lang.NullPointerException
        at
org.apache.servicemix.tutorial.camel.MyProcessor.process(MyProcessor.java:33)       
at
org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:92)
        at
org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:66)
        at
org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorT
        at
org.apache.camel.processor.SendProcessor.process(SendProcessor.java:75)
        at
org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:146)
        at
org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:90)
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:85)
        at
org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:39)
        at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
        at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
        at
org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:91)
        at
org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:48)
        at java.util.TimerThread.mainLoop(Timer.java:512)
        at java.util.TimerThread.run(Timer.java:462)

Be advise that line 33 is:Endpoint endpoint = (Endpoint)
((org.apache.camel.Component)
component).createEndpoint("provider:com.amdocs.oxp.esb");

My questions:

1. As bolded above i "fetched" my provider su component by staing it's name
- is it correct?

2. I used the following servicemix object (not camel's) since i work with
servicemix provider endpoint. That's the reason for all the casting in my
code:
import org.apache.servicemix.jbi.deployment.Component;
import org.apache.servicemix.jbi.framework.Endpoint;

Is it correct?

Thank again,
Liav Ezer.





Claus Ibsen-2 wrote:
> 
> Hi
> 
> You can use the producer template to call an external http server and
> get the response.
> 
> See this tutorial:
> http://activemq.apache.org/camel/tutorial-axis-camel.html
> 
> From the section - integrating Camel
> 
> Its kinda the same but its just uses the producer template to save a
> file. Its the same API for using any of the camel components.
> 
> Little sidenote:
> And since you use InOut you should use: requestBody instread of
> sendBody. However Camel is not to stricky about this yet so if you use
> a send instead of request then it should work as well.
> 
> The demo shows how to inject a producer template from spring into your
> bean class = your processor. when you have this template you can call
> the external http server and get the response using the requestBody
> method.
> 
> 
> 
> 
> 
> 
> 
> On Thu, Jan 8, 2009 at 1:46 PM, Liav Ezer <li...@gmail.com> wrote:
>>
>> Hi,
>>
>> Here is my camel-context:
>>
>>  <camelContext id="camel"
>> xmlns="http://activemq.apache.org/camel/schema/spring">
>>    <package>org.apache.servicemix.tutorial.camel</package>
>>  </camelContext>
>>
>>  <bean id="myProcessor"
>> class="org.apache.servicemix.tutorial.camel.MyProcessor"/>
>>
>> Here is my RouteBuilder java file:
>>
>> public class MyRouteBuilder extends RouteBuilder {
>>        public void configure() {
>>        from("timer://tutorial?fixedRate=true&delay=3000&period=10000")
>>                .setBody(constant(".....................Liav Camel
>> POC......................."))
>>                        .to("myProcessor");
>>
>>    }
>> }
>>
>> Here is my processor java file:
>> public class MyProcessor implements Processor {
>>          public void process(Exchange exchange) throws Exception {
>>              //WANT TO INITIATE A CALL TO http pROVIDER END POINT & PASS
>> THE
>> 'FROM'
>>                  // PARAMETRS RECIEVED PROIRE TO THE PROCESSOR INVOKE.  
>> }
>> }
>>
>> Thanks.
>> --
>> View this message in context:
>> http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21351142.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> 
> /Claus Ibsen
> Apache Camel Committer
> Blog: http://davsclaus.blogspot.com/
> 
> 

-- 
View this message in context: http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21387207.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: How do i call an HTTP Provider end-pont from the process method?

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Sorry this is rubbish what I write. The code below is for consuming
only, such as polling a file.

What you wanted was to call an external http server and get the response.
- You can do as Willem suggested directly in the route without the Processor
- From the Processor you can use the ProducerTemplate to call and get
response in a single codeline

public void process(Exchange exchange) {
  ProducerTemplate producer =
exchange.getCamelContext().createProducerTemplate();
  Object response =
producer.sendBody("http://myserver.com/myapp?foo=bar", "Liv Camel
POC");
}

On Thu, Jan 8, 2009 at 2:01 PM, Claus Ibsen <cl...@gmail.com> wrote:
> Hi
>
> You can use the producer template to call an external http server and
> get the response.
>
> See this tutorial:
> http://activemq.apache.org/camel/tutorial-axis-camel.html
>
> From the section - integrating Camel
>
> Its kinda the same but its just uses the producer template to save a
> file. Its the same API for using any of the camel components.
>
> Little sidenote:
> And since you use InOut you should use: requestBody instread of
> sendBody. However Camel is not to stricky about this yet so if you use
> a send instead of request then it should work as well.
>
> The demo shows how to inject a producer template from spring into your
> bean class = your processor. when you have this template you can call
> the external http server and get the response using the requestBody
> method.
>
>
>
>
>
>
>
> On Thu, Jan 8, 2009 at 1:46 PM, Liav Ezer <li...@gmail.com> wrote:
>>
>> Hi,
>>
>> Here is my camel-context:
>>
>>  <camelContext id="camel"
>> xmlns="http://activemq.apache.org/camel/schema/spring">
>>    <package>org.apache.servicemix.tutorial.camel</package>
>>  </camelContext>
>>
>>  <bean id="myProcessor"
>> class="org.apache.servicemix.tutorial.camel.MyProcessor"/>
>>
>> Here is my RouteBuilder java file:
>>
>> public class MyRouteBuilder extends RouteBuilder {
>>        public void configure() {
>>        from("timer://tutorial?fixedRate=true&delay=3000&period=10000")
>>                .setBody(constant(".....................Liav Camel
>> POC......................."))
>>                        .to("myProcessor");
>>
>>    }
>> }
>>
>> Here is my processor java file:
>> public class MyProcessor implements Processor {
>>          public void process(Exchange exchange) throws Exception {
>>              //WANT TO INITIATE A CALL TO http pROVIDER END POINT & PASS THE
>> 'FROM'
>>                  // PARAMETRS RECIEVED PROIRE TO THE PROCESSOR INVOKE.   }
>> }
>>
>> Thanks.
>> --
>> View this message in context: http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21351142.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
>
>
>
> --
>
> /Claus Ibsen
> Apache Camel Committer
> Blog: http://davsclaus.blogspot.com/
>



-- 

/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/

Re: How do i call an HTTP Provider end-pont from the process method?

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

You can use the producer template to call an external http server and
get the response.

See this tutorial:
http://activemq.apache.org/camel/tutorial-axis-camel.html

>From the section - integrating Camel

Its kinda the same but its just uses the producer template to save a
file. Its the same API for using any of the camel components.

Little sidenote:
And since you use InOut you should use: requestBody instread of
sendBody. However Camel is not to stricky about this yet so if you use
a send instead of request then it should work as well.

The demo shows how to inject a producer template from spring into your
bean class = your processor. when you have this template you can call
the external http server and get the response using the requestBody
method.







On Thu, Jan 8, 2009 at 1:46 PM, Liav Ezer <li...@gmail.com> wrote:
>
> Hi,
>
> Here is my camel-context:
>
>  <camelContext id="camel"
> xmlns="http://activemq.apache.org/camel/schema/spring">
>    <package>org.apache.servicemix.tutorial.camel</package>
>  </camelContext>
>
>  <bean id="myProcessor"
> class="org.apache.servicemix.tutorial.camel.MyProcessor"/>
>
> Here is my RouteBuilder java file:
>
> public class MyRouteBuilder extends RouteBuilder {
>        public void configure() {
>        from("timer://tutorial?fixedRate=true&delay=3000&period=10000")
>                .setBody(constant(".....................Liav Camel
> POC......................."))
>                        .to("myProcessor");
>
>    }
> }
>
> Here is my processor java file:
> public class MyProcessor implements Processor {
>          public void process(Exchange exchange) throws Exception {
>              //WANT TO INITIATE A CALL TO http pROVIDER END POINT & PASS THE
> 'FROM'
>                  // PARAMETRS RECIEVED PROIRE TO THE PROCESSOR INVOKE.   }
> }
>
> Thanks.
> --
> View this message in context: http://www.nabble.com/How-do-i-call-an-HTTP-Provider-end-pont-from-the-process-method--tp21351142s22882p21351142.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 

/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/