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 |