sap pi web servisinden kullanıcı adı ve şifreyi kaldırma yöntemi

merhaba, sanırım güvenlik nedeniyle sap pi sistemi üzerinden oluşturulan web servislerden kullanıcı adı ve şifreyi kaldıramıyoruz. bunu yapabilmek için araya bir katman yerleştirmemiz gerekiyor. bu katmanı araya koyarak web servisin uç noktasını da değiştirmiş oluyoruz. çalışmanın sonunda elde edeceğimiz uç noktası şu şekilde olacak; http://[domain]:50000/sap/bc/icf/[servis adı]

şimdi bunun nasıl yapıldığını anlatayım. öncelikle sicf işlem koduna girilip service path alanına /sap/bc/icf/ yazılarak çalıştırılır. daha sonra bu düğümün altında yeni bir servis oluşturulur. bu web servisin çağırılacağı yerden kullanıcı adı şifre istememek için kullanıcı adı ve şifre bilgileri yazılır. handler list tabına da oluşturacağımız sınıfın adı yazılır. son olarak servis aktif edilir.

 

pi1

pi2

pi3

 

se24 işlem koduna girilirek z’li sınıf oluşturulur. interface tabına IF_HTTP_EXTENSION arayüzü eklenir. daha sonra interface aracılığıyla gelen IF_HTTP_EXTENSION~HANDLE_REQUEST metoduna istenilen kod yazılır. kod içerisinden pi web servisine şifreli erişileceği için bu şifreyi saklamak gerekir. bu şifreyi saklamanın yöntemi de rfc destination tanımlamaktır. sm59 işlem koduna girerek rfc destination oluşturulur ve aşağıdaki kod methodun içine yazılır. hepsi bu kadar.

pi4

pi5

 

METHOD if_http_extension~handle_request.
 
  DATA: lv_client       TYPE REF TO if_http_client,
        soap_body       TYPE string,
        lv_val          TYPE string,
        lv_len          TYPE i,
        req_data        TYPE string,
        req_datax       TYPE xstring,
        lt_headers      TYPE tihttpnvp,
        lv_contenttype  TYPE string.
 
 
  server->request->get_header_fields( CHANGING fields = lt_headers ).
  server->request->get_header_field( EXPORTING name = 'Content-Type' RECEIVING value = lv_contenttype ).
  req_data = server->request->get_cdata( ).
  req_datax = server->request->get_data( ).
 
  lv_len = strlen( req_data ).
 
  CALL METHOD cl_http_client=>create_by_destination
    EXPORTING
      destination              = 'EFATURA_WEBSERVICE'
    IMPORTING
      client                   = lv_client
    EXCEPTIONS
      argument_not_found       = 1
      destination_not_found    = 2
      destination_no_authority = 3
      plugin_not_active        = 4
      internal_error           = 5
      OTHERS                   = 6.
 
  lv_val = '/XIAxisAdapter/MessageServlet?senderParty=&senderService=XXXX&receiverParty=&receiverService=&interface=XXXX&interfaceNamespace=XXXXX'.
  lv_client->request->set_header_field( name = '~request_uri' value = lv_val ).
  lv_client->request->set_header_field( name  = '~request_method' value = 'POST' ).
  lv_client->request->set_header_field( name  = '~server_protocol' value = 'HTTP/1.1' ).
*  lv_client->request->set_header_field( name = 'Content-Type' value = 'text/xml;charset=UTF-8' ).
  lv_client->request->set_header_field( name = 'Content-Type' value = lv_contenttype ).
  lv_client->request->set_header_field( name = 'Connection' value = 'Keep-Alive' ).
  lv_client->request->set_header_field( name = 'Accept-Encoding' value = 'gzip' ).
 
*  CLEAR lv_val.
*  MOVE: lv_len TO lv_val.
*  lv_client->request->set_header_field( name = 'Content-Length' value = lv_val ).
*  lv_client->request->set_header_field( name = 'SOAPAction' value = 'http://sap.com/xi/WebService/soap1.1' ).
 
*  lv_client->request->set_cdata( data = req_data ).
  lv_client->request->set_data( data = req_datax ).
 
* Get request:
  CALL METHOD lv_client->send
    EXCEPTIONS
      http_communication_failure = 1
      http_invalid_state         = 2
      http_processing_failed     = 3
      OTHERS                     = 4.
 
* Prepare client-receive:
  CALL METHOD lv_client->receive
    EXCEPTIONS
      http_communication_failure = 1
      http_invalid_state         = 2
      http_processing_failed     = 3
      OTHERS                     = 4.
 
* Get data
  CLEAR soap_body.
  soap_body = lv_client->response->get_cdata( ).
 
  CLEAR lv_contenttype.
  lv_client->response->get_header_field( EXPORTING name = 'Content-Type' RECEIVING value = lv_contenttype ).
  CALL METHOD server->response->set_header_field( name = 'Content-Type' value = lv_contenttype ).
  CALL METHOD server->response->set_cdata( data = soap_body ).
 
ENDMETHOD.