【问题标题】:Are BING geocoding & Google geocoding a web-service, or web-api?BING 地理编码和谷歌地理编码是网络服务还是网络 API?
【发布时间】:2014-08-07 20:25:49
【问题描述】:

我只想从 BING 或 Google 中提取纬度和经度(对于 oracle 表中的某些地址)。我想从存储过程中做到这一点。我尝试使用 UTL_DBWS 包执行此操作,但由于缺少“操作”、“输入参数请求格式”等详细信息,因此无法形成完整的调用。我找不到两个地理编码服务的 wsdl 文件.那么这些服务实际上是 web-api 还是 web-service?从 oracle 存储过程中调用这些服务的最佳方式是什么?

【问题讨论】:

    标签: oracle web-services geocoding


    【解决方案1】:

    您可以查看example,它使用 utl_http 来了解如何操作

    你需要注意的几件事

    1)您需要从数据库服务器直接连接互联网

    2)您需要编辑您的数据库 ACL 策略才能使其正常工作

    3)您需要在用于搜索的 URL 中转义“&”符号

    4)您需要使用 Oracle 钱包验证 SSL 证书

    ACL 示例

    BEGIN
    --You need DBA to execute this function where www.xml is the ACL Name
    --SCOTT is the schemaname,my.oracle.com is the host to access the webpage 
    DBMS_NETWORK_ACL_ADMIN.CREATE_ACL(acl         => 'www.xml',
                                    description => 'WWW ACL',
                                    principal   => 'SCOTT',
                                    is_grant    => true,
                                    privilege   => 'connect');
    
    DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(acl       => 'www.xml',
                                       principal => 'SCOTT',
                                       is_grant  => true,
                                       privilege => 'resolve');
    
     DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL(acl  => 'www.xml',
                                    host => 'my.oracle.com');
     END;
     /
    COMMIT;
    

    您可以向 ACL www.xml 添加用于访问 Internet 的其他主机名,如下所示

    BEGIN
    DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL(acl  => 'www.xml',
                                    host => 'www.google.co.in');
    END;
    /
    COMMIT;
    

    这里是一个使用谷歌搜索经纬度的例子

        declare
          httpuri        HttpUriType;
          x              clob;
          address        VARCHAR2(32000):='New York';
          lat_long_value VARCHAR2(4000);
        begin
    
          UTL_HTTP.set_transfer_timeout(60); --set timeout to 60 seconds
          httpuri        := HttpUriType('http://www.google.co.in/search?q=find+latitude+and+longitude+of+' ||address||'&'||'ie=utf-'||'8&'||'oe=utf-'||'8&'||'aq=t'||'&'||'rls=org.mozilla'||':'||'en-US'||':'||'official'||'&'||'client=firefox-a');
          x              := httpuri.getclob();
          lat_long_value := regexp_substr(x, '<div class="_Xj">(.+)</div>');
          if lat_long_value is not null then
            select regexp_replace(lat_long_value,
                                  '<div class="_Xj">(.+)</div>',
                                  '\1')
              into lat_long_value
              FROM dual;
          end if;
          dbms_output.put_line(lat_long_value);
        end;
    

    如果你得到错误,

    Ora-29024 Certification validation failure
    

    请按照所需的步骤将谷歌证书添加到 Oracle 钱包here

    最后你得到的输出是

    40.7127° N, 74.0059° W
    

    【讨论】:

    • 感谢您的回复。那么,在服务被定义为 REST 的情况下,是否可以得出结论,utl_http 是要走的路
    • 您可以通过链接 docs.oracle.com/cd/B28359_01/appdev.111/b28369/xdb15dbu.htm 访问互联网中的 URL 以获取 http 请求,我们使用 utl_http 检索日期跨度>
    猜你喜欢
    • 2012-10-01
    • 1970-01-01
    • 2016-01-05
    • 1970-01-01
    • 2015-09-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多