jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Xiaojie Shen <Xiaojie.S...@cybercomgroup.com>
Subject jackrabbit searchMethod - error 405 Method Not Allowed
Date Mon, 21 Jun 2010 08:13:17 GMT

We're trying to do Webdav Search by Jackrabbit searchMethod against our Jackrabbit server,
but always get error 405 Method Not Allowed and there's none error logged in Jackrabbit log.
Then I'm trying to do Search against the Jackrabbit default server, but same error is given.
So far, I haven't found any successful example of SearchMethod on Jackrabbit's wiki or other
resource. Can anybody please give some suggestion?

import java.io.IOException;

import org.apache.commons.httpclient.Credentials;
import org.apache.commons.httpclient.HostConfiguration;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpConnectionManager;
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
import org.apache.jackrabbit.webdav.client.methods.SearchMethod;

public class SearchJackRabbit {
      public static void main(String[] args) throws IOException {
                    HostConfiguration hostConfig = new HostConfiguration();
                  hostConfig.setHost("localhost", 9997);
                  HttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
                  HttpConnectionManagerParams params = new HttpConnectionManagerParams();
                  int maxHostConnections = 20;
                  params.setMaxConnectionsPerHost(hostConfig, maxHostConnections);

                  HttpClient client = new HttpClient(connectionManager);
                  Credentials creds = new UsernamePasswordCredentials("admin", "admin");
                  client.getState().setCredentials(AuthScope.ANY, creds);

                  String query = "<D:searchrequest xmlns:D =\"DAV:\">" +
                    "  <D:sql>" +
                    " SELECT *" +
                    "  </D:sql>" +
                  SearchMethod searchMethod = new SearchMethod("/jackrabbit-webapp_default/repository/default",query,"sql");
                  byte[] resp = searchMethod.getResponseBody();
                  System.out.println("response: " + resp);

                  int statuscode = searchMethod.getStatusCode();
                  System.out.println("statusCode " + statuscode);
                  String statustext = searchMethod.getStatusText();
                  System.out.println("text " + statustext);

Run result:
response: [B@c44b88
statusCode 405
text Method Not Allowed

Best regards


View raw message