2012-04-17 52 views
0

我正尝试通过我的java代码连接到Google API,并且我正在使用apache骆驼。我必须先在代理服务器上进行身份验证,然后请求才会被转发到Google。但是,尽管我正在递交凭证,但我无法通过认证。Apache Camel:代理代码

context.getProperties().put("http.proxyAuthMethod","Digest"); 
      context.getProperties().put("http.proxyHost", "foo"); 
      context.getProperties().put("http.proxyPort", "80"); 
      context.getProperties().put("http.proxyAuthUsername", 
        "bar"); 
      context.getProperties().put("http.proxyAuthPassword", "foo"); 

也i相HTTP端点试图

HttpEndpoint endpoint = (HttpEndpoint) context.getEndpoint("https://foo/bar"); 
Map<String, Object> options = new HashMap<String, Object>(); 
      options.put("proxyAuthUsername","foo"); 
      options.put("proxyAuthPassword","bar"); 
      options.put("proxyAuthMethod","Basic"); 
      endpoint.configureProperties(options); 
      endpoint.setProxyHost("foo"); 
      endpoint.setProxyPort(80); 

我仍然得到407响应代码,以及从代理需要认证的消息。任何人都可以给我关于这个的指针。

感谢

回答

3

最后我工作昨晚代理代码,但我不知道为什么上述两种方法都不能正常工作。但是我开始使用Spring XML配置文件进行骆驼路由,并且我能够通过以下配置实现此目的:

<camel:to uri="http://www.google.com/search?proxyAuthMethod=Basic&amp;proxyPort=xx&amp;proxyHost=xxxxxxx&amp;proxyAuthUsername=username&amp;proxyAuthPassword=password" />