This procedure enables you to create inside-out Web services from pure non-abstract Java classes. Note, that you cannot create Web services from servlet Java classes.
When creating an inside-out Web service, you can use a service endpoint interface(SEI) to expose some or all methods of the implementation bean as a Web service. More information: Service Endpoint Interface.
● A Dynamic Web Project is created. More information: Creating Dynamic Web Projects 2.5.
● A pure Java class for a Web service is created. The class resides in the Dynamic Web Project.
● An Enterprise Application Project is created and the Dynamic Web Project is added to it.
● If you want to use an existing Java interface as an SEI, it has to be available in the project.
● The AS Java settings are configured in Window → Preferences → SAP AS Java.
● The application server and Web service runtime are configured in the SAP NetWeaver Developer Studio from Window → Preferences → Web Services → Server and Runtime. In the Server field, choose SAP Server, and in the Web service runtime field, choose SAP NetWeaver.
1. Add business methods to the implementation bean.
2. In the Package Explorer of the Java perspective, open the project and select the implementation bean you have created.
3. From the context menu, choose Web Services → Create Web Service.
The Web Services wizard opens.
4. Move the slider to the Develop service position.
At a later step in this procedure, this will enable you to customize the servlet endpoint’s URL pattern by updating the web.xml file of the Web Module. Customizing the URL pattern is optional.
5. From Configuration, select SAP server and SAP NetWeaver Web service runtime.
6. Make sure that the service project and service EAR project are set correctly.
To set the name of the service EAR project, proceed as follows:
a. Under Configuration, choose Service EAR project.
The Specify Service Project Settings dialog box opens.
b. In the Service EAR project field, choose the correct service EAR project, and then choose OK.
If you have added the Dynamic Web project to a service EAR project, the name of the Dynamic Web project appears in the Service EAR project field.
7. Depending on whether you want to use an SEI, proceed as follows:
Option |
Meaning |
Steps |
Do not use SEI |
The contract definition is not decoupled from the Web service implementation. |
a. Choose Do not use SEI. b. Choose Next. c. On the Web service customizations screen, change the values or accept the default ones, and then choose Next. d. Choose the indicators for the methods of the implementation class which you want to expose as a Web service. e. Choose Next. |
Specify Existing Interface |
You create the Web service against a Java interface (the SEI) available in advance. The SEI contains the methods of the implementation class which you want to expose as a Web service. |
... a. Choose Specify existing interface. b. Choose Browse. c. Choose the service endpoint interface you want to use, and then choose OK. d. Choose Next. e. On the Web service customizations screen, change the values or accept the default ones, and then choose Next. f. Choose Next. |
Create new interface |
The Developer Studio creates a Java interface (the SEI) containing the methods, which you choose to expose. |
... a. Choose Create new interface. b. Enter a name for the SEI. c. If necessary, change the SEI package and the folder where the Developer Studio should create the SEI. d. Choose Next. e. On the Web service customizations screen, change the values or accept the default ones, and then choose Next. f. If the implementation class extends a superclass whose methods you also want to expose, choose Show superclass methods. g. Choose the indicators for the methods of the implementation class and/or its superclass which you want to expose as a Web service. h. Choose Next. |
8. Choose Finish.
The Developer Studio adds Java EE 5 annotations for Web services to the Java class, as well as to the service endpoint interface, if applicable.
Optionally, you can customize the servlet endpoint’s URL pattern. Proceed as follows to apply additional settings to the Web module:
a. Open the web.xml file of the Web module.
b. On the Source tab page, add the entries as shown in the code excerpt below. These changes add the servlet and servlet-mapping entries that reference the Java class and enable you to optionally customize the servlet’s URL pattern.
... <display-name>ProjectName</display-name> <servlet> <description></description> <!-- Free text name of the servlet, for example myServlet --> <servlet-name>ServletName</servlet-name> <!-- The name, including the package, of the Java class serving as a servlet endpoint, for example com.sap.demo.myServlet --> <servlet-class>Package.ServletName</servlet-class> </servlet> <servlet-mapping> <!-- Free text name of the servlet, for example myServlet --> <servlet-name>ServletName</servlet-name> <!-- Free text string which identifies the URL pattern on which the servlet endpoint will be available --> <url-pattern>/MyURLPattern</url-pattern> </servlet-mapping>
<welcome-file-list> ... </welcome-file-list> |
c. Save the file and build the project.
d. Deploy the Web service on the SAP NetWeaver Application Server. More Information: Building, Publishing and Removing Published Java EE Applications.
To invoke the servlet, in a new Web browser enter the following data:
http://<server>:<http port>/<webproject name>/<url-pattern>
If you have not customized the URL pattern, then you can invoke the servlet by using the following URL:
http://<server>:<http port>/<webproject name>/<servlet name>
9. You can view the WSDL by entering the WSDL URL in a Web browser.
A WSDL URL comprises:
http://<host>:<http port>/<Service contextRoot>/<BindingData url>?wsdl
To find the service context root and binding data URL information for a Web service deployed on the server, proceed as follows:
a. Connect to the server over Telnet. More information: Administration Using Telnet.
b. Execute the following commands:
ADD WEBSERVICES
LIST_WS
In Telnet, you receive the following information about a Web service deployed on the server:
Application: sap.com/ConverterEJBEAR
Service: ConverterService
Service contextRoot: ConverterService
BindingData: ConverterLocalBinding
BindingData url: /ConverterBean
A Web service whose service context root and binding data URL are ConverterService and /ConverterBean respectively has the following WSDL URL:
http://<host>:<port>/ConverterService/ConverterBean?wsdl
● Creating Web Service Proxies.
● Java → WSDL mapping:
○ JAX-WS 2.0 specification (http://jcp.org/aboutJava/communityprocess/pfd/jsr224/index.html)
■ Chapter 3: Java to WSDL 1.1 Mapping
● Java → Schema mapping
○ JAXB 2.0 specification (http://jcp.org/aboutJava/communityprocess/final/jsr222/index.html)
■ Chapter 8: Java Types to XML