Show TOC

Creating an Inside-Out Web Service from a Java ClassLocate this document in the navigation structure

Use

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 java class as a Web service. More information: Service Endpoint Interface .

Prerequisites
  • You have created a Dynamic Web Project.

    For more information, see: Creating Dynamic Web Projects 2.5 .

  • You have created an Enterprise Application Project is created and the Dynamic Web Project is added to it.

  • You have created a pure Java class, which you want to expose as a Web service and all its business methods are implemented. The class resides in the Dynamic Web Project.

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

  • You have configured the AS Java settings in Window Start of the navigation path   Next navigation step  SAP AS Java End of the navigation path.

    For more information, see: 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 Start of the navigation path Window Next navigation step Preferences  Next navigation step  Web Services  Next navigation step  Server and Runtime End of the navigation path. In the Server field, choose SAP Server , and in the Web service runtime field, choose SAP NetWeaver .

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

    For more information, see: Configuring Resource Management Settings .

Procedure
  1. In the PackageExplorer of the Java EE perspective, open the project and select the implementation bean you have created.

  2. From the context menu, choose Start of the navigation path Web Services Next navigation step Create Web Service End of the navigation path.

  3. The Web Services wizard opens.

  4. Move the slider to the Develop service position.

    Note

    At a later stage 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.

    Note

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

  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:

    1. Under Configuration , choose Service EAR project.

      The Specify Service Project Settings dialog box opens.

    2. 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. Choose Next .

  8. When you want to use a SEI you have to configure it. For more information, see Choosing a Service Endpoint Interface Options .

  9. Depending on the settings, which you provided in the Start of the navigation path Window Next navigation step Preferences Next navigation step Web Services Next navigation step Resource Management End of the navigation path window, the tools prompt you to confirm creation of resources or check out of updated existing resources.

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

    To customize Web service endpoint's URL pattern, proceed with the following procedure: Customizing Web Service Endpoint .

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

    For more information, see: Configuring Web Services at Design Time

  12. Deploy the Web service on the SAP NetWeaver Application Server.

    For more information, see: 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>

    Note

    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>

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

    The Finding Service Context section below explains how to find the service context root and binding data URL information for a Web service deployed on the server.

Finding Service Context

  1. Connect to the server over Telnet.

    For more information, see: Administration Using Telnet .

  2. Execute the following commands:

    ADD WEBSERVICES

    LIST_WS

    Example

    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

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:

  • For Java WSDL mapping, see JAX-WS 2.0 specification, Chapter 3: Java to WSDL 1.1 Mapping: http://jcp.org/aboutJava/communityprocess/final/jsr222/index.html

  • For Java Schema mapping, see JAXB 2.0 specification, Chapter 8: Java Types to XML:

    http://jcp.org/aboutJava/communityprocess/final/jsr222/index.html