Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7189502
  • 博文数量: 655
  • 博客积分: 10264
  • 博客等级: 上将
  • 技术积分: 8278
  • 用 户 组: 普通用户
  • 注册时间: 2007-06-04 17:47
个人简介

ABAP顾问

文章分类

全部博文(655)

文章存档

2017年(2)

2014年(8)

2013年(3)

2012年(2)

2011年(18)

2010年(102)

2009年(137)

2008年(274)

2007年(134)

分类:

2010-01-19 11:47:29

***SOAP方式调用WebService

REPORT  z_barry_http_soap_post LINE-SIZE 1023.

DATA: http_client TYPE REF TO if_http_client .
DATA: proxy_host TYPE string VALUE '10.99.60.203' ,
      proxy_port TYPE string VALUE '8080',
      proxy_user TYPE string ,
      proxy_pass TYPE string .
DATA: len TYPE i,
      len_str TYPE string  .
DATA: post_string TYPE string ,
      return_str TYPE string .

PARAMETERS: p_code(11) TYPE c OBLIGATORY DEFAULT '1381852'.
PARAMETERS: p_user(20) TYPE c .

START-OF-SELECTION .

  CONCATENATE ''
  '  ' xmlns:soap="
  ''
  '    IMPORTING
      text_buffer  = str
    TABLES
      binary_tab   = bin_tab.

  CALL METHOD http_client->close.
  WRITE return_str .
  WRITE / str.

 
***HTTP POST 方法
REPORT  z_barry_http_post LINE-SIZE 1023.
 
DATA: http_client TYPE REF TO if_http_client .
DATA: proxy_host TYPE string VALUE '10.99.60.203' ,
      proxy_port TYPE string VALUE '8080',
      proxy_user TYPE string ,
      proxy_pass TYPE string .
DATA: len TYPE i,
      len_str TYPE string  .
DATA: post_string TYPE string ,
      return_str TYPE string .
 
PARAMETERS: p_code(11) TYPE c OBLIGATORY DEFAULT '1381852'.
PARAMETERS: p_user(20) TYPE c .
 
START-OF-SELECTION .
  CONCATENATE 'mobileCode=' p_code '&userID=' p_user INTO post_string.
  len = STRLEN( post_string ) .
  len_str = len .
 
  CALL METHOD cl_http_client=>create
    EXPORTING
      host          = 'webservice.webxml.com.cn'
      service       = '80'
      scheme        = '1'
      proxy_host    = proxy_host
      proxy_service = proxy_port
    IMPORTING
      client        = http_client.
  http_client->propertytype_logon_popup = http_client->co_enabled .
 
*  CALL METHOD http_client->authenticate
*    EXPORTING
*      proxy_authentication = 'X'
*      username             = proxy_user
*      password             = proxy_pass.
 
  CALL METHOD http_client->request->set_header_field
    EXPORTING
      name  = '~request_method'
      value = 'POST'.
  CALL METHOD http_client->request->set_header_field
    EXPORTING
      name  = '~server_protocol'
      value = 'HTTP/1.1'.
  CALL METHOD http_client->request->set_header_field
    EXPORTING
      name  = '~request_uri'
      value = '/WebServices/MobileCodeWS.asmx/getMobileCodeInfo'.
  CALL METHOD http_client->request->set_header_field
    EXPORTING
      name  = 'Content-Type'
      value = 'application/x-www-form-urlencoded'.
  CALL METHOD http_client->request->set_header_field
    EXPORTING
      name  = 'Content-Length'
      value = len_str.
  CALL METHOD http_client->request->set_cdata
    EXPORTING
      data   = post_string
      offset = 0
      length = len.
  CALL METHOD http_client->send
    EXCEPTIONS
      http_communication_failure = 1
      http_invalid_state         = 2.
  CALL METHOD http_client->receive
    EXCEPTIONS
      http_communication_failure = 1
      http_invalid_state         = 2
      http_processing_failed     = 3.
 
  return_str = http_client->response->get_cdata( ).
 
  CALL METHOD http_client->close.
 
  WRITE return_str.
阅读(16118) | 评论(8) | 转发(1) |
给主人留下些什么吧!~~

qdbarry2010-01-19 13:59:51

46C好像没有这个Class,使用HTTP_POST吧

zwvolcano2010-01-19 13:12:28

很好,很强大!

chinaunix网友2010-01-19 13:11:30

老白你这是在ECC上的代码,有没有在46C上代码呢?!!