Chinaunix首页 | 论坛 | 博客
  • 博客访问: 466078
  • 博文数量: 199
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1902
  • 用 户 组: 普通用户
  • 注册时间: 2020-05-14 13:25
个人简介

代码5S

文章分类

全部博文(199)

文章存档

2021年(5)

2020年(194)

我的朋友

分类:

2020-05-20 15:45:00

原文地址:关于HTTP GET 作者:qdbarry

昨天在一个群友的博客上看到一篇HTTP Get的文章(http://www.dbsun.com/blog/article.asp?id=117),用的是if_http_client,其实,像这样简单的应用没有必要搞的这么麻烦,用一个函数就搞定了。
 
 
REPORT z_barry_test_http_get LINE-SIZE 256 .
 
TYPES: BEGIN OF text,
         line(256),
       END OF text.
DATA: status(3) TYPE c,
      statustext(128) TYPE c,
      rlength TYPE i .
DATA: response TYPE TABLE OF text WITH HEADER LINE,
      response_headers TYPE TABLE OF text WITH HEADER LINE.
 
PARAMETERS: url(256) TYPE c LOWER CASE default '' &
                     'huobizhengce/huobizhengcegongju/huilvzhengce/' &
                     'renminbihuilvjiaoyishoupanjia.asp' ,
            dest LIKE rfcdes-rfcdest DEFAULT 'SAPHTTP'.
 
START-OF-SELECTION.
 
  CALL FUNCTION 'HTTP_GET'
    EXPORTING
      absolute_uri                = url
      rfc_destination             = dest
      blankstocrlf                = 'Y'
*       proxy                       = '10.99.60.203:8080' 
    IMPORTING
      status_code                 = status
      status_text                 = statustext
      response_entity_body_length = rlength
    TABLES
      response_entity_body        = response
      response_headers            = response_headers.
 
  LOOP AT response_headers.
    WRITE response_headers-line.
  ENDLOOP.
  SKIP 2.
  LOOP AT response.
    REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>horizontal_tab
                            IN response-line WITH ' '.
    WRITE response-line.
  ENDLOOP.
 
  CALL FUNCTION 'RFC_CONNECTION_CLOSE'
    EXPORTING
      destination = dest
    EXCEPTIONS
      OTHERS      = 0.
 
阅读(773) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~