微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ABAP 创建并调用WebService

1. 创建Webservice


    有两种方式创建webservice,1种是在se80中使用wizard生成,另外一种是直接在se37中给予function生成,具体操作以下:


    1.se80中Create-->Enterprise Service/Web Service --> Web Servcie


      保护service名,选择1个poit type(type point为1个功能点:如,Bapi中的Method,FunctionGroup中的1个function,1个function或Message Interface:XI)


    2.se37 Utility--> More Utility --> Create WebService -->From the Function Module


    在创建完成的时候可以选择立刻release,否则需要在wsconfig中进行release。


2 WSASMIN(WebService Administration)


     Tcode:wsadmin


    选中刚刚创建的Webservice ,可以有两种操作测试webservice


   1.点击Ctrl+F8 --> 进入WebService HomePage(可以预览webservice发送接收的数据)


    2.点击Ctrl+F1 --> 预览WSDL文档


3 在Wsconfig中设置logon Data


    输入Service DeFinition,并填写1个Variant,点击新建


   Create --> ICF Detail -->在Servcie列表当选择需要设置logo Data的Service,双击,在logon data的tab页中设置logo data(设置了logon data的service在调用时就不会在弹出logon对话框)


    (tcode : SICF 可以直接进入Maintain Service)


4 在ABAP中调用Webservice


    1.创建Proxy


     se80 --> Create --> Enterprice Service --> Proxy


    在Proxy中指定wsdl连接


    2. 创建Logical Port (tcode:lpconfig


    输入Logical Port,指定Proxy Class,点击新建。


    3.创建程序


      在se80中,将Proxy拖入到workbench中,自动生成代码框架,根据自己需求进行简单的修改代码示例以下:


REPORT   zws_flight_gl.


DATA: g_proxy TYPE REF TO zglco_zgl_flight .
TRY.
    CREATE OBJECT g_proxy
      EXPORTING logical_port_name = 'ZGLPORT_FLIGHT'
         .
  CATCH cx_ai_system_fault .
ENDTRY.


DATA: output TYPE zglflight_get_list_response .
DATA: input TYPE zglflight_get_list .


input-max_rows = 10 .
TRY.
    CALL METHOD g_proxy->flight_get_list
      EXPORTING
        input   = input
      IMPORTING
        output = output.
  CATCH cx_ai_system_fault .
  CATCH cx_ai_application_fault .
ENDTRY.


DATA : ls_sflight TYPE zglbapisfldat.
DATA : lt_sflight TYPE zglbapisfldat_tab .


lt_sflight = output-flight_list-item .


LOOP AT lt_sflight INTO ls_sflight .


  WRITE    : ls_sflight-airlineid,ls_sflight-airline,
             ls_sflight-connectid,ls_sflight-flightdate,
             ls_sflight-airportfr,ls_sflight-cityfrom,
             ls_sflight-airportto,ls_sflight-cityto,
             ls_sflight-deptime,   ls_sflight-arrtime,
             ls_sflight-arrdate,   ls_sflight-price,
             ls_sflight-curr,      ls_sflight-curr_iso .
  ULINE .


ENDLOOP.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