【问题标题】:Google Search Appliance Administration APIGoogle Search Appliance 管理 API
【发布时间】:2013-08-15 20:13:34
【问题描述】:

我们使用 GSA 进行公司内部搜索,它已配置为安全 URL,即 https_colon_fwdSlash2_Myhostname.net:8443。我正在尝试使用谷歌搜索设备管理 API 来连接到 GSA。我正在使用 API 的 Java 版本,并在我公司网络内的不同服务器上编写程序。

这是我要运行的代码

 import java.io.IOException;
 import java.net.MalformedURLException;

 import com.google.enterprise.apis.client.GsaClient;
 import com.google.enterprise.apis.client.GsaEntry;
 import com.google.gdata.util.ServiceException;

 public class GsaFirst {
 public static void main(String args[]) throws MalformedURLException, ServiceException, IOException{

        System.out.println("The program started...");
        GsaClient myClient = new GsaClient("Myhostname.net", 8443, "username", "pwd1234");
        System.out.println("this is the error");
        //String addr = myClient.getAddress();
        //System.out.println(addr);

        GsaEntry myEntry = myClient.getEntry("config", "crawlURLs");
        System.out.println("Start URLs: " + myEntry.getGsaContent("startURLs"));
        System.out.println("Follow URLs: " + myEntry.getGsaContent("followURLs"));
        System.out.println("Do Not Crawl URLs: " + myEntry.getGsaContent("doNotCrawlURLs"));

    }

}

我得到的输出是 节目开始... 线程“主”com.google.gdata.util.AuthenticationException 中的异常:身份验证错误(检查服务名称) 在 com.google.gdata.client.GoogleAuthTokenFactory.getAuthException(未知来源) 在 com.google.gdata.client.GoogleAuthTokenFactory.getAuthToken(未知来源) 在 com.google.gdata.client.GoogleAuthTokenFactory.setUserCredentials(未知来源) 在 com.google.gdata.client.GoogleService.setUserCredentials(未知来源) 在 com.google.gdata.client.GoogleService.setUserCredentials(未知来源) 在 com.google.gdata.client.GoogleService.setUserCredentials(未知来源) 在 com.google.enterprise.apis.client.GsaClient.(未知来源) 在 com.google.enterprise.apis.client.GsaClient.(未知来源) 在 com.gsa.GsaFirst.main(GsaFirst.java:14)

如果有人可以帮助我或指导我必须采取哪些步骤来解决此问题。感谢您对此的任何帮助。

【问题讨论】:

    标签: networking google-search-api google-search-appliance


    【解决方案1】:

    我能够通过添加这个小sn-p代码来解决这个问题。

      import java.io.IOException;
      import java.net.MalformedURLException;
    
      import com.google.enterprise.apis.client.GsaClient;
      import com.google.enterprise.apis.client.GsaEntry;
      import com.google.gdata.util.ServiceException;
    
      public class GsaFirst {
      static {
        //for localhost testing only
        javax.net.ssl.HttpsURLConnection.setDefaultHostnameVerifier(
        new javax.net.ssl.HostnameVerifier(){
    
            public boolean verify(String hostname,
                    javax.net.ssl.SSLSession sslSession) {
                if (hostname.equals("Myhostname.net")) {
                    return true;
                }
                return false;
            }
        });
    }
      public static void main(String args[]) throws MalformedURLException,   ServiceException, IOException{
    
        System.out.println("The program started...");
        GsaClient myClient = new GsaClient("Myhostname.net", 8443, "username", "pwd1234");
        System.out.println("this is the error");
        //String addr = myClient.getAddress();
        //System.out.println(addr);
    
        GsaEntry myEntry = myClient.getEntry("config", "crawlURLs");
        System.out.println("Start URLs: " + myEntry.getGsaContent("startURLs"));
        System.out.println("Follow URLs: " + myEntry.getGsaContent("followURLs"));
        System.out.println("Do Not Crawl URLs: " + myEntry.getGsaContent("doNotCrawlURLs"));
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-24
      • 1970-01-01
      • 2014-08-08
      • 2013-06-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多