You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by yiwang <im...@gmail.com> on 2013/08/14 12:00:27 UTC

Why can not get the data

hello everyboby,I ask a question.
I write the code:
public class TestHttpCamel {
	public static void main(String args[]) throws Exception {
		CamelContext context = new DefaultCamelContext();
		context.addRoutes(new RouteBuilder() {
			public void configure() {
                               from("http://host:port/query_data_detail")
                               .to("file:d:/temp/outbox?fileName=data.txt");
				
			}
		});
		context.start();
	}

}

explain:
          from("url") url---request service's url and the server returned in
json form
          to("uri")  uri--The local folder address

Why not success from the server to store data in a file ?




--
View this message in context: http://camel.465427.n5.nabble.com/Why-can-not-get-the-data-tp5737243.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Why can not get the data

Posted by yiwang <im...@gmail.com>.
Is not the reason to add "/" 
still not get the data. The HTTP routing write wrong or need what
configuration?



--
View this message in context: http://camel.465427.n5.nabble.com/Why-can-not-get-the-data-tp5737243p5737284.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Why can not get the data

Posted by Marco Westermann <Ma...@gmx.de>.
Hi,

what exactly is you problem. Do you get an exception? try it with the 
following in your route:

.to("file:/d:/temp/outbox?fileName=data.txt")

recognize the / before d:

regards, Marco



Am 14.08.2013 12:00, schrieb yiwang:
> hello everyboby,I ask a question.
> I write the code:
> public class TestHttpCamel {
> 	public static void main(String args[]) throws Exception {
> 		CamelContext context = new DefaultCamelContext();
> 		context.addRoutes(new RouteBuilder() {
> 			public void configure() {
>                                 from("http://host:port/query_data_detail")
>                                 .to("file:d:/temp/outbox?fileName=data.txt");
> 				
> 			}
> 		});
> 		context.start();
> 	}
>
> }
>
> explain:
>            from("url") url---request service's url and the server returned in
> json form
>            to("uri")  uri--The local folder address
>
> Why not success from the server to store data in a file ?
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Why-can-not-get-the-data-tp5737243.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>


Re: Why can not get the data

