From: Jérémy C. <jer...@gm...> - 2010-03-30 13:55:44
|
Hello, I have a communication problem between android and eXist. I need to send information/file from android to eXist. My terminal in Android should be able to submit files of type XML to eXist database. I'm using android in VPN. I tried using the PUT&GET method of HTTP (i think GET&PUT method are aviable with eXIst, see=>http://exist.sourceforge.net/devguide_rest.htm ): private static String url = "http://localhost:8080/exist/rest/db/"; HttpClient httpclient = new DefaultHttpClient (); HttpPut httpput = new HttpPut (url); try ( httpput.setEntity (new StringEntity ( "<the goes here> xml")); httpput.setHeader ( "Content-Type", "text / xml"); HttpResponse response; response = httpclient.execute (httpput); ) Catch (ClientProtocolException e) ( e.printStackTrace (); ) Catch (IOException e) ( e.printStackTrace (); ) I get no result and no error in compilation or execution. I therefore ask you one example of Java code, or if an explanation of the "right way" to use. Thanks you for your help |
From: James F. <jam...@gm...> - 2010-03-30 15:08:29
|
On Tue, Mar 30, 2010 at 3:55 PM, Jérémy Cazaux <jer...@gm...> wrote: > Hello, > > I have a communication problem between android and eXist. I need to send > information/file from android to eXist. > > My terminal in Android should be able to submit files of type XML to eXist > database. I'm using android in VPN. > I tried using the PUT&GET method of HTTP (i think GET&PUT method are aviable > with eXIst, see=>http://exist.sourceforge.net/devguide_rest.htm ): ok first step, u sure you can access eXist e.g. u sending right creds or have it setup to be writeable by guest ? > > private static String url = "http://localhost:8080/exist/rest/db/"; you will need to give a name to the new document e.g. http://localhost:8080/exist/rest/db/test.xml > HttpClient httpclient = new DefaultHttpClient (); > HttpPut httpput = new HttpPut (url); > > try ( > httpput.setEntity (new StringEntity ( "<the goes here> xml")); ummm, unsure of what this line is ... cause its not xml ... perhaps u are trying to upload binary document ? > httpput.setHeader ( "Content-Type", "text / xml"); > HttpResponse response; > response = httpclient.execute (httpput); > > ) Catch (ClientProtocolException e) ( > e.printStackTrace (); > > ) Catch (IOException e) ( > e.printStackTrace (); > ) > > I get no result and no error in compilation or execution. > > I therefore ask you one example of Java code, or if an explanation of the > "right way" to use. > > Thanks you for your help a simple HTTP PUT should work but u need to check access, make sure u are slinging xml (if thats your intention), give it a name ... u sure u dont see anything in the eXist logs (usually here webapp/WEB-INF/logs/exist.log) hth, James Fuller > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > Exist-development mailing list > Exi...@li... > https://lists.sourceforge.net/lists/listinfo/exist-development > > |
From: Adam R. <ad...@ex...> - 2010-03-30 15:36:13
|
You need to specify the resource name, i.e. - import java.io.IOException; import java.io.UnsupportedEncodingException; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.methods.PutMethod; import org.apache.commons.httpclient.methods.RequestEntity; import org.apache.commons.httpclient.methods.StringRequestEntity; public class App { public static void main( String[] args ) throws UnsupportedEncodingException, IOException { HttpClient client = new HttpClient(); PutMethod post = new PutMethod("http://localhost:8080/exist/rest/db/test.xml"); RequestEntity entity = new StringRequestEntity("<hello/>", "text/xml", "UTF-8"); post.setRequestEntity(entity); int code = client.executeMethod(post); System.out.println("Response Code: " + code); } } On 30 March 2010 14:55, Jérémy Cazaux <jer...@gm...> wrote: > Hello, > > I have a communication problem between android and eXist. I need to send > information/file from android to eXist. > > My terminal in Android should be able to submit files of type XML to eXist > database. I'm using android in VPN. > I tried using the PUT&GET method of HTTP (i think GET&PUT method are aviable > with eXIst, see=>http://exist.sourceforge.net/devguide_rest.htm ): > > private static String url = "http://localhost:8080/exist/rest/db/"; > > HttpClient httpclient = new DefaultHttpClient (); > HttpPut httpput = new HttpPut (url); > > try ( > httpput.setEntity (new StringEntity ( "<the goes here> xml")); > httpput.setHeader ( "Content-Type", "text / xml"); > HttpResponse response; > response = httpclient.execute (httpput); > > ) Catch (ClientProtocolException e) ( > e.printStackTrace (); > > ) Catch (IOException e) ( > e.printStackTrace (); > ) > > I get no result and no error in compilation or execution. > > I therefore ask you one example of Java code, or if an explanation of the > "right way" to use. > > Thanks you for your help > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > Exist-development mailing list > Exi...@li... > https://lists.sourceforge.net/lists/listinfo/exist-development > > -- Adam Retter eXist Developer { United Kingdom } ad...@ex... irc://irc.freenode.net/existdb |
From: <jer...@gm...> - 2010-03-31 17:48:02
|
Thank you very much, There was a problem with the chmod & the code. It's working now. Best regards. Le Tue, 30 Mar 2010 17:36:05 +0200, Adam Retter <ad...@ex...> a écrit: > You need to specify the resource name, i.e. - > > import java.io.IOException; > import java.io.UnsupportedEncodingException; > import org.apache.commons.httpclient.HttpClient; > import org.apache.commons.httpclient.methods.PutMethod; > import org.apache.commons.httpclient.methods.RequestEntity; > import org.apache.commons.httpclient.methods.StringRequestEntity; > > public class App > { > public static void main( String[] args ) throws > UnsupportedEncodingException, IOException > { > HttpClient client = new HttpClient(); > PutMethod post = new > PutMethod("http://localhost:8080/exist/rest/db/test.xml"); > > RequestEntity entity = new StringRequestEntity("<hello/>", > "text/xml", "UTF-8"); > post.setRequestEntity(entity); > > int code = client.executeMethod(post); > > System.out.println("Response Code: " + code); > } > } > > On 30 March 2010 14:55, Jérémy Cazaux <jer...@gm...> wrote: >> Hello, >> >> I have a communication problem between android and eXist. I need to send >> information/file from android to eXist. >> >> My terminal in Android should be able to submit files of type XML to >> eXist >> database. I'm using android in VPN. >> I tried using the PUT&GET method of HTTP (i think GET&PUT method are >> aviable >> with eXIst, see=>http://exist.sourceforge.net/devguide_rest.htm ): >> >> private static String url = "http://localhost:8080/exist/rest/db/"; >> >> HttpClient httpclient = new DefaultHttpClient (); >> HttpPut httpput = new HttpPut (url); >> >> try ( >> httpput.setEntity (new StringEntity ( "<the goes here> xml")); >> httpput.setHeader ( "Content-Type", "text / xml"); >> HttpResponse response; >> response = httpclient.execute (httpput); >> >> ) Catch (ClientProtocolException e) ( >> e.printStackTrace (); >> >> ) Catch (IOException e) ( >> e.printStackTrace (); >> ) >> >> I get no result and no error in compilation or execution. >> >> I therefore ask you one example of Java code, or if an explanation of >> the >> "right way" to use. >> >> Thanks you for your help >> >> ------------------------------------------------------------------------------ >> Download Intel® Parallel Studio Eval >> Try the new software tools for yourself. Speed compiling, find bugs >> proactively, and fine-tune applications for parallel performance. >> See why Intel Parallel Studio got high marks during beta. >> http://p.sf.net/sfu/intel-sw-dev >> _______________________________________________ >> Exist-development mailing list >> Exi...@li... >> https://lists.sourceforge.net/lists/listinfo/exist-development >> >> > > > -- Utilisant le client e-mail révolutionnaire d'Opera : http://www.opera.com/mail/ |