Thursday, February 3, 2011

Consuming Web Service with WSDL file through BSP

Sending SMS to Mobile

Scenario: Consuming WSDL file through BSP which involves the proxy development.

Proxy generation

Step1: Go to SE80 transaction, select the package and right click on package create enterprise service/web service and right click and select on proxy object.

Step2: User has option to select the WSDL sources, select local file click on continue. User has option to select the WSDL file. (To download the WSDL file used in this scenario, click here)

Step3:Next is port selection, select the sendsmssoap.

Stpe4: Give the package name and also prefix

Step5: Save and activate the application, Proxy was generated.

Step6: Go to SE24 and check the class name, a method was created with import and export parameters. In BSP application call the method which was generated and with this we can send SMS to mobile. We can also check the status of application whether message is delivered or not.

Creation of BSP application and consuming the web-service.

Step1: Go to SE80 transaction and create a BSP application

Step2: Give the short description of application and assign package to application.

Step3: Right-click on application name and create a page.



Step4: Give the page name and description

Step5: Layout code:

<%@page language="abap" %>
<%@extension name="htmlb" prefix="htmlb" %>
content design="design2003" >
title="First page " >
form>


text = "Mobile No"
design =
"EMPHASIZED" />
id = "mob"
value = "<%= w_mobno %>"
size = "12" />
<
br>
text = "Mail ID"
design =
"EMPHASIZED" />
id = "mail"
value = "<%= w_mail %>" />
<
br>
text = "Message"
design =
"EMPHASIZED" />
id = "msg"
value = "<%= w_msg %>"
size = "12" />
<
br>
<
br>
button text = "Send SMS"
id = "get"
onClick = "OnInputProcessing" />
<%
if fl_flag eq 1.
%>
<%
if t_ou is not initial.
%>
<
center>
<
font face=verdana style="font-size:12px" color ="#228B22"> <%= t_ou-SEND_SMSTO_INDIA_result-FROM_EMAIL_ADDRESS%>
<
br><%= t_ou-SEND_SMSTO_INDIA_result-MOBILE_NUMBER%>
<
br><%= t_ou-SEND_SMSTO_INDIA_result-PROVIDER%>
<
br><%= t_ou-SEND_SMSTO_INDIA_result-STATE%>
<
br><%= t_ou-SEND_SMSTO_INDIA_result-STATUS%> b>h6>center>
<%
endif.
%>
<%
Endif.
%>


form>

content>

Step6:

OnInPutProcessing Code:

* event handler for checking and processing user input and
* for defining navigation
data:
w_event
type ref to cl_htmlb_event,
w_obj
type ref to object,
w_inputfield
type ref to cl_htmlb_inputfield.


call method cl_htmlb_manager=>get_event
exporting
request = runtime->server->request
receiving
event = w_event.
case w_event->id.
when 'get'.
CALL METHOD cl_htmlb_manager=>get_data
EXPORTING
request = runtime->server->request
name =
'inputfield'
id = 'mob'
RECEIVING
data = w_obj.
w_inputfield ?= w_obj.
w_mobno = w_inputfield->value.

w_input = w_mobno.
clear w_obj.

CALL METHOD cl_htmlb_manager=>get_data
EXPORTING
request = runtime->server->request
name =
'inputfield'
id = 'mail'
RECEIVING
data = w_obj.
w_inputfield ?= w_obj.
w_mail = w_inputfield->value.

w_input = w_mail.
clear w_obj.

CALL METHOD cl_htmlb_manager=>get_data
EXPORTING
request = runtime->server->request
name =
'inputfield'
id = 'msg'
RECEIVING
data = w_obj.
w_inputfield ?= w_obj.
w_msg = w_inputfield->value.

w_input = w_msg.
clear w_obj.

data:
tv
type REF TO ZTCO_SEND_SMSSOAP ,
t_in
type ZTSEND_SMSTO_INDIA_SOAP_IN,
t_in1
type REF TO ZTSEND_SMSTO_INDIA_SOAP_IN,
t_inn
like standard table of t_in.

TRY.
CREATE OBJECT tv
* EXPORTING
* logical_port_name =
.
CATCH cx_ai_system_fault .
ENDTRY.

t_in-MOBILE_NUMBER = w_mobno.
t_in-FROM_EMAIL_ADDRESS = w_mail.
t_in-
MESSAGE = w_msg.*

APPEND t_in to t_inn.

TRY.
CALL METHOD tv->send_smsto_india
EXPORTING
input = t_in
IMPORTING
output = t_ou
.
CATCH cx_ai_system_fault .
CATCH cx_ai_application_fault .
ENDTRY.
if t_ou is not initial.
fl_flag =
1.
endif.

endcase.

Page attributes:

fl_flag TYPE I

t_ou TYPE ZTSEND_SMSTO_INDIA_SOAP_OUT

w_input TYPE STRING

w_mail TYPE ZTSEND_SMSTO_INDIA_SOAP_IN-FROM_EMAIL_ADDRESS

w_mobno TYPE ZTSEND_SMSTO_INDIA_SOAP_IN-MOBILE_NUMBER

w_msg TYPE ZTSEND_SMSTO_INDIA_SOAP_IN-MESSAGE

OUPUT:

Give the mobile number, mailid and message and click on button.

Output is as follows with the mobile-no, mailid, service provider, place and status of message (Message is delivered or not delivered)




No comments:

Tutorials on SAP-ABAP

Adobe Interactive Forms Tutorials

Business Server Pages (BSP)

Userexits/BADIs

Web Dynpro for ABAP (Step by step procedure for web dynpro,Tutorials on Web Dynpro,)

ALV Tutorials

Blog Archive

goodsites