Posted by nandla <ta...@mahawebs.com>.
camel route:from(" http://localhost:8080/wms/
<http://localhost:8080/wms/query_all_handlover_note?type=source>  
query_all_handlover_note?type=source <http://www.cricscores1.com/teams.html> 
").to("file:d:/temp/outbox?fileName=data1.txt")



--
View this message in context: http://camel.465427.n5.nabble.com/Why-can-not-get-the-data-tp5737243p5737594.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Why can not get the data

Posted by yiwang <im...@gmail.com>.
At present 
camel
route:from("http://localhost:8080/wms/query_all_handlover_note?type=source").to("file:d:/temp/outbox?fileName=data1.txt")
can run successfully.
thank you.




--
View this message in context: http://camel.465427.n5.nabble.com/Why-can-not-get-the-data-tp5737243p5737494.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Why can not get the data

Posted by yiwang <im...@gmail.com>.
began to visit
"http://localhost:8080/wms/query_all_handlover_note?type=source" ,The
results are shown:
{"total":"1","rows":[{"id":51,"noteNo":"43a43d88-4f7f-4364-ad22-cd2076964d7a","from_entry_type":"dd","from_entry_no":"dd","storage_name":"dianlan","model_number":"d1","number":"ed","unit":"d","entry_date":"2013-08-14
15:45:25"}]} 
Can get the json data from the server.
Then run the program.
I have no intention to Visit the url again.there is an error,the following:
org.apache.camel.component.file.GenericFileOperationFailedException: Cannot
write null body to file: d:\temp\outbox\data.txt
How is the problem?



--
View this message in context: http://camel.465427.n5.nabble.com/Why-can-not-get-the-data-tp5737243p5737369.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Why can not get the data

Posted by yiwang <im...@gmail.com>.
Hi:
   Add the corresponding jar package.
   Before the code changes for 
             main.addRouteBuilder(new RouteBuilder() {
			public void configure() {
	
from("jetty://http://localhost:8080/wms/query_all_handlover_note?type=source")
		  .to("file:d:/temp/outbox?fileName=data.txt");

			}
		});
    ,other remains the same.
    still not get the data.I don't know where is my write wrong or what's
the problem.
    Did you see that you get the json data from the server and then stored
in the file in a simple example?
Thank you



--
View this message in context: http://camel.465427.n5.nabble.com/Why-can-not-get-the-data-tp5737243p5737368.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Why can not get the data

Posted by Claus Ibsen <cl...@gmail.com>.
If you want the Camel application to act like a HTTP server, then you
should use jetty component for that. See details at:

http://camel.apache.org/jetty



On Thu, Aug 15, 2013 at 5:01 AM, yiwang <im...@gmail.com> wrote:
> I rewrite code is as follows:
> public class TestHttpCamel {
>         private Main main;
>
>         public static void main(String args[]) throws Exception {
>
>                 TestHttpCamel example = new TestHttpCamel();
>                 example.boot();
>
>         }
>
>         public void boot() throws Exception {
>                 main = new Main();
>                 main.enableHangupSupport();
>                 main.addRouteBuilder(new RouteBuilder() {
>                         public void configure() {
>
> from("http://localhost:8080/wms/query_all_handlover_note?type=source")
>
> .to("file:d:/temp/outbox?fileName=data.txt");
>
>                         }
>                 });
>                 main.run();
>         }
>
> }
> still not get the data.I have direct access to
> "http://localhost:8080/wms/query_all_handlover_note? Type = source",can
> obtain the json data.  The HTTP routing write wrong or need what
> configuration?
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Why-can-not-get-the-data-tp5737243p5737285.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Why can not get the data

Posted by yiwang <im...@gmail.com>.
hi:
   I have direct access to
"http://localhost:8080/wms/query_all_handlover_note?type=source".
Can get the json data.I may not need an Http server for unit testing.I
download the HttpTestServer.java,but have errors.If you feel the need,so how
should I import which packages, normal operation of the HttpTestServer.java?
Thank you.



--
View this message in context: http://camel.465427.n5.nabble.com/Why-can-not-get-the-data-tp5737243p5737367.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Why can not get the data

Posted by Chris Wolf <cw...@gmail.com>.
Do you just need an Http server for unit testing?  Maybe take a look
at the class "HttpTestServer.java" in this directory in Git:

https://fisheye6.atlassian.com/browse/camel-git/tests/camel-itest/src/test/java/org/apache/camel/itest/http

On Wed, Aug 14, 2013 at 11:01 PM, yiwang <im...@gmail.com> wrote:
> I rewrite code is as follows:
> public class TestHttpCamel {
>         private Main main;
>
>         public static void main(String args[]) throws Exception {
>
>                 TestHttpCamel example = new TestHttpCamel();
>                 example.boot();
>
>         }
>
>         public void boot() throws Exception {
>                 main = new Main();
>                 main.enableHangupSupport();
>                 main.addRouteBuilder(new RouteBuilder() {
>                         public void configure() {
>
> from("http://localhost:8080/wms/query_all_handlover_note?type=source")
>
> .to("file:d:/temp/outbox?fileName=data.txt");
>
>                         }
>                 });
>                 main.run();
>         }
>
> }
> still not get the data.I have direct access to
> "http://localhost:8080/wms/query_all_handlover_note? Type = source",can
> obtain the json data.  The HTTP routing write wrong or need what
> configuration?
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Why-can-not-get-the-data-tp5737243p5737285.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Why can not get the data

Posted by yiwang <im...@gmail.com>.
I rewrite code is as follows:
public class TestHttpCamel { 
        private Main main; 

        public static void main(String args[]) throws Exception { 

                TestHttpCamel example = new TestHttpCamel(); 
                example.boot(); 

        } 

        public void boot() throws Exception { 
                main = new Main(); 
                main.enableHangupSupport(); 
                main.addRouteBuilder(new RouteBuilder() { 
                        public void configure() { 
                               
from("http://localhost:8080/wms/query_all_handlover_note?type=source") 
                                               
.to("file:d:/temp/outbox?fileName=data.txt"); 

                        } 
                }); 
                main.run(); 
        } 

} 
still not get the data.I have direct access to
"http://localhost:8080/wms/query_all_handlover_note? Type = source",can
obtain the json data.  The HTTP routing write wrong or need what
configuration?



--
View this message in context: http://camel.465427.n5.nabble.com/Why-can-not-get-the-data-tp5737243p5737285.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Why can not get the data

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

Babak explained this on another post today. So I am quoting his reply

Hi

Invoking start on the CamelContext is a non-blocking call, check links below
to see how to keep your standalone Camel application running:

http://camel.apache.org/running-camel-standalone-and-have-it-keep-running.html
http://stackoverflow.com/questions/1846791/camelcontext-start-doesnt-block

Babak

On Wed, Aug 14, 2013 at 12:00 PM, yiwang <im...@gmail.com> wrote:
> hello everyboby,I ask a question.
> I write the code:
> public class TestHttpCamel {
>         public static void main(String args[]) throws Exception {
>                 CamelContext context = new DefaultCamelContext();
>                 context.addRoutes(new RouteBuilder() {
>                         public void configure() {
>                                from("http://host:port/query_data_detail")
>                                .to("file:d:/temp/outbox?fileName=data.txt");
>
>                         }
>                 });
>                 context.start();
>         }
>
> }
>
> explain:
>           from("url") url---request service's url and the server returned in
> json form
>           to("uri")  uri--The local folder address
>
> Why not success from the server to store data in a file ?
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Why-can-not-get-the-data-tp5737243.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Why can not get the data

Posted by yiwang <im...@gmail.com>.
     1.Is not the reason to add "/"
     2.public class TestHttpCamel {
	private Main main;

	public static void main(String args[]) throws Exception {

		TestHttpCamel example = new TestHttpCamel();
		example.boot();

	}

	public void boot() throws Exception {
		main = new Main();
		main.enableHangupSupport();
		main.addRouteBuilder(new RouteBuilder() {
			public void configure() {
				from("http://localhost:8080/wms/query_all_handlover_note?type=source")
						.to("file:d:/temp/outbox?fileName=data.txt");

			}
		});
		main.run();
	}

}
still not get the data. The HTTP routing write wrong or need what
configuration?



--
View this message in context: http://camel.465427.n5.nabble.com/Why-can-not-get-the-data-tp5737243p5737283.html
Sent from the Camel - Users mailing list archive at Nabble.com.