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

      An EJB project 3.0 is created. More information: Creating EJB 3.0 Projects in the Developer Studio.

      An Enterprise Application Project is created and the EJB project 3.0 is added to it.

      An EJB session bean is created for a Web service.

      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 SAPServer, and in the Web service runtime field, choose SAP NetWeaver.

Procedure

       1.      Add business methods to the EJB 3.0 implementation bean.

       2.      In the Package Explorer of the Java perspective, open the project and select the EJB 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.

       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 EJB project to a service EAR project, the name of the EJB 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.

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

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

       9.      You can use annotations to configure the Web service. More information: Configuring Web Services at Design Time.

   10.      Build and deploy the Web service on the SAP NetWeaver Application Server. More Information: Building, Publishing and Removing Published Java EE Applications.

   11.      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 about creating Web service proxies: Creating Web Service Proxies. More information about creating client applications: Creating Web Service Client Applications.

More information:

      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