Show TOC Start of Content Area

Procedure documentation Creating an Inside-Out Web Service from an Enterprise Java Bean  Locate the document in its SAP Library structure

Use

This procedure enables you to create inside-out Web services from Enterprise JavaBean 3.0 (EJB).

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.

Prerequisites

·        You have created an EJB project 3.0. More information: Creating EJB 3.0 Projects in the Developer Studio.

·        You have created an Enterprise Application Project and the EJB project 3.0 is added to it.

·        You have created an EJB session bean which you want to expose as a Web service and all its business methods are implemented.

·        If you want to use an existing Java interface as an SEI, it has to be available in the project.

·        You have configured the AS Java settings in Window Preferences SAP AS Java.

More information: Configuring the Application Server in the Developer Studio

·        You have configured the application server and Web service runtime in the SAP NetWeaver Developer Studio in Window Preferences Web Services Server and Runtime. In the Server field, choose SAPServer, and in the Web service runtime field, choose SAP NetWeaver.

·        Optionally, you can configure resource management settings of the SAP NetWeaver Developer Studio.

More Information: Configuring Resource Management Settings

Procedure

       1.      In the Package Explorer of the Java EE perspective, open the project and select the EJB you created.

       2.      From the context menu, choose Web Services Create Web Service.

The Web Services wizard opens.

       3.      Move the slider to the Develop service position.

       4.      From Configuration, select SAP server and SAP NetWeaver Web service runtime.

Note

It is essential that you configure SAP server and runtime settings in Window Preferences Web Services Server and Runtime prior to creating a Web service. For more information, see the prerequisites section.

       5.      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 EJB project to a service EAR project, the name of the EJB project appears in the Service EAR project field.

       6.      Choose Next.

       7.      Depending on whether you want to use an SEI, proceed as follows:

Option

Meaning

Steps

Do not use an explicit Service Endpoint Interface

The contract definition is not decoupled from the Web service implementation.

                            a.      Choose Do not use an explicit Service Endpoint Interface.

                            b.      Choose Next

                            c.      On the Web service customizations screen, change the values or accept the default ones, and then choose Next.

Note

After you deploy the Web service, you can use the value in the Wsdl URL preview field to view the WSDL document of the Web service in a Web browser. At this step, you can copy the WSDL URL so that you have it at hand.

                            d.      Choose the indicators for the methods of the implementation class which you want to expose as a Web service.

                            e.      Choose Next twice.

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.

Note

After you deploy the Web service, you can use the value in the Wsdl URL preview field to view the WSDL document of the Web service in a Web browser. At this step, you can copy the WSDL URL so that you have it at hand.

                              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.

Note

After you deploy the Web service, you can use the value in the Wsdl URL preview field to view the WSDL document of the Web service in a Web browser. At this step, you can copy the WSDL URL so that you have it at hand.

                              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 Web service.

                            h.      Choose Next.

       8.      Depending on the settings, which you provided in the Window Preferences Web Services Resource Management window, the tools prompt you to confirm creation of resources or check out of updated existing resources.

       9.      Choose Finish.

The Developer Studio adds Java EE 5 annotations for Web services to the implementation bean, as well as to the service endpoint interface, if applicable.

   10.      You can use annotations to configure the Web service.

More information: Configuring Web Services at Design Time

   11.      Build and deploy the Enterprise Application Project of the Web service on the SAP NetWeaver Application Server.

More Information: Building, Publishing and Removing Published Java EE Applications.

   12.      You can view the WSDL by entering the WSDL URL in a Web browser.

The WSDL URL comprises:

http://<host>:<http_port>/<Service_Name>/<Bean_Name>?wsdl

Example

A Web service whose EJB name is MyTestBean, has the following WSDL URL:

http://<host>:<http port>/MyTestService/MyTestBean?wsdl

As a next step, you can generate a proxy for the Web service client and implement the client application.

More information:

Creating Web Service Proxies

Creating Web Service Client Applications

More Information

More information about the mapping of the Java types to WSDL 1.1 documents or XML schemas is available in the following standard specifications:

·        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

End of Content Area