如何建立一个Webservice WSDL的简单例子(完整例子)

news/2024/12/23 6:03:58/

一:根据对方给的wsdl 的接口地址创建Web 的逻辑端口

1:例如这个用C#写的Web

2.我们需要在SAP里建立一个Service Consumers 的服务记得后缀要加?wsdl

2:然后就会生成对应方法的出参 入参 返回的消息根据接口方法来判断

二:如何通过LPCONFIG建立逻辑端口或者通过SOAMANAGER来建立

1:指定对应的名称

2:绑定对应的地址再绑定对应SOAP的操作

SOAP操作 = ”Namespace && 调用方法“

三:程序里改如何调用呢

*&---------------------------------------------------------------------*
*& REPORT ZMM_COUNT_MATNR
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zmm_count_matnr.DATA:lr_alv_data TYPE REF TO data.FIELD-SYMBOLS : <lt_alv_data> TYPE ANY TABLE .
FIELD-SYMBOLS : <ls_data> TYPE any.DATA:zwb_log_s   TYPE zwb_log.
DATA:zwb_log_t   TYPE TABLE OF zwb_log.DATA:zwb_log_id  TYPE TABLE OF zwb_log.
DATA:zwb_log_del TYPE TABLE OF zwb_log.
DATA:zwb_log_in  TYPE TABLE OF zwb_log.DATA:lt_lgort TYPE TABLE OF zwb_lgort.DATA:lv_x.DATA:BEGIN OF gs_excel,werks   TYPE string,lgort   TYPE string,matnr   TYPE string,charg   TYPE string,labst   TYPE string,fact    TYPE string,extime  TYPE char08,type    TYPE string,message TYPE string,datum   TYPE string,END OF gs_excel.
DATA:zwb_log_excel  LIKE TABLE OF gs_excel.DATA gt_fieldcat TYPE lvc_t_fcat.         "列结构
DATA gs_fieldcat TYPE lvc_s_fcat.         "列结构 --工作区
DATA gs_layout TYPE lvc_s_layo.           "表单格式TYPES: BEGIN OF ty_fieldname,name TYPE char20,END OF ty_fieldname.DATA: lt_fieldname TYPE TABLE OF ty_fieldname WITH HEADER LINE.DATA:lv_data1 TYPE sy-datum.
DATA:lv_data2 TYPE sy-datum.IF sy-datum+7(1) = 1.lv_data1 = sy-datum.lv_data2 = sy-datum - 1.
ELSE.lv_data1 = sy-datum.lv_data2 = sy-datum.
ENDIF.DEFINE fieldcatset.CLEAR gs_fieldcat.gs_fieldcat-fieldname   = &1.                  "字段名称gs_fieldcat-coltext     = &2.                  "字段显示名称gs_fieldcat-outputlen   = &3.                  "输出长度APPEND gs_fieldcat TO gt_fieldcat.
END-OF-DEFINITION.PARAMETERS:s_werks1 TYPE marc-werks OBLIGATORY.
RANGES:s_werks FOR marc-werks.
RANGES:s_matnr FOR mara-matnr.
RANGES:s_lgort FOR mard-lgort.DATA: lcx_ex TYPE REF TO cx_ai_system_fault.
DATA: lv_err_msg    TYPE string,lcx_fault     TYPE REF TO cx_ai_application_fault,lcl_zmm20     TYPE REF TO zmm20co_if_trs_cpi_delivery_so,ls_acc_input  TYPE zmm20get_pdmaterial_data_soap1,ls_acc_output TYPE zmm20get_pdmaterial_data_soap,ls_return     TYPE zmm20pdmaterial_return_item.
DATA:zmm20pdmaterial_result_item TYPE zmm20pdmaterial_result_item.AT SELECTION-SCREEN OUTPUT.IF sy-datum+6(2) = '01' .MESSAGE '还未到盘点时间' TYPE 'E'.ENDIF.END-OF-SELECTION.PERFORM get_data.           "获取数据PERFORM check_data.         "检查数据PERFORM frm_pre_fieldcat.   "设置字段PERFORM frm_set_layout.     "设置布局PERFORM frm_show_alv.
*PERFORM Filter_data.        "过滤发送的数据*&---------------------------------------------------------------------*
*& Form get_data
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM get_data .s_werks+0(3) = 'IEQ'.s_werks-low = s_werks1.APPEND s_werks.SELECT * FROM zwb_lgort WHERE werks IN @s_werks INTO CORRESPONDING FIELDS OF TABLE @lt_lgort.LOOP AT lt_lgort INTO DATA(ls_lgort).SELECT single lgort FROM ZMM_LGORTWHERE werks = @ls_lgort-werksAND lgort = @ls_lgort-lgortINTO  @DATA(ls_mm_lgort) .IF ls_mm_lgort IS  INITIAL.MESSAGE '盘点的线边仓' && ls_lgort-lgort  && '不存在!!' TYPE 'S' DISPLAY LIKE 'E'.LEAVE PROGRAM.ENDIF.ENDLOOP.CLEAR:s_lgort.LOOP AT lt_lgort INTO ls_lgort.s_lgort+0(3) = 'IEQ'.s_lgort-low = ls_lgort-lgort.APPEND s_lgort.ENDLOOP.cl_salv_bs_runtime_info=>set( EXPORTING display  = abap_falsemetadata = abap_falsedata     = abap_true ).CLEAR lr_alv_data.UNASSIGN <lt_alv_data>.SUBMIT rm07mlbs WITH werks IN s_werksWITH matnr IN s_matnrWITH lgort IN s_lgortWITH pa_sond = ''WITH nozero = 'X'WITH xmchb = 'X'WITH pa_hsq = ''WITH pa_flt = 'X'AND RETURN.TRY.cl_salv_bs_runtime_info=>get_data_ref( IMPORTING r_data = lr_alv_data ).ASSIGN lr_alv_data->* TO <lt_alv_data>.CATCH cx_salv_bs_sc_runtime_info.MESSAGE 'Unable to retrieve ALV data! Please try other conditions.' TYPE 'E'.ENDTRY.cl_salv_bs_runtime_info=>clear_all( ).ENDFORM.*&---------------------------------------------------------------------*
*& Form check_data
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM check_data .DATA:lv_posnr TYPE n LENGTH 6.DATA:lv_uuid  TYPE uuid.CLEAR:lv_uuid.TRY.CALL METHOD cl_system_uuid=>if_system_uuid_static~create_uuid_x16RECEIVINGuuid = lv_uuid.CATCH cx_uuid_error.ENDTRY.IF <lt_alv_data> IS ASSIGNED.UNASSIGN <ls_data>.LOOP AT <lt_alv_data> ASSIGNING <ls_data>."即所需要内表数据MOVE-CORRESPONDING <ls_data> TO zwb_log_s.zwb_log_s-uuid = lv_uuid.READ TABLE lt_lgort INTO DATA(ls_lgort) WITH KEY werks = zwb_log_s-werkslgort = zwb_log_s-lgort.IF sy-subrc = 0.zwb_log_s-fact = ls_lgort-fact.ENDIF.IF zwb_log_s-matnr+0(6) <> 'Q01-EN' AND zwb_log_s-labst = '0'.CLEAR:zwb_log_s.ENDIF.IF zwb_log_s-matnr IS NOT INITIAL.SELECT SINGLE vfdat FROM mch1 WHERE matnr = @zwb_log_s-matnr AND charg = @zwb_log_s-charg INTO @DATA(ls_vfadt)."没有过期日期赋值IF ls_vfadt IS INITIAL.zwb_log_s-extime = sy-datum+0(7) && '2000000'.ELSE.zwb_log_s-extime = ls_vfadt && '000000'.ENDIF.IF zwb_log_s-extime >= sy-datum && '000000'.
*        IF zwb_log_s-extime >= '20240901000000'.zwb_log_s-type     = ''.zwb_log_s-message  = ''.zwb_log_s-datum    = ''.zwb_log_s-uzeit    = ''.ELSE.zwb_log_s-type     = 'D'.zwb_log_s-message  = 'SAP货架过期日期已过期'.zwb_log_s-datum    = sy-datum.zwb_log_s-uzeit    = sy-uzeit.ENDIF.lv_posnr = lv_posnr + 1.zwb_log_s-posnr = lv_posnr.APPEND zwb_log_s TO zwb_log_t.ENDIF.ENDLOOP.ENDIF."先检索相同批次不同物料的MOVE-CORRESPONDING zwb_log_t TO zwb_log_id.DATA(lv_lines1) = lines( zwb_log_t ).SORT zwb_log_id BY charg.DELETE ADJACENT DUPLICATES FROM zwb_log_id COMPARING charg.DATA(lv_lines2) = lines( zwb_log_id ).IF lv_lines1 <> lv_lines2.CALL FUNCTION 'CTVB_COMPARE_TABLES'EXPORTINGtable_old  = zwb_log_ttable_new  = zwb_log_idkey_length = 100  "键长度,指定内表中的前若干个字节为主键,做为内表行是否为增加的判断条件。IMPORTINGtable_del  = zwb_log_del. "new比old 少的数据LOOP AT zwb_log_del INTO DATA(zwb_log_des).LOOP AT zwb_log_t INTO zwb_log_s WHERE charg = zwb_log_des-charg.zwb_log_s-type     = 'D'.zwb_log_s-message  = '批次相同不同料号'.zwb_log_s-datum    = sy-datum.zwb_log_s-uzeit    = sy-uzeit.MODIFY zwb_log_t FROM zwb_log_s.ENDLOOP.ENDLOOP.ENDIF.SORT zwb_log_t BY werks lgort matnr.
ENDFORM.*&---------------------------------------------------------------------*
*& Form frm_pre_fieldcat
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM frm_pre_fieldcat .fieldcatset:'WERKS'   '工厂'          '80' ,'LGORT'   '储存地点'      '80' ,'MATNR'   '物料编码'      '80' ,'CHARG'   '批次'          '80' ,'LABST'   '数量'          '80' ,'FACT'    'MES工厂'       '80' ,'EXTIME'  '货架过期日期'  '80' ,'TYPE'    '当前状态'      '80' ,'MESSAGE' '状态文本'      '80' .ENDFORM.*&---------------------------------------------------------------------*
*& Form frm_set_layout
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM frm_set_layout .gs_layout-cwidth_opt = 'X'.gs_layout-zebra = 'X'.gs_layout-no_toolbar = 'X'.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form Filter_data
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM Filter_data .SORT zwb_log_t BY werks lgort matnr."宁波厂的WLP要分开发LOOP AT zwb_log_t ASSIGNING FIELD-SYMBOL(<fs>) GROUP BY ( fact = <fs>-fact ).CLEAR:ls_acc_input.ls_acc_input-pdmaterial_data-id = sy-datum && sy-uzeit.LOOP AT zwb_log_t INTO zwb_log_s WHERE fact = <fs>-factAND type IS INITIAL.zmm20pdmaterial_result_item-mat_id   = zwb_log_s-matnr.zmm20pdmaterial_result_item-mat_lot  = zwb_log_s-charg.zmm20pdmaterial_result_item-fac      = zwb_log_s-fact.zmm20pdmaterial_result_item-ck       = zwb_log_s-lgort.zmm20pdmaterial_result_item-qty      = zwb_log_s-labst.zmm20pdmaterial_result_item-e_eate   = zwb_log_s-extime.APPEND zmm20pdmaterial_result_item TO ls_acc_input-pdmaterial_data-input-pdmaterial_result_item .ENDLOOP.*   测试端口是否连通CLEAR lv_err_msg.CLEAR lcx_ex.CLEAR ls_acc_output.IF lcl_zmm20 IS INITIAL.TRY.CREATE OBJECT lcl_zmm20EXPORTINGlogical_port_name = 'ZM20WEBSV'.       "逻辑端口名称CATCH cx_ai_system_fault INTO lcx_ex .ENDTRY.ENDIF.IF NOT lcx_ex IS INITIAL.MESSAGE '远程连接生管系统失败,请联系管理员!' TYPE 'S' DISPLAY LIKE 'E'.EXIT.ELSE.TRY.CALL METHOD lcl_zmm20->get_pdmaterial_dataEXPORTINGinput  = ls_acc_inputIMPORTINGoutput = ls_acc_output.CATCH cx_ai_system_fault INTO lcx_ex.CALL METHOD lcx_ex->get_textRECEIVINGresult = lv_err_msg.ENDTRY.IF lv_err_msg IS NOT INITIAL."接口异常MESSAGE lv_err_msg TYPE 'S' DISPLAY LIKE 'E'.EXIT.ELSEIF ls_acc_output-get_pdmaterial_data_result-message_type = 'E' ."错误返回消息记录日志MESSAGE ls_acc_output-get_pdmaterial_data_result-message_text TYPE 'S' DISPLAY LIKE 'E'.IF ls_acc_output-get_pdmaterial_data_result-message_text CA '违反唯一约束条件'.LOOP AT zwb_log_t INTO zwb_log_s WHERE fact = <fs>-factAND type IS INITIAL.zwb_log_s-type     = 'E'.zwb_log_s-message  = '违反唯一约束条件'.zwb_log_s-datum    = sy-datum.zwb_log_s-uzeit    = sy-uzeit.MODIFY zwb_log_t FROM zwb_log_s.ENDLOOP.ELSE.LOOP AT zwb_log_t INTO zwb_log_s WHERE fact = <fs>-factAND type IS INITIAL.zwb_log_s-type     = 'E'.zwb_log_s-message  = ls_acc_output-get_pdmaterial_data_result-message_text.zwb_log_s-datum    = sy-datum.zwb_log_s-uzeit    = sy-uzeit.MODIFY zwb_log_t FROM zwb_log_s.ENDLOOP.ENDIF.EXIT.ELSEIF ls_acc_output-get_pdmaterial_data_result-message_type = 'S' .LOOP AT zwb_log_t INTO zwb_log_s WHERE fact = <fs>-factAND type IS INITIAL.zwb_log_s-type     = 'S'.zwb_log_s-message  = '已盘点完成'.zwb_log_s-datum    = sy-datum.zwb_log_s-uzeit    = sy-uzeit.MODIFY zwb_log_t FROM zwb_log_s.ENDLOOP.ENDIF.ENDIF.ENDLOOP.IF lv_x = ''.INSERT zwb_log FROM TABLE zwb_log_t.ENDIF.ENDFORM.
*&---------------------------------------------------------------------*
*& Form frm_show_alv
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM frm_show_alv .CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'EXPORTINGi_callback_program       = sy-cprogi_callback_pf_status_set = 'SUB_STATUS_SET'i_callback_user_command  = 'SUB_USER_COMMAND'
*     I_GRID_SETTINGS          = GS_SETTING   "编辑回填数据时候打开is_layout_lvc            = gs_layoutit_fieldcat_lvc          = gt_fieldcati_save                   = 'A'TABLESt_outtab                 = zwb_log_tEXCEPTIONSprogram_error            = 1OTHERS                   = 2.IF sy-subrc <> 0.
* Implement suGT_OUTle error handling hereENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*&      Form  SUB_STATUS_SET
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM sub_status_set USING rt_extab TYPE slis_t_extab.SET PF-STATUS 'STATUS01'.
*  set titlebar 'TITLE'.
ENDFORM.                    "SUB_STATUS_SET*&---------------------------------------------------------------------*
*&      Form  SUB_USER_COMMAND
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM sub_user_command USING s_ucomm TYPE sy-ucommre_selfield TYPE slis_selfield.*  修改Alv表的数据实时刷新,并在内表中显示修改的内容DATA: lr_grid TYPE REF TO cl_gui_alv_grid,myindex TYPE sy-tabix.
*  刷新屏幕CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'IMPORTINGe_grid = lr_grid.CALL METHOD lr_grid->check_changed_data.lr_grid->set_frontend_layout( is_layout = gs_layout ).    "防止LAYOUT失效re_selfield-col_stable     = 'X'.re_selfield-row_stable     = 'X'.re_selfield-refresh        = 'X'.CASE s_ucomm.WHEN '&OUT'.IF lv_x = ''.SELECT SINGLE werks FROM zwb_log WHERE datum BETWEEN @lv_data1 AND @lv_data2 AND werks = @s_werks1 INTO @DATA(lv_werks).IF lv_werks IS NOT INITIAL.MESSAGE '工厂:' && lv_werks && '已经盘料!!!' TYPE 'E'.ELSE.PERFORM filter_data.ENDIF.lv_x = 'X'.ELSE.MESSAGE '不允许再次点击发送盘点数据' TYPE 'S' DISPLAY LIKE 'E'.ENDIF.WHEN '&DOWNLOAD'.PERFORM download_excel.ENDCASE.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form DOWNLOAD_EXCEL
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM download_excel .MOVE-CORRESPONDING zwb_log_t TO zwb_log_excel.DELETE zwb_log_excel WHERE type = 'S'.DELETE zwb_log_excel WHERE type = ''.SORT zwb_log_excel BY charg.PERFORM frm_set_fieldname USING '工厂'.PERFORM frm_set_fieldname USING '储存地点'.PERFORM frm_set_fieldname USING '物料编码'.PERFORM frm_set_fieldname USING '批次'.PERFORM frm_set_fieldname USING '数量'.PERFORM frm_set_fieldname USING 'MES工厂'.PERFORM frm_set_fieldname USING '货架过期日期'.PERFORM frm_set_fieldname USING '当前状态'.PERFORM frm_set_fieldname USING '状态文本'.PERFORM frm_set_fieldname USING '建立日期'.DATA lv_file TYPE string.DATA:p_files TYPE rlgrap-filename .p_files = s_werks1 && '工厂盘点异常数据'.CALL FUNCTION 'WS_FILENAME_GET'EXPORTINGdef_filename     = p_files      "默认文件名称
*     DEF_PATH         = ' '     "默认文件路径mask             = ',excel.xls,*.xls,excel.xlsx,*.xlsx,text.txt,*.txt.'mode             = 'S'    "s 保存  ; o打开title            = '保存文件'   "窗口显示名称IMPORTINGfilename         = lv_file
*     RC               =EXCEPTIONSinv_winsys       = 1no_batch         = 2selection_cancel = 3selection_error  = 4OTHERS           = 5.CALL FUNCTION 'GUI_DOWNLOAD'EXPORTING
*     BIN_FILESIZE                    =filename   = lv_filefiletype   = 'DAT' "ASC格式 1000- 不会显示为 -1000 DBF格式 字符前空格 前导0不会显示codepage   = '8404' "四位字符集代码 可通过表TCP00A,查询对应字符集代TABLESdata_tab   = zwb_log_excel       "内表数据fieldnames = lt_fieldname.       "表头字段名
ENDFORM.FORM frm_set_fieldname  USING    VALUE(p_fieldname).         "控制获取的字段名lt_fieldname = p_fieldname.APPEND lt_fieldname.
ENDFORM.

四:如何在Postman里调用

1:输入调用方法的路径

2:更改或添加Headers参数 

3:复制XML报文 raw改成XML调用即可


http://www.ppmy.cn/news/1526795.html

相关文章

计算机三级 - 数据库技术 - 第十四章 数据仓库与数据挖掘 笔记

第十四章 数据仓库与数据挖掘 内容提要&#xff1a; 了解数据仓库相关技术了解数据仓库的设计、建造、运行及维护了解OLAP及多维数据模型了解数据挖掘技术 决策支持系统(DSS)&#xff1a;综合利用大量数据有机组合众多模型(数学模型和数据处理模型)&#xff0c;通过人机交互&a…

观察者模式,回调函数,事件调度

观察者模式 定义 是一种行为型设计模式&#xff0c;它定义了一种一对多的依赖关系&#xff0c;当一个对象的状态发生改变时&#xff0c;其所有依赖于它的对象都会收到通知并自动更新。 主题&#xff08;Subject&#xff09;&#xff1a;也称为被观察者&#xff0c;维护一个观…

ASP.NET Core 入门教学二十八 linux打包部署

在Linux上打包和部署ASP.NET Core应用程序涉及几个步骤。以下是一个详细的指南&#xff0c;帮助你在Linux系统上完成这一过程。 1. 准备工作 确保你的Linux系统已经安装了以下软件&#xff1a; .NET SDK&#xff08;用于构建应用程序&#xff09;.NET Runtime&#xff08;用…

华为地图服务 - 如何开启和展示“我的位置”? -- HarmonyOS自学10

一. 场景介绍 本章节将向您介绍如何开启和展示“我的位置”功能&#xff0c;“我的位置”指的是进入地图后点击“我的位置”显示当前位置点的功能。效果如下&#xff1a; 二. 接口说明 “我的位置”功能主要由MapComponentController的方法实现&#xff0c;更多接口及使用方法…

MacOS Catalina 从源码构建Qt6.2开发库之01: 编译Qt6.2源代码

安装xcode&#xff0c; cmake&#xff0c; ninja brew install node mac下安装OpenGL库并使之对各项目可见 在macOS上安装OpenGL通常涉及到安装一些依赖库&#xff0c;如MGL、GLUT或者是GLEW等&#xff0c;同时确保LLVM的OpenGL框架和相关工具链的兼容性。以下是一个基本的安装…

深入理解Go语言中的接口定义与使用

在Go语言的编程实践中&#xff0c;接口&#xff08;Interface&#xff09; 是一个强大而灵活的特性&#xff0c;它允许我们定义一组方法&#xff0c;而不需要指定这些方法的具体实现。通过接口&#xff0c;我们可以将不同类型的值组合在一起&#xff0c;只要它们实现了接口中定…

Docker | 轻松管理容器:Portainer安装与使用指南

引言 在Docker的世界中&#xff0c;管理容器、镜像、网络和卷可能会变得复杂&#xff0c;特别是当项目规模扩大时。幸运的是&#xff0c;Portainer提供了一个简单而强大的可视化界面来管理Docker环境。本文将带你了解如何安装和使用Portainer&#xff0c;让你的容器管理变得更…

策略路由与路由策略的区别

&#x1f423;个人主页 可惜已不在 &#x1f424;这篇在这个专栏 华为_可惜已不在的博客-CSDN博客 &#x1f425;有用的话就留下一个三连吧&#x1f63c; 目录 一、主体不同 二、方式不同 三、规则不同 四、定义和基本概念 一、主体不同 1、路由策略&#xff1a;是为了改…