调试SAP标准程序找到Web Services的HTTP METHOD 为POST 相关类为 CL_SOAP_HTTP_EXTENSION

CL_SOAP_HTTP_EXTENSION
IF_HTTP_EXTENSION~HANDLE_REQUEST
Called for request handling for each incoming HTTP request

IF_HTTP_EXTENSION
HTTP Framework (iHTTP) HTTP Request Handler

SRT_TOOLS SOA 运行时工具

CL_SOAP_HTTP_EXTENSION IF_HTTP_EXTENSION~HANDLE_REQUEST Called for request handling for each incoming HTTP request

method if_http_extension~handle_request.

  try.

  srt_init_errorhandling 'IF_HTTP_EXTENSION~HANDLE_REQUEST'. "#EC NOTEXT

  data: srtid_info           type string,
        srtid_date           type sy-datum,                 "#EC NEEDED
        srtid_time           type sy-uzeit,                 "#EC NEEDED
        srtid_version        type string,                   "#EC NEEDED
        srtid_aguid          type sysuuid_c,                "#EC NEEDED
        srtid_trace_level(3) type n,
        trace_level          type i,
        srtid_appl_id        type sysuuid_c.

  data: l_start_time         type i,
        l_end_time           type i,
        l_run_time           type i,
        lv_commit_time       type i,
        l_p1                 type string,
        l_p2                 type string,
        l_p3                 type string,
        l_p4                 type string,
        l_t100_text          type string,
        l_server_info        type string,
        l_request_uri        type string,
        ls_ext_interface     type qname,
        ls_int_interface     type string.

  data: l_func_stack_level   type i,
        l_pload_stack_level  type i,
        l_http_method        type string,
        l_cfg                type ref to if_srt_wsp_assign_config_serv,
        l_sc_util            type ref to if_srt_wsp_rt_shortcut_util,
        lt_header_fields     type tihttpnvp.

* ---  START Trace Initialization  ---
  get run time field l_start_time.
  cl_soap_util=>set_http_instance( http_server = server ).

  cl_soap_sector=>set_sect_provider_before_async( ).

* Set WS Processing Unit and New Operation
  cl_soap_util=>set_sector_attributes(
    exporting
      sector_no     = if_soap_util_constants=>ws_provider
      new_operation = 'X'
      message_id    = space
  ).

* Get Performance Trace Info from HTTP Header
  srtid_info = server->request->if_http_entity~get_header_field( tsrc_soap_11_http_srtid ).
  split srtid_info at '/'
    into srtid_date srtid_time srtid_version srtid_aguid
         srtid_trace_level srtid_appl_id.

  trace_level = srtid_trace_level.

  data(lo_trace_context) = cl_soap_util_trace_context=>push( conv #( srtid_trace_level ) ).
  lo_trace_context->set_user( sy-uname ).

* Check and Activate Traces if required
  l_request_uri = server->request->if_http_entity~get_header_field( if_http_header_fields_sap=>request_uri ).

  lo_trace_context->set_uri( l_request_uri ).

  cl_soap_util=>init(
    exporting
      trace_level    = trace_level
      application_id = srtid_appl_id
      request_uri    = l_request_uri
  ).


* ---  END Trace Initialization  ---


  srt_util_perf_start 'Handle_Request'.                     "#EC NOTEXT

* FUNC and PLOAD Trace Request if required
  if cl_soap_util=>m_func_trace_level  is not initial or
     cl_soap_util=>m_pload_trace_level is not initial.
    cl_soap_util=>trace_payload(
      exporting
        call_type         = if_soap_util_constants=>trace_type_request
        http_server       = server
      changing
        func_stack_level  = l_func_stack_level
        pload_stack_level = l_pload_stack_level
    ).
  endif.

* simple client provider handling; HTTP 500 on invalid SCP call
  data:
    lv_text type string,
    lv_cont type abap_bool,
    lx_soap_core type ref to cx_soap_core.

  try.
    lv_cont = cl_srt_wsp_assign_config=>check_scp_call( pi_server = server iv_raise_exception = abap_true ).
  catch cx_soap_core into lx_soap_core.
    lv_cont = abap_false.
  endtry.

  if lv_cont = abap_false.
    message e924(srt_wsp) into l_t100_text.
    srt_util_set_error_location.

    if lx_soap_core is bound.
      lv_text = lx_soap_core->get_text( ).
      concatenate l_t100_text ` ` lv_text into lv_text.
    else.
      lv_text = l_t100_text.
    endif.

    cl_soap_util=>log_write(
      exporting
        main_entry  = 'X'
        short_text  = lv_text
        t100_area   = 'SRT_WSP'
        t100_msgno  = '924'
        http_server = server

    ).
    server->response->set_status( code = 500 reason = l_t100_text ).


* FUNC and PLOAD Trace Response if required
    if cl_soap_util=>m_func_trace_level  is not initial or
       cl_soap_util=>m_pload_trace_level is not initial.
      cl_soap_util=>trace_payload(
        exporting
          call_type         = if_soap_util_constants=>trace_type_response
          http_server       = server
        changing
          func_stack_level  = l_func_stack_level
          pload_stack_level = l_pload_stack_level
      ).
    endif.
    srt_util_perf_end.
    lo_trace_context->pop( ).
    return.
  endif.


* HEAD Handling
  l_http_method = server->request->get_method( ).
  if l_http_method = 'HEAD'. " ping
    l_cfg = cl_srt_wsp_assign_config=>read_server( pi_server_object = server ). "fast check

    data: lv_ping_status    type abap_bool value abap_true,
          l_transport_key   type scr_transport_key.

    if l_cfg is initial.
* check for local shortcut
      l_sc_util = cl_srt_wsp_rt_factory=>get_shortcut_utility( ).
      if l_sc_util->is_url_shortcut( server->request->get_header_field( if_http_header_fields_sap=>path_translated ) ) ne 'X'.
* no local shortcut, check for old persistence
        " slow check....
        " special handling for old persistence (IDoc configs are stored only in the old persistence)
        l_transport_key-key1 = cl_http_server=>c_virtual_host.
        l_transport_key-key2 = server->request->get_header_field(
                                if_http_header_fields_sap=>path_translated ).
        l_transport_key-key3 = if_soap_transport_context=>co_transport_id_http.
*     check if webservice key exists
        try.
            cl_srt_registry=>get_service_rt( l_transport_key ).
          catch cx_srt_registry.
            " key does not exist => ping failed
            lv_ping_status = abap_false.
        endtry.
      endif.
    endif.

    if lv_ping_status = abap_false.
*      MESSAGE e171(srt_wsp) WITH l_request_uri INTO l_t100_text.
      cl_srt_wsp_api_helper=>chop_it( exporting pi_in = l_request_uri importing pe_part1 = l_p1 pe_part2 = l_p2 pe_part3 = l_p3 pe_part4 = l_p4 ).
      message e171(srt_wsp) with l_p1 l_p2 l_p3 l_p4 into l_t100_text.
      srt_util_set_error_location.
      cl_soap_util=>log_write(
        exporting
          main_entry  = 'X'
          short_text  = l_t100_text
          t100_area   = 'SRT_WSP'
          t100_msgno  = '171'
          http_server = server
      ).
      server->response->set_status( code = 500 reason = l_t100_text ).
    endif.

* FUNC and PLOAD Trace Response if required
    if cl_soap_util=>m_func_trace_level  is not initial or
       cl_soap_util=>m_pload_trace_level is not initial.
      cl_soap_util=>trace_payload(
        exporting
          call_type       = if_soap_util_constants=>trace_type_response
          http_server     = server
        changing
        func_stack_level  = l_func_stack_level
        pload_stack_level = l_pload_stack_level
      ).
    endif.
    srt_util_perf_end.
    lo_trace_context->pop( ).
    return.
  endif. " Ping

* -0- check/init
  srt_assert_ref_bound server 1.
  m_server = server.

  "- make sure no further handlers are processed
  if_http_extension~flow_rc = if_http_extension~co_flow_ok.
  "- make sure instance can be re-executed by ICF
  if_http_extension~lifetime_rc = if_http_extension~co_lifetime_keep.

* -1- delegate
  call method handle_request( ).

*  if m_runtime is bound.
*    m_runtime->log_extended_statistics( cl_soap_runtime_root=>co_ext_stat_action_exec_end ).
*  endif.

  if m_config is bound and m_config->context is bound.
    ls_ext_interface = m_config->context->get_external_interface( ).
    ls_int_interface = m_config->context->get_internal_interface( ).
  endif.

  get run time field l_end_time.

  cl_soap_util=>performance_end(
    pmname_1    = 'Interface_Name'
    pmvalue_1   = ls_ext_interface-name
    pmname_2    = 'Interface_Namespace'
    pmvalue_2   = ls_ext_interface-namespace
    pmname_3    = 'Constructor runtime'
    pmvalue_3   = m_constructor_time
    stack_level = 1
  ).                                                        "#EC NOTEXT

  get run time field lv_commit_time.

  l_run_time = ( l_end_time - l_start_time ) / 1000.
  lv_commit_time = ( lv_commit_time - l_end_time ) / 1000.

  if m_constructor_time is not initial.
    l_run_time = l_run_time + m_constructor_time.
    clear m_constructor_time.
  endif.

  cl_soap_tool=>set_last_call_time_abap( l_run_time ).

  l_server_info = cl_soap_tool=>pack_wscall_info( server_time = l_run_time ).

  if l_server_info is not initial.
    server->response->if_http_entity~set_header_field(
      name = co_http_header_server_info
      value = l_server_info
    ).

    server->response->if_http_entity~set_header_field(
      name  = cl_soap_http_tpbnd_root=>co_http_header_server_info_ext
      value = lv_commit_time && `` ).
  endif.

* Set connection close header in case of http 500. See Incident 0120025231 0000550668 2014
  data lv_code type i.
  server->response->get_status( importing code = lv_code ).
  if lv_code = 500.
    server->response->if_http_entity~set_header_field( name  = 'Connection' value = 'close' ).  "#EC NOTEXT
  endif.

* enable compression of response
  server->response->if_http_entity~get_header_fields( changing fields = lt_header_fields ).
  read table lt_header_fields transporting no fields with key name = 'content-encoding'. "#EC NOTEXT
  if sy-subrc <> 0.
    server->set_compression( exceptions others = 99 ).
  endif.

* FUNC and PLOAD Trace Response if required
  if cl_soap_util=>m_func_trace_level  is not initial or
     cl_soap_util=>m_pload_trace_level is not initial.
    cl_soap_util=>trace_payload(
      exporting
        call_type         = if_soap_util_constants=>trace_type_response
        http_server       = server
      changing
        func_stack_level  = l_func_stack_level
        pload_stack_level = l_pload_stack_level
    ).
  endif.

  lo_trace_context->pop( ).
  cleanup.
    lo_trace_context->pop( ).
  endtry.
endmethod.  "-- IF_HTTP_EXTENSION~HANDLE_REQUEST

Using cl_http_client for calling WSDL(URL) methodicon-default.png?t=M4ADhttps://answers.sap.com/questions/9826867/using-clhttpclient-for-calling-wsdlurl-method.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

SAP爱好者

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值