Developing a Web Service to send an email

...Previous

Give the WSDL file URL as got from SOAMANAGER 

image image

If you have any namespace, You can add it in Prefix. If you want the proxy class to be named starting with Z or Y. Give Z in the Prefix field. Or else it will ask for access key.

image

 A class will be generated.

image

Save and activate the same.

We also need a Logical Port to link the Proxy class with the Web service:

 (Logical Port was earlier  created in Tcode:LPCONFIG )

Create Logical Port: ZTRD_INTEGRATION_LP

in Tcode: SOAMANAGER.

Goto Business administration -> web service administration

image

select the Proxy class and click on apply selection.

Then under Configurations tab, select Create Logical Port.

image

Give the WSDL file path as given in Proxyclass, then click on apply settings button.

image

save the changes.

(IF you want to edit the login details go to Tcode:SICF against the URL access path given above and give the login method as Standard and login details)

Now create SE38 report program to consume the same.

REPORT  zweb_final_ws.

DATA p_direct TYPE checkbox.

DATA it_irecp TYPE zsalrtscomm_tab.
DATA wa_irecp TYPE zztt_recipeint.
DATA wa_recp  TYPE zsalrtscomm.

DATA wa_imsg    TYPE zztp_tt_message.
DATA it_imsg    TYPE zsolisti1_tab.
DATA wa_str     TYPE zsolisti1.

DATA it_ret TYPE zbapiret2_tab.
DATA wa_iret TYPE zbapiret2tab.
DATA wa_ret TYPE zbapiret2.

DATA: zproxy TYPE REF TO zco_zweb_integration .

PARAMETER: p_text   TYPE string DEFAULT 'new WS Consumed in ABAP !'.

START-OF-SELECTION.

  TRY.
      CREATE OBJECT zproxy
        EXPORTING
          logical_port_name = 'ZTRD_INTEGRATION_LP'.
      .
    CATCH cx_ai_system_fault .
  ENDTRY.
  DATA: output TYPE zzjo_web_integration_response .
  DATA: input TYPE zzjo_web_integration .
  TRY.
      wa_str-line  = p_text.
      APPEND wa_str TO it_imsg.
      wa_imsg-item   = it_imsg.
      input-imessage = wa_imsg.


      CLEAR: wa_recp.
      wa_recp-type = 'INT'.
      wa_recp-value = 'abc@xxxx.com'. "recipient e-address
      wa_recp-name = 'abc'. "name
      wa_recp-langu = 'EN'.
      APPEND wa_recp TO it_irecp.

      wa_irecp-item = it_irecp.
      input-irecipient = wa_irecp.

      CALL METHOD zproxy->zjo_web_integration
        EXPORTING
          input  = input
        IMPORTING
          output = output.

   CATCH cx_ai_system_fault .
   CATCH cx_ai_application_fault .

      IF NOT output-ereturn IS INITIAL.
        WAIT UP TO 2 SECONDS.
        SUBMIT rsconn01 WITH mode = 'INT'
               WITH output = 'X'
                AND RETURN.

        wa_iret =  output-ereturn .
        it_ret = wa_iret-item.

        LOOP AT it_ret INTO wa_ret.

          WRITE: / wa_ret-MESSAGE.
        ENDLOOP.
      ENDIF.
  ENDTRY.

Now test the web service using the report.

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image