解析word template返回使用的webservice WSDL和Operation

版权声明:署名,允许他人基于本文进行创作,且必须基于与原先许可协议相同的许可协议分发本文 (Creative Commons

Created by Jerry Wang, last modified on Jun 04, 2014

如果在CRM UI上创建新的document template并为其assign external web service,则可通过下面的report 通过解析template file内容的方法得到web service的WSDL URL和operation:

执行report 得到结果:

REPORT zget_template_wsdl.
 
 
PARAMETERS: file TYPE localfile OBLIGATORY.
 
 
DATA: lv_xtemplate TYPE xstring,
 
      lt_filetable TYPE filetable,
 
      lv_result    TYPE i.
 
 
AT SELECTION-SCREEN ON VALUE-REQUEST FOR file.
 
  CALL METHOD cl_gui_frontend_services=>file_open_dialog
 
    EXPORTING
 
      default_extension = 'docx'
 
    CHANGING
 
      file_table        = lt_filetable
 
      rc                = lv_result.
 
 
  CHECK lv_result = 1.
 
 
  READ TABLE lt_filetable ASSIGNING FIELD-SYMBOL(<result>) INDEX 1.
 
  file = <result>.
 
 
START-OF-SELECTION.
 
 
  PERFORM upload CHANGING lv_xtemplate.
 
 
  CALL METHOD cl_crm_oi_util=>get_ws_url_from_template
 
    EXPORTING
 
      iv_data           = lv_xtemplate
 
    IMPORTING
 
      ev_wsdl_url       = DATA(gv_wsdl_url)
 
      ev_wsdl_operation = DATA(gv_wsdl_operation).
 
 
  WRITE: / 'WSDL URL:', gv_wsdl_url COLOR COL_NEGATIVE.
 
  WRITE: / 'WSDL operation: ', gv_wsdl_operation.
 
 
FORM upload CHANGING cv_content TYPE xstring.
 
  CONSTANTS c_linelen TYPE i VALUE 255.
 
  DATA: wa_data(c_linelen) TYPE x,
 
        it_data            LIKE TABLE OF wa_data,
 
        converter          TYPE REF TO cl_abap_conv_in_ce,
 
        lv_xstring         TYPE xstring,
 
        lv_length          TYPE i.
 
 
  CALL METHOD cl_gui_frontend_services=>gui_upload
 
    EXPORTING
 
      filename                = CONV #( file )
 
      filetype                = 'BIN'
 
    IMPORTING
 
      filelength              = lv_length
 
    CHANGING
 
      data_tab                = it_data
 
    EXCEPTIONS
 
      file_open_error         = 1
 
      file_read_error         = 2
 
      no_batch                = 3
 
      gui_refuse_filetransfer = 4
 
      invalid_type            = 5
 
      no_authority            = 6
 
      unknown_error           = 7
 
      bad_data_format         = 8
 
      header_not_allowed      = 9
 
      separator_not_allowed   = 10
 
      header_too_long         = 11
 
      unknown_dp_error        = 12
 
      access_denied           = 13
 
      dp_out_of_memory        = 14
 
      disk_full               = 15
 
      dp_timeout              = 16
 
      not_supported_by_gui    = 17
 
      error_no_gui            = 18
 
      OTHERS                  = 19.
 
  IF sy-subrc <> 0.
 
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
 
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
 
  ENDIF.
 
 
  CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
 
    EXPORTING
 
      input_length = lv_length
 
    IMPORTING
 
      buffer       = lv_xstring
 
    TABLES
 
      binary_tab   = it_data
 
    EXCEPTIONS
 
      failed       = 1
 
      OTHERS       = 2.
 
  IF sy-subrc  <> 0.
 
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
 
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
 
  ENDIF.
 
 
  cv_content = lv_xstring.
 
ENDFORM.

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

扫码关注云+社区

领取腾讯云代金券