Calling Web Service from Function Module

dear all
i am new to SAP.
i have a web Service developed with .net and C#.
i want to call this web Service from inside a function module.
how can i do this ?
thanks,

Hi Ramzy,
Please browse through chrome or sdn , there is a lot of documents and discussions, any how find the below URL, which might be helpful.
Create an SAP Web Service Consumer (calling External Web Service from ABAP)
Create a Function Module and full the below Code :
Sample code :
DATA: http_client TYPE REF TO if_http_client,
      host_str TYPE string VALUE 'www.myservice.in',
      service_str TYPE string,
      path TYPE string VALUE  'my path',
      errortext TYPE string. "used for error handling
DATA  : wf_string1 TYPE string,
         lw_inputs TYPE string,
         error_text type string,
         subrc TYPE SY-SUBRC,
         lw_outputs TYPE  string.
CALL METHOD cl_http_client=>create_by_url
  EXPORTING
    url                = 'myurl'
  IMPORTING
    client             = http_client
  EXCEPTIONS
    argument_not_found = 1
    plugin_not_active  = 2
    internal_error     = 3
    OTHERS             = 4.
  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 METHOD http_client->request->set_header_field
  EXPORTING
    name  = '~request_method'
    value = 'POST'.
CALL METHOD http_client->request->set_header_field
  EXPORTING
    name  = '~server_protocol'
    value = 'HTTP/1.1'.
CALL METHOD http_client->request->set_header_field
  EXPORTING
    name  = '~request_uri'
    value = 'mypath'.
CALL METHOD http_client->request->set_header_field
  EXPORTING
    name  = 'Content-Type'
    value = 'application/soap+xml; charset=utf-8'."'text/xml; charset=utf-8'.
CALL METHOD http_client->request->set_header_field
  EXPORTING
    name  = 'Content-Length'
    value = '19000'."txlen.
CALL METHOD http_client->request->set_header_field
  EXPORTING
    name  = 'SOAPAction'
    value = 'myURL'.
concatenate 'data u need sned' into wf_string
CALL METHOD http_client->request->set_cdata
  EXPORTING
    data   = wf_string1
    offset = 0
    length = '19000'.
Regards,
Lokeswar.

Similar Messages

  • Urgent: Web Service from Function Module

    Hi guys, I am new to this area so please help to achieve following:
    I want to show a demo to load data from a web service to BI. I have performed the following steps and don’t know how to process further. Please help me in the sense where do I put the logic to show fields on the web service and ….
    1. I have created a web service data source in BI with four fields (Cal dat, material, amount and currency)
    2. This created a Web Service /RFC FM automatically.
    3. From this FM I created a web service (Utilities – create web service – from function module)
    4. I followed the web service creation wizard.
    Thanks,
    sam

    releasing and related steps are fine,
    what i want to know is, BW/BI datasource will create a FM, from this FM inturn I will create a webservice.
    Lets say BW/BI datasource has 4 fields account, company, amount & currency.
    I want to enter these 4 values from the webservice which will bring these values to BW delta queue and eventually get loaded in BW.
    For this process do I need to code anything in the FM or any other part of the system

  • I generated web service from function module.Where can I find .wsdl file ?

    Hi,
    I generated web service from function module.
    Where can I find .wsdl file ?
    I want to use .wsdl file in .Net application.
    Thanks.

    Hii Cemil Bozlagan,
      All Remote enabled Function Modules in Web AS 6.20 and Above are available as Webservices and the WSDL documents are available in the web service repository at
    [http://<host>:<port>/sap/bc/bsp/sap/webservicebrowser/search.html]
    Find the respective BAPI.
    Click on the WSDL link in the browser and download the WSDL document and use it as per the requirement
    Regards,
    Varun

  • Is it possible to call web service from ABAP SAP 4.6 c..If yes how

    Hi Friends,
    Is it possible to call web service from ABAP-SAP 4.6 c..If yes Could you please let me know how.
    Thanks in Advance.
    Murali Krishna K
    Edited by: Murali Krishna Kakarla on Jan 26, 2008 7:09 PM
    Edited by: Murali Krishna Kakarla on Jan 26, 2008 7:11 PM

    Olivier CHRETIEN wrote:>
    > Hi Terry,
    >
    > So these function modules must use the SAPHTTPA RFC destination which uses the exe saphttp.exe ?
    >
    > How much abap code lines do you have for a web service call ?
    > Do you have to code the call specifically for each different web service ?
    > Are you able to use the WSDL ?
    >
    > Nice job if you have coded your own private SOAP runtime !
    >
    > But I don't think this is an easy solution for everybody...
    >
    > Regards,
    >
    > Olivier
    Yes, SAPHTTPA (runs on application server) and/or SAPHTTP (runs on front-end pc), one of which, is required for HTTP communication.  So far, nothing too elaborate as far as SOAP goes, but the logic is simplistic.  Here's some sample code:
      DEST = 'SAPHTTPA'.
      TRANSLATE HOST TO LOWER CASE.
      MYURL = 'wssrvTest/Service.asmx/GetByOrderItem'.
      CONCATENATE HOST MYURL INTO MYURL.
      REQUEST_HEADERS-DATA = 
                  'Content-type: application/x-www-form-urlencoded'.
      APPEND REQUEST_HEADERS.
      CLEAR REQUEST_HEADERS.
    *........Convert Order Number to External Format........................
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
           EXPORTING
                INPUT  = ORDER
           IMPORTING
                OUTPUT = ORDER.
    *........Convert Item Number to External Format.........................
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
           EXPORTING
                INPUT  = ITEM
           IMPORTING
                OUTPUT = ITEM.
    *........Convert Material Number to External Format.....................
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
           EXPORTING
                INPUT  = MATERIAL
           IMPORTING
                OUTPUT = MATERIAL.
      CONCATENATE 'sOrder=' ORDER
                   INTO REQUEST_BODY-DATA.
      APPEND REQUEST_BODY.
      CLEAR REQUEST_BODY.
      CONCATENATE '&sItem=' ITEM
                   INTO REQUEST_BODY-DATA.
      APPEND REQUEST_BODY.
      CLEAR REQUEST_BODY.
      CONCATENATE '&sMaterial=' MATERIAL
                  INTO REQUEST_BODY-DATA.
      APPEND REQUEST_BODY.
      CLEAR REQUEST_BODY.
      CALL FUNCTION 'HTTP_POST'
           EXPORTING
                ABSOLUTE_URI          = MYURL
                RFC_DESTINATION       = DEST
                BLANKSTOCRLF          = 'X'
           TABLES
                RESPONSE_ENTITY_BODY  = RESPONSE_BODY
                REQUEST_ENTITY_BODY   = REQUEST_BODY
                RESPONSE_HEADERS      = RESPONSE_HEADERS
                REQUEST_HEADERS       = REQUEST_HEADERS
           EXCEPTIONS
                CONNECT_FAILED        = 1
                TIMEOUT               = 2
                INTERNAL_ERROR        = 3
                TCPIP_ERROR           = 4
                DATA_ERROR            = 5
                SYSTEM_FAILURE        = 6
                COMMUNICATION_FAILURE = 7
                OTHERS                = 8.
      CHECK SY-SUBRC = 0.  "more appropriate msg goes here
      LOOP AT RESPONSE_BODY.
        IF RESPONSE_BODY+0(7) <> '<string' AND
           RESPONSE_BODY+0(8) <> '</string' AND
           RESPONSE_BODY+0(5) <> '<?xml'.
          SPLIT RESPONSE_BODY-DATA AT '=' INTO FIELD_NAME FIELD_VALUE.
          TRANSLATE FIELD_NAME TO UPPER CASE.
          CASE FIELD_NAME.
            WHEN 'HEIGHT'.
              HEIGHT = FIELD_VALUE.
            WHEN 'WIDTH'.
              WIDTH = FIELD_VALUE.
            WHEN 'LENGTH'.
              LENGTH = FIELD_VALUE.
            WHEN 'WEIGHT'.
              WEIGHT = FIELD_VALUE.
            WHEN 'QTY'.
              QTY = FIELD_VALUE.
          ENDCASE.
        ENDIF.
      ENDLOOP.
    Hope this helps...
    Terry
    Edited by: Terry West on Feb 4, 2008 3:08 PM

  • How do i call web services from SAP ABAP

    Hello,
    Ian working with .net team. they are using sap .net Connector to connect SAP. But my job is In SAP side when Purchase Requisition is created, I have to call web services from ABAP and i have to pass the Purchase Requisition number to web service(.net Program). Please help me how to call web services from ABAP and how to pass value. Any one help me with example.
    Thanks
    RaviKumar

    Hi Ravi,
    If you can call EJB from ABAP and from EJB call Web service which you want to call. I am giving code to write in EJB business method processFunction.
    public void processFunction(Function function) {
       IRepository repository;
       repository = new Repository("TestRepository");
       JCO.MetaData fmeta = new JCO.MetaData("ZTEST_EJB");
       fmeta.addInfo("REQUTEXT", JCO.TYPE_CHAR, 255,   0,  0,  
       JCO.IMPORT_PARAMETER, null);
       fmeta.addInfo("ECHOTEXT", JCO.TYPE_CHAR, 255,   0,  0,
       JCO.EXPORT_PARAMETER, null);
       fmeta.addInfo("RESPTEXT", JCO.TYPE_CHAR, 255,   0,  0,
       JCO.EXPORT_PARAMETER, null);
       repository.addFunctionInterfaceToCache(fmeta);
       JCO.ParameterList input  =
       function.getImportParameterList();
       JCO.ParameterList output =
       function.getExportParameterList();          
       JCO.ParameterList tables =
       function.getTableParameterList();
      if (function.getName().equals("ZTEST_EJB")) {
                        output.setValue(input.getCharArray("REQUTEXT"),"ECHOTEXT");
    output.setValue("This is a response " + table.getString("E_NAME") +" " + output.getName(1), "RESPTEXT");
      else if (function.getName().equals("STFC_STRUCTURE")) {
      JCO.Structure sin  = input.getStructure("IMPORTSTRUCT");
      JCO.Structure sout = (JCO.Structure)sin.clone();
      try {
          System.out.println(sin);
       catch (Exception ex) {
           System.out.println(ex);
                        output.setValue(sout,"ECHOSTRUCT");
    output.setValue("This is a response from Example5.java","RESPTEXT");
    }//if
    Here REQUTEXT, ECHOTEXT are import parameter and RESPTEXT is the Export parameter of Function module ZTEST_EJB in SAP.
    Here from this bisuness method you can call web service which you want and give back the result of webservice to ABAP F.M.
    Regards,
    Bhavik

  • How to call web services from oracle database 10g

    Hi all ,
    How can i call web services from oracle database 10g ?
    thanks ...

    abdou123 wrote:
    but how can i get complex result
    for example
    i pass input parameter like National Id Number
    and get the person details ( name , age , date of birth , ............ ) .Basic approach to web services using UTL_HTTP explained in {message:id=10448611}.
    An example of using a pipeline table function as a data transformation process (turning web data into rows and columns) in {message:id=10158148}.

  • Calling a report from function module

    Hi Friends,
    I have requirement for Function Module i.e. we will add the button to the standard T-code and ( Function added in config ) then
    Function to be called from Customizing
    Program A called from customizing function
    CalculationPDFFunction  is called from program A.
    So can any one help me the logic for "calling a report from function module  ".
    Thanks in Advance.
    Regards,
    OSReddy.
    Edited by: OSReddy on Sep 23, 2011 7:31 AM

    Hi Jaya,
    Yes. It is possible to call ur custom program using SUBMIT statement.
    1. If u have data to pass then build table type RSPARAMS and use below statement.
    data:
          rspar_tab  TYPE TABLE OF rsparams,
          rspar_line LIKE LINE OF rspar_tab,
    SUBMIT report1 WITH SELECTION-TABLE rspar_tab
                   AND RETURN.
    1. If u want to create variant to the program and use that. use the below statement .
    SUBMIT report1 USING SELECTION-SET 'VAR1' "variant
                   AND RETURN.
    Regards,
    Venkat.O

  • Is there a way to call web service from 2 servers??

    Hi,
    I need to know if its possible to call web service from 2 different servers without having load balancer??? I mean, if one of the server has heavy work on, then it should call web service from the other server.
    Thanks in advance.
    Best Regards.

    Hi,
    WebLogic Cluster has this feature ( Load Balancing & Failover ). If you will deploy your WebService to a WebLogic Cluster and then If you will put a Proxy in front of it like (Apache)...Then it is Possible.
    <h3><font color=maroon>What All You Need To Do ? ...... as following</font></h3>
    <b><font color=maroon>Step1).</font></b> Create a WebLogic Cluster (minimum two ManagedServers)
    http://weblogic-wonders.com/weblogic/2010/04/28/weblogic-clustering-in-remote-boxes/
    <b><font color=maroon>Step2).</font></b> Install a Proxy like Apache in frot of them like following:
    http://weblogic-wonders.com/weblogic/2010/05/13/apache-proxy-as-static-content-repository/
    Or
    http://weblogic-wonders.com/weblogic/2010/08/01/weblogic-httpclusterservlet-proxyserver/
    <b><font color=maroon>Step3).</font></b> Now Configure a FrontEnd Host for your Cluster by providing the ProxyServer Host name as the FrontEnd of your Cluster. This step is required to Generate the Dynamic WSDL with the Address of the Frontend.(Not of a perticular WebLogic Server)
    http://weblogic-wonders.com/weblogic/2010/06/21/configuring-frontend-host-and-port/
    <b><font color=maroon>Step4).</font></b> Deploy your WebService on the Cluster
    <b><font color=maroon>Step5).</font></b> Now Hit the WebService using the Proxy URL:
    Example:
    http://ProxyHostname:proxyPort/ServiceContextRoot/ServiceURI?WSDL
    Thanks
    Jay SenSharma

  • Calling Web service From R/3

    Hi ,
    we have a requirement, where we have to call a web service in Biz talk from SAP and compile the received data in R/3 as a report.
    has any one worked on such a requirement, could you please provide your inputs on the same.
    Thanks,
    Raghavendra

    [Calling Web service From R/3|http://forums.sdn.sap.com/search.jspa?threadID=&q=CallingWebserviceFromR/3&objID=f50&dateRange=all&numResults=15]

  • Calling web service from Obiee

    Hi,
    I want to get data from webservice and show the results in a dashboard.
    I checked http://www.artofbi.com/index.php/2009/08/consuming-a-web-service-in-obiee-presentation-services-using-jquery-cdn/ web site.
    But the author is retrieving data from a web page by sending parameter to querystring like
    yqlq=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22YHOO%22%2C%22AAPL%22%2C%22GOOG%22%2C%22MSFT%22%2C%20%22PTRY%22)&format=json&env=http%3A%2F%2Fdatatables.org%2Falltables.env&callback=?";
    But as I know we can not call web services with parameters like this.
    How can I call web service from BI?
    Could you please suggest articles or sample codes, documents etc.
    Regards,
    bye

    Hi,
    I controlled this document. The document is explaining Oracle BI web services for extracting information from Oracle BI and showing them in other environments. But I want to get results from a web service ( for example a web service which returns currency rates, weather information or sharepoint lists) and then represent them in Oracle BI Dashboards.

  • Calling Web Service from CRM using proxy

    Hi all,
    I'm facing a problem trying to call a web service from CRM (WAS 620) via XI 3.0. The response that XI recieves from the web service contains SOAP Envelope, and the mapping fails because of it. I built the proxy manually, because if I load WSDL the proxy generation in CRM generates error that sais that external definition coudn't be used.
    Is there any way to remove SOAP envelope from the response while mapping?
    Is it possible to call web service from WAS 620?
    Thanks!!!!
    Anya.

    Hi Manish,
    SOAP adapter does pass the message to XI (this message contains SOAP envelope although XI expects to get message without it), and during the mapping step i get "Runtime Exception in Message-Mapping transformatio~".
    I suppose it's because i created proxy manually. I did so because when i imported WSDL, and tried to generate proxy in CRM, i got an error message that said that proxy couldn't be generated because external definitions are only allowed in XI 3. But my XI version is 3.0! And when I generate the same proxy in my R/3 system that is installed on WAS 640, it works.
    What can I do?
    Cheers,
    Anya.

  • Calling Web Service from SAP

    Dear All,
    How can we call web service from SAP?
    Thanks in Advance,
    Ramana

    HI kcr,
    pls see this link
    http://****************/Tutorials/Others/ValidateEmailID/Webservice.htm
    write this program
    REPORT zvalidate_email.PARAMETERS: p_mail(100) LOWER CASE.                 " E-Mail id to be verifiedDATA: http_client TYPE REF TO if_http_client .DATA: w_string TYPE string ,
          w_result TYPE string ,
          r_str    TYPE string .DATA: result_tab TYPE TABLE OF string.START-OF-SELECTION .
      CLEAR w_string .
      CONCATENATE
      'http://www.webservicex.net/ValidateEmail.asmx/IsValidEmail?Email=' p_mail
    INTO
      w_string .  CALL METHOD cl_http_client=>create_by_url
        EXPORTING
          url                = w_string
        IMPORTING
          client             = http_client
        EXCEPTIONS
          argument_not_found = 1
          plugin_not_active  = 2
          internal_error     = 3
          OTHERS             = 4.  CALL METHOD http_client->send
        EXCEPTIONS
          http_communication_failure = 1
          http_invalid_state         = 2.  CALL METHOD http_client->receive
        EXCEPTIONS
          http_communication_failure = 1
          http_invalid_state         = 2
          http_processing_failed     = 3.
      CLEAR w_result .
      w_result = http_client->response->get_cdata( ).  REFRESH result_tab .
      SPLIT w_result AT cl_abap_char_utilities=>cr_lf INTO TABLE result_tab .  READ TABLE result_tab INTO r_str INDEX 2.
      IF r_str+44(1) = 't'.
        WRITE:/ 'Valid email address'.
      ELSE.
        WRITE:/ 'Invalid email address'.
      ENDIF.Output:
    thanks
    karthik

  • Calling web Service from the Custom Adapter.Is it Possible?

    Hi Experts,
                    I am having requirment in which i have to cal com.sap.aii.mapping.lookup.LookupService for calling web Service from the Custom Adapter.Is it Possible?
    Regards,
    Rajesh.D

    Hi Rajesh..
    Just looking the problem in another angle.. if there is no constraint that you have to use XI specific API to call the web service, why dont you use usual Java API used for calling a web service inside you custom adapter (I have Microsoft background.. donno exactly how it is done in Java,, but in .NET kind of a language it is possible). SInce your adapter is in Java itself and is capable of calling web service.. collect or lookup the data whatever you want and validate...
    Just a thought..
    VJ

  • Calling web service from MBean weblogic cannot find type mapping file

    When calling web service from custom MBean i get java.io.IOException.
    java.io.IOException: unable to find the type mapping resource file for:
    net.msl.sfx.ebooking.client.BookingPartiesServiceService
    at weblogic.webservice.core.encoding.DefaultRegistry.<init>(DefaultRegis
    try.java:67)
    at weblogic.webservice.core.rpc.ServiceImpl.<init>(ServiceImpl.java:83)
    at net.msl.sfx.ebooking.client.BookingPartiesServiceService_Impl.<init>(
    BookingPartiesServiceService_Impl.java:22)
    at net.msl.sfx.ebooking.service.EBookingService.getBookingParties(EBooki
    ngService.java:59)
    The types.xml file is placed in same jar file as the classes such as net.msl.sfx.ebooking.client.BookingPartiesServiceService_Impl.
    When calling the same class/method from a EJB, everything works fine and the web service is called.

    i am having the same problem.
    Do you have a solution now?
    Thanks

  • Calling web service from oracle application framework r12

    Hi Techies
    Is anybody know How to call web service from oracle application framework r12(step by step procedure),because i searched in net but i could not understand that one
    Thanks
    Dillibabu B
    Edited by: 962005 on 28 Sep, 2012 12:11 AM

    Hi,
    Check below links:
    http://oracle.anilpassi.com/oa-framework-with-captcha-webservice.html
    http://oracle.anilpassi.com/integrate-oa-framework-with-web-service.html
    https://blogs.oracle.com/ebusinesssuiteintegration/entry/r121_-invokingweb_service_fr
    --Sushant                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Maybe you are looking for

  • Package for Business Objects Explorer

    Hello, can anyone say what the "name" of the package is that we have to order to get access to ASP Business Objects Explorer software? We want to use the non accelerated version of Explorer first. I am asking here to speed up the process - I want to

  • Scheduling a job in SAP R/3 !

    Dear All For one of the requirements we need to increase the DELTA job frequency on the R/3 side. We will schedule a job for this with the report 'RMBWV317' in the background. We are fetching data from the three different clients on the same R/3 syst

  • How does Time Machine handle renamed folders

    I am trying to free up some space on my external hard drive that I back up to via Time Machine. I am browsing the backups via the TM "Star Wars" UI deleting some backups I don't need anymore. I notice I have on directory in particular that is around

  • Invalid Directory Structure Error

    So I recently purchased a Panasonic AG-HMC40 and it's my first experience with a non tape camera. When I tried to get the footage onto my computer Final Cut wouldn't recognize it. It worked in iMovie but I would rather not lose quality by transferrin

  • Question mark flashing om screen

    question mark flashing on screen.