exposing webserivce through java.pdf
Embed Size (px)
TRANSCRIPT
-
8/17/2019 exposing webserivce through java.pdf
1/12
GUIDE TO CREATE A WEB SERVICE FROM A JAVA CLASS
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
© 2007 SAP AG 1
GUIDE TO CREATE A WEB SERVICE FROM A JAVA CLASS
Appl ies to:
SAP NetWeaver Developer Studio 7.0.11
Summary
Using this document anyone can easily create a Web Service from a java class in SAP NetWeaver; just youhave to fellow these steps.
Author : Rajes Ghosh
Company: HCL Technologies Ltd
Created on: 6 June 2007
Author Bio
Rajes Ghosh is working as a SAP NetWeaver Consultant for HCL Technologies Ltd.
-
8/17/2019 exposing webserivce through java.pdf
2/12
GUIDE TO CREATE A WEB SERVICE FROM A JAVA CLASS
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
© 2007 SAP AG 2
Table of Contents
Applies to: ........................................................................................................................................ 1
Summary.......................................................................................................................................... 1
Author Bio ........................................................................................................................................ 1
STEPS TO FELLOW ....................................................................................................................... 3
1. CREATE A JAVA PROJECT....................................................................................................... 3
2. CREATE PACKAGE & JAVA CLASS ......................................................................................... 3
3. CONSTRUCT REQUIRED METHOD ......................................................................................... 4
4. OPEN WEB SERVICE PERPECTIVE......................................................................................... 4
5. CREATE WEB SERVICE ............................................................................................................ 5
6. PROVIDE WEB SERVICE NAME, CONFIGURATION TYPE & CONFIGURATION NAME...... 5
7. SELECT THE REQUIRED METHOD TO EXPOSE AS WEB SERVICE .................................... 6
8. PROVIDE VIRTUAL INTERFACE & WEB SERVICE DEFINATION NAME............................... 6
9. BUILD EAR FILE ......................................................................................................................... 7
10. DEPLOY THE EAR FILE........................................................................................................... 7
11. DEPLOYMENT FINISHED ........................................................................................................ 7
12. OPEN WEB SERVICE NEVIGATOR TAB & REFRESH .......................................................... 8
13. OPEN THE WEB SERVICE ...................................................................................................... 8
14. TEST THE WEB SERVICE ....................................................................................................... 9
15. TEST INPUT SCREEN............................................................................................................ 10
16. OUTPUT SCREEN .................................................................................................................. 10
17. REQUEST SOAP XML MESSAGE......................................................................................... 11
18. RESPONSE SOAP XML MESSAGE ...................................................................................... 11 Related Content............................................................................................................................. 11
Disclaimer and Liability Notice....................................................................................................... 12
-
8/17/2019 exposing webserivce through java.pdf
3/12
GUIDE TO CREATE A WEB SERVICE FROM A JAVA CLASS
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
© 2007 SAP AG 3
STEPS TO FELLOW
1. CREATE A JAVA PROJECT
Here we are creating the java project in SAP NetWeaver Developer Studio to create a java class. In that javaclass we will write down a method to expose that as web service.
2. CREATE PACKAGE & JAVA CLASS
Here we are declaring the a package to create the java class and also creating the java class as‘MyEMIClaculator ”.
-
8/17/2019 exposing webserivce through java.pdf
4/12
GUIDE TO CREATE A WEB SERVICE FROM A JAVA CLASS
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
© 2007 SAP AG 4
3. CONSTRUCT REQUIRED METHOD
Here EMICalculation is the required method in class MyEMICalculator , which we are going to expose as
Web Service.
4. OPEN WEB SERVICE PERPECTIVE
Open the Web Service Perspective by Clicking the Web ServicePerspective Icon pointed out in the picture.
-
8/17/2019 exposing webserivce through java.pdf
5/12
GUIDE TO CREATE A WEB SERVICE FROM A JAVA CLASS
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
© 2007 SAP AG 5
5. CREATE WEB SERVICE
This is the Web Service Perspective.
Click on the New Web Service
Menu to get the Web service creationwidget.
6. PROVIDE WEB SERVICE NAME, CONFIGURATION TYPE & CONFIGURATION
NAME
This is the Web Service Creation Widget.
Enter the Web Service name, Configuration type &Configuration name.
Click Next button.
In configuration type, you will get 3 options. Herewe are taking simple soap for simplicity.
-
8/17/2019 exposing webserivce through java.pdf
6/12
GUIDE TO CREATE A WEB SERVICE FROM A JAVA CLASS
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
© 2007 SAP AG 6
7. SELECT THE REQUIRED METHOD TO EXPOSE AS WEB SERVICE
Select the method to expose as a Web service. Here
we are selecting one method. If java class has moremethod and if required then you can select morethan one method,
Click Next button.
8. PROVIDE VIRTUAL INTERFACE & WEB SERVICE DEFINATION NAME
Here we are entering the Virtual Interface and Webservice definition name.
You can just click to Finish button with the defaultvalues.
It is advisable that keep the default name.
-
8/17/2019 exposing webserivce through java.pdf
7/12
GUIDE TO CREATE A WEB SERVICE FROM A JAVA CLASS
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
© 2007 SAP AG 7
9. BUILD EAR FILE
In Java Explorer, you can see that virtual interface, web service definition & web service configuration hasbeen created.
Click on the Build EAR menu by right click to create the EAR file.
10. DEPLOY THE EAR FILE
Select the EAR file and right click on it. You will getDeploy menu.
Click on the Deploy menu to deploy it in J2EE Engine.
11. DEPLOYMENT FINISHED
You will get a message in Deploy OutputView that deployed finished message. Ifthere is any error then you will get thatinformation also.
-
8/17/2019 exposing webserivce through java.pdf
8/12
GUIDE TO CREATE A WEB SERVICE FROM A JAVA CLASS
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
© 2007 SAP AG 8
12. OPEN WEB SERVICE NEVIGATOR TAB & REFRESH
After deployment if we Refresh the Local Serverthen you will find that new Web Service will beadded into the list.
13. OPEN THE WEB SERVICE
WS_MyEMICalculator is the new Web Serviceadded in the list as in pointed out in picture.Open this Web Service.
-
8/17/2019 exposing webserivce through java.pdf
9/12
GUIDE TO CREATE A WEB SERVICE FROM A JAVA CLASS
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
© 2007 SAP AG 9
14. TEST THE WEB SERVICE
Click on Test link to test the web service.
Test Screen
Click on the Method Name “EMICalculation” to test it.
-
8/17/2019 exposing webserivce through java.pdf
10/12
-
8/17/2019 exposing webserivce through java.pdf
11/12
GUIDE TO CREATE A WEB SERVICE FROM A JAVA CLASS
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
© 2007 SAP AG 11
17. REQUEST SOAP XML MESSAGE
Request is gone to the web service as a XML. Here we are showing the request XML message.
18. RESPONSE SOAP XML MESSAGE
Response is come from web service also as a xml message. So here is the response xml message.
Related Content
Please refer to this web page if you want to know more.
http://help.sap.com/saphelp_nw04/helpdata/en/30/581e3e6217b40be10000000a114084/frameset.htm
http://help.sap.com/saphelp_nw04/helpdata/en/30/581e3e6217b40be10000000a114084/frameset.htmhttp://help.sap.com/saphelp_nw04/helpdata/en/30/581e3e6217b40be10000000a114084/frameset.htm
-
8/17/2019 exposing webserivce through java.pdf
12/12
GUIDE TO CREATE A WEB SERVICE FROM A JAVA CLASS
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
© 2007 SAP AG 12
Disclaimer and Liabili ty Notice
This document may discuss sample coding or other information that does not include SAP official interfacesand therefore is not supported by SAP. Changes made based on this information are not supported and canbe overwritten during an upgrade.
SAP will not be held liable for any damages caused by using or misusing the information, code or methodssuggested in this document, and anyone using these methods does so at his/her own risk.
SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content ofthis technical article or code sample, including any liability resulting from incompatibility between the contentwithin this document and the materials and services offered by SAP. You agree that you will not hold, orseek to hold, SAP responsible or liable with respect to the content of this document.