ABAP 创建并调用WebService
发布时间:2020-12-13 20:43:25 所属栏目:PHP教程 来源:网络整理
导读:1. 创建Webservice 有两种方式创建webservice,1种是在se80中使用wizard生成,另外一种是直接在se37中给予function生成,具体操作以下: 1.se80中Create--Enterprise Service/Web Service -- Web Servcie 保护service名,选择1个poit type(type point为1个功
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. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |