【问题标题】:Connecting to Bing Maps SDK from a Rails app从 Rails 应用程序连接到 Bing Maps SDK
【发布时间】:2009-07-09 03:09:38
【问题描述】:

我正在尝试通过 RoR 应用程序连接到 Bing Maps SDK。我的目标是在对两个位置进行地理编码后计算它们之间的行驶距离。我是 SOAP 和 ROR 的新手,所以我可能会犯一个简单的错误。

两天的谷歌搜索(Binging?),我快来了。这是我正在做的事情:

环境

Windows Vista 上的 Ruby 1.8.7(下周获得 Mac)。 gem install httpclient --source http://dev.ctor.org/download/ gem install soap4r --include-dependencies

浏览器测试

转到https://staging.common.virtualearth.net/find-30/common.asmx?wsdl 系统提示我输入用户名和密码。我可以成功输入并接收 WSDL 文件。所以网址、用户名和密码都是正确的

代码

require 'rubygems'
gem 'soap4r'
require 'httpclient'
require "soap/wsdlDriver"
  user = "XXXXXX"
  pass = "XXXXXXX"
  wsdl = "https://staging.common.virtualearth.net/find-30/common.asmx?wsdl"
  driver = SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver
  driver.options["protocol.http.basic_auth"] << [wsdl,user,pass]

控制台输出

driver = SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver


HTTPClient::BadResponseError: 意外响应:未授权", @request_uri=nil, @body_date=nil,@status_code=401,@dumped=false,@request_method=nil,@chunked=false, @body_charset=nil,@request_via_proxy=nil,@header_item=[[“连接”,“关闭”], ["日期", "星期四, 2009 年 7 月 9 日 02:53:59 GMT"], ["服务器", "Microsoft-IIS/6.0"], ["P3P", "CP=\"BUS CUR CONo FIN IVDo ONL OUR PHY SAMo TELo\""], ["X-Powered-By", "ASP.NET"], ["WWW-Authenticate", "Digest qop=\"auth\", realm=\" MapPoint\", nonce=\"87b3d5847da867f7930801742100f2e55de88fd216317a696fe1411f79e3\""], [“内容长度”,“0”]],@body_size=0,@http_version="1.1",@body_type=nil,@request_query=nil,@is_request=false> 来自 c:/ruby/lib/ruby/gems/1.8/gems/httpclient-2.1.5.2/lib/httpclient.rb:840:in `follow_redirect'

我查看过的参考文献

其中一个很可能有答案。我只是没有足够的 SOAP 背景知识来找到它......

http://hideoustriumph.wordpress.com/2008/05/05/ws-deathstar-for-the-rest-of-us/ http://s2.diffuse.it/blog/show/62-Consume_SSL_protected_Web_Services_with_soap4r http://dev.ctor.org/doc/soap4r/RELEASE_en.html#samples http://markthomas.org/2007/09/12/getting-started-with-soap4r/ http://www.elctech.com/articles/consuming-soap-with-ruby-and-soap-mapping-object http://wso2.org/project/wsf/ruby/1.1.0/docs/manual.html http://www.globalnerdy.com/2009/06/29/learnhub-powered-by-rails-searches-with-bing/ http://rpheath.com/posts/298-consuming-soap-services-in-ruby

【问题讨论】:

  • 在 47hats 上很好地讨论了有兴趣获得 Google 地图之外的其他选择。必应是一种选择,但不幸的是,这些工具还没有。请参阅“$10K gotcha”:47hats.com/?p=1329

标签: ruby-on-rails web-services soap bing soap4r


【解决方案1】:

查看 Ruby 库 Savon,这是迄今为止 Ruby 中最好的 SOAP 客户端。

【讨论】:

    【解决方案2】:

    用户savon 用于处理wsdl,然后使用地理编码计算两点之间的距离。因为 bing 地图 API 没有给出直接的“距离差异”,但它为我们提供了点的纬度/经度。而Geocoder可以给出两对lat/lng之间更准确的距离

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-27
      • 1970-01-01
      • 2014-02-12
      • 2017-01-27
      • 1970-01-01
      • 2018-09-06
      • 2015-07-24
      相关资源
      最近更新 更多