Skip to Content

For better usage this guide is divided in four parts. In part one we choose a Web Service and save the

WSDL file on the computer. Part two deals with creating a standalone proxy. In part three we generate the Web Service Client Application

and afterwards we run the application.

To retrace this blog you need to install the SAP NetWeaver Application Server,
Java EE 5 Edition
and you need a access to the ES Workplace .

Part 1: Choose a WSDL file

Use

For creating a standalone proxy we need a WSDL file to access the Web Service. In the following we will use the “Find Customer by Address”

Web Service which you can find on the ES Workplace. The Name of this Web Service in the mySAP ERP ECC 600 backend system is ECC_CUSTOMER002QR.

Procedure

1. Open the ES Workplace: http://erp.esworkplace.sap.com/socoview .

2. Click the link Enterprise Service Index.

!https://weblogs.sdn.sap.com/weblogs/images/251739409/01_ES_Workplace_Startseite.JPG|height=347|alt=image|width=509|src=https://weblogs.sdn.sap.com/weblogs/images/251739409/01_ES_Workplace_Startseite.JPG|border=0!

3. In the browser window insert the name of the Enterprise Service: Find Customer by Address into the field Search and click Search in Enterprise Service Index.

!https://weblogs.sdn.sap.com/weblogs/images/251739409/02_WebService_Suche.JPG|height=374|alt=image|width=574|src=https://weblogs.sdn.sap.com/weblogs/images/251739409/02_WebService_Suche.JPG|border=0!

4. In the browser window you get the result of the search. Click the link Find Customer by Address.

!https://weblogs.sdn.sap.com/weblogs/images/251739409/03_Search_Results.JPG|height=220|alt=image|width=323|src=https://weblogs.sdn.sap.com/weblogs/images/251739409/03_Search_Results.JPG|border=0!

5. Now you can get detailed information about the Enterprise Service.

!https://weblogs.sdn.sap.com/weblogs/images/251739409/03_overview.JPG|height=396|alt=image|width=531|src=https://weblogs.sdn.sap.com/weblogs/images/251739409/03_overview.JPG|border=0!

6. To open the WSDL file click the link on Related Web Service Definition.

!https://weblogs.sdn.sap.com/weblogs/images/251739409/04_Related_Web_Service_DefinitionSearch_Results.JPG|height=200|alt=image|width=360|src=https://weblogs.sdn.sap.com/weblogs/images/251739409/04_Related_Web_Service_DefinitionSearch_Results.JPG|border=0!

7. Logon with your user.

!https://weblogs.sdn.sap.com/weblogs/images/251739409/05_Login_Window.JPG|height=226|alt=image|width=261|src=https://weblogs.sdn.sap.com/weblogs/images/251739409/05_Login_Window.JPG|border=0!

8. Choose File –> +Save As…+in the browser window.

!https://weblogs.sdn.sap.com/weblogs/images/251739409/06_WSDL_browser.JPG|height=319|alt=image|width=579|src=https://weblogs.sdn.sap.com/weblogs/images/251739409/06_WSDL_browser.JPG|border=0!

9. Change the file extension from XML to WSDL and choose Save.

!https://weblogs.sdn.sap.com/weblogs/images/251739409/07_save_file.JPG|height=330|alt=image|width=451|src=https://weblogs.sdn.sap.com/weblogs/images/251739409/07_save_file.JPG|border=0!

Result

The WSDL file was saved on your computer.

Part 2: Creating a standalone proxy

Use

This procedure enables you to generate a standalone Web Service proxy for consuming a Web Service using the Web Service Client wizard.

Creating a Java project

Procedure

1. Choose File –> New –> Project.

!https://weblogs.sdn.sap.com/weblogs/images/251739409/08_create_project.JPG|height=168|alt=image|width=316|src=https://weblogs.sdn.sap.com/weblogs/images/251739409/08_create_project.JPG|border=0!

2. In the pop-up window choose Java Project and click Next.

!https://weblogs.sdn.sap.com/weblogs/images/251739409/09_popup_create_project.JPG|height=324|alt=image|width=302|src=https://weblogs.sdn.sap.com/weblogs/images/251739409/09_popup_create_project.JPG|border=0!

3. Enter the project name: WsCall.

4. Choose Finish.

!https://weblogs.sdn.sap.com/weblogs/images/251739409/10_popup2_create_project.JPG|height=388|alt=image|width=327|src=https://weblogs.sdn.sap.com/weblogs/images/251739409/10_popup2_create_project.JPG|border=0!

Result

A new Java project was created.

!https://weblogs.sdn.sap.com/weblogs/images/251739409/11_overview_project.JPG|height=176|alt=image|width=340|src=https://weblogs.sdn.sap.com/weblogs/images/251739409/11_overview_project.JPG|border=0!

Importing a WSDL file

Use

The Web Service Client Wizard assists you in creating a new Web Service proxy from a WSDL file. First you have to import a WSDL file into your

Java project. To import a WSDL file follow the instructions below. You can also add a WSDL file by using drag and drop.

Procedure

1. Choose File –> Import.

!https://weblogs.sdn.sap.com/weblogs/images/251739409/12_choose_import.JPG|height=373|alt=image|width=216|src=https://weblogs.sdn.sap.com/weblogs/images/251739409/12_choose_import.JPG|border=0!

2. In the popup-window choose General –> File System and click Next.

!https://weblogs.sdn.sap.com/weblogs/images/251739409/13_choose_File_System.JPG|height=303|alt=image|width=320|src=https://weblogs.sdn.sap.com/weblogs/images/251739409/13_choose_File_System.JPG|border=0!

3. Click Browse on the next page of the wizard to select the directories from which you would like to add the WSDL file.

!https://weblogs.sdn.sap.com/weblogs/images/251739409/14_browse_wsdl.JPG|height=321|alt=image|width=437|src=https://weblogs.sdn.sap.com/weblogs/images/251739409/14_browse_wsdl.JPG|border=0!

4. On the next page select the checkbox for the WSDL file.

5. Specify the WsCall project as import destination.

6. When you have finished specifying your import options, click Finish.

!https://weblogs.sdn.sap.com/weblogs/images/251739409/15_select_wsdl.JPG|height=364|alt=image|width=432|src=https://weblogs.sdn.sap.com/weblogs/images/251739409/15_select_wsdl.JPG|border=0!

Result

The WSDL file was imported into your project.

Start the client wizard

Use

With the added WSDL file you are able to generate a Web Service proxy.

Procedure

1. Select the WSDL file from the WsCall project.

2. Press the right mouse button.

3. In the popup menu choose Web Services –> Generate Client.

!https://weblogs.sdn.sap.com/weblogs/images/251739409/16_select_generate_client.JPG|height=146|alt=image|width=400|src=https://weblogs.sdn.sap.com/weblogs/images/251739409/16_select_generate_client.JPG|border=0!

4. A wizard for creating a Web Service Client starts.

!https://weblogs.sdn.sap.com/weblogs/images/251739409/17_web_service_wizard.JPG|height=396|alt=image|width=392|src=https://weblogs.sdn.sap.com/weblogs/images/251739409/17_web_service_wizard.JPG|border=0!

5. Move the slider to the Assemble client position.

6. Check the settings in the configurations:

– Server: SAP Server

– Web service runtime: SAP Netweaver

– Client project: WsCall

!https://weblogs.sdn.sap.com/weblogs/images/251739409/18_finish_wizard.JPG|height=396|alt=image|width=392|src=https://weblogs.sdn.sap.com/weblogs/images/251739409/18_finish_wizard.JPG|border=0!

7. Choose Finish.

!https://weblogs.sdn.sap.com/weblogs/images/251739409/19_oveview_project.JPG|height=353|alt=image|width=350|src=https://weblogs.sdn.sap.com/weblogs/images/251739409/19_oveview_project.JPG|border=0!

Result

The wizard has created the Java classes in the WsCall folder.

Part 3: Creating a Web Service Client Application

Creating a new class

Use

To invoke the standalone proxy you need a new class with a main method.

Procedure

1. Choose File –> New –> Class.

!https://weblogs.sdn.sap.com/weblogs/images/251739409/20_new_class.JPG|height=123|alt=image|width=414|src=https://weblogs.sdn.sap.com/weblogs/images/251739409/20_new_class.JPG|border=0!

2. In the popup-window enter the class name: WsCall.

3. Insert the name of the package: com.sap.xi.appl.se.global.

4. Select the checkbox public static void main(String[] args) to create a main method in the class.

5. Click Finish.

!https://weblogs.sdn.sap.com/weblogs/images/251739409/21_create_new_class.JPG|height=399|alt=image|width=361|src=https://weblogs.sdn.sap.com/weblogs/images/251739409/21_create_new_class.JPG|border=0!

Result

A new class with a main method was created.

!https://weblogs.sdn.sap.com/weblogs/images/251739409/22_overview_class.JPG|height=208|alt=image|width=490|src=https://weblogs.sdn.sap.com/weblogs/images/251739409/22_overview_class.JPG|border=0!

Creating source code

Use

To invoke the standalone proxy you have to create instances, insert authentication and set the values for the request. The complete source code of

the class is also available at the end of this chapter.

Procedure

1. Insert the imports.

Result

The source code for invoking the standalone proxy is created.

Complete source code for the class WsCall

Here is the complete source code for the class WsCall. You can copy it and paste it into the class file. Before running the program

change the settings for username “yourUser” and password “yourPassword” in the source code.

Part 4: Run the application

Use

To test the Web Service Client you have to run the application. The result is displayed in the console view. The console view is

accessible from Windows –> Show View –> Console.

Procedure

1. Select the class WsCall.

2. Choose Run –> Run As –> Java Application.

!https://weblogs.sdn.sap.com/weblogs/images/251739409/23_run_appl.JPG|height=187|alt=image|width=441|src=https://weblogs.sdn.sap.com/weblogs/images/251739409/23_run_appl.JPG|border=0!

Result

The result of the Web Service call is displayed in the console.

image

To report this post you need to login first.

7 Comments

You must be Logged on to comment or reply to a post.

  1. Amol Joshi
    Hi Boris,

    I guess the concepts and implementation of Web services for different versions of NetWeaver must not be different and that is why this question.

    I am on NW04 SP 15 and have created a standalone proxy for a WSDL for a XI message interface. The code for setting the proxy host and port and credentials is based on guidelines from help.sap.com, involving classes BaseGeneratedStub, SecurityProtocol and AuthenticationContext. Ref http://help.sap.com/saphelp_nw04/helpdata/en/ab/c955e2e2d24a888127f211f2d5043f/content.htm

    How different is the usage of these classes as compared to the step 3 you have mentioned <3. Insert the proxy settings when they are necessary.> and which one is recommended.

    Regards,
    Amol

    (0) 
    1. Vladimir Savchenko
      Hi,
      The difference comes from the fact that the example shows how to comsume Web Services using Java EE 5. With NW04, the programming model is a derivation from JAX-RPC 1.1, and therefore the difference.
      I hope this helps.

      Nevertheless, applications developed with NW04/s will work in the same manner on the Java EE 5 edition server

      Regards, Vladimir

      (0) 
  2. Enrique Yaptenco
    If I am not mistaken, the code above demonstrates authentication using web service authentication. How do we do basic authentication using the proxies generated?

    (0) 
  3. Enrique Yaptenco
    Could you give us a code sample where MYSAPSSO2 cookie is used instead of username and password?

    Assume the application already has the SSO ticket.

    Regards,

    Enrique

    (0) 

Leave a Reply