Skip to end of metadata
Go to start of metadata

Part 1: Browse ES Workplace and select ECC_CUSTOMER002QR WSDL
The tutorial is developed with SAP NetWeaver Java EE 5. 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:

For detailled and pictured descritption see the following weblog .

1. Navigate to SDN ES Workplace homepage http://erp.esworkplace.sap.com/socoview.

2. Click the link Enterprise Service Index.

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.

4. In the browser window you get the result of the search. Click the link Find Customer by Address.
5. Now you can get detailed information about the Enterprise Service.
6. To open the WSDL file click the link on Related Web Service Definition.
7. Logon with your user.

8 Copy the link http://erp.esworkplace.sap.com/sap/bc/srt/xip/sap/ECC_CUSTOMER002QR?sap-client=800&wsdl=1.1 to your clipboard. Otionally you may save the WSDL locally in your file system. Eclipse based NetWeaver Developer Studio NWDS can handle both ways.

Part 2: Test the WSDL

1. Open theES Workplace http://erp.esworkplace.sap.com/ in your Browser and click on Web Service Navigator.

2. Enter the WSDL, click next and logon with your credentials.

3. Click on "Test" in the navigation pane.

4. You see the Request Test Page for the wsdl:portType name="CustomerSimpleByNameAndAddressQueryResponse_In"

5. Enter e.g. "Julia" into xsd:element name="FirstLineName" and click "Send" button.

6. You will receive a Response list of customers. Look carefully at the nested structure of the Web Service reuest and response. We will need it for programming in the next part.

Part 3: 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.

2. In the pop-up window choose Java Project and click Next.
3. Enter the project name: Customer.
4. Choose Finish.

As a Result a new Java Project (for JDK 1.5) is created.

5. Create a new Web Service Client. Choose File -> New -> Other --> Web Service Client.

6. In the popup wizard enter the WSDL-URL and choose "Deploy Client" in the slider on the left (however you may choose whatever you like, it has no influence in this project type.

7. Choose "SAP NetWeaver" as Web Service Runtime instead of "Apache Axis". Otherwise you will not be able to "SAP Global datatypes", You will need them for the rather complex business data types.

8. Choose finish, a Java Proxy is generated.

Part 4: 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.

2. In the popup-window enter the class name: MyCustomer.
3. Insert the name of the package: com.sap.tutorial . You may also choose com.sap.xi.appl.se.global. This has the advantage, that you do not need to import the generated SAP Java Proxy by import statement.
4. Select the checkbox public static void main(String[] args) to create a main method in the class.
5. Click Finish.

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.

Coding

import java.util.List;

import javax.xml.ws.BindingProvider;

import com.sap.xi.appl.se.global.CustomerSimpleByNameAndAddressQueryMessage_SyncType;
import com.sap.xi.appl.se.global.CustomerSimpleByNameAndAddressQueryResponseIn;
import com.sap.xi.appl.se.global.CustomerSimpleByNameAndAddressQueryResponseInService;
import com.sap.xi.appl.se.global.CustomerSimpleByNameAndAddressResponseMessage_SyncType;
import com.sap.xi.appl.se.global.OrganisationNameType;
import com.sap.xi.appl.se.global.CustomerSimpleByNameAndAddressQueryMessage_SyncType.CustomerSimpleSelectionByNameAndAddressAnonymous;
import com.sap.xi.appl.se.global.CustomerSimpleByNameAndAddressResponseMessage_SyncType.CustomerAnonymous;

/**
* @author
*
*/
public class MyECCCustomer {
/**
* Author: Oliver Stiefbold, NetWeaver Product Management
*/
public static void main(String[] args) {
try {
// create service: CustomerSimpleByNameAndAddressQueryResponse_In
CustomerSimpleByNameAndAddressQueryResponseInService service = new CustomerSimpleByNameAndAddressQueryResponseInService();
// create SOAP binding
CustomerSimpleByNameAndAddressQueryResponseIn binding = service
.getCustomerSimpleByNameAndAddressQueryResponse_InSoapBinding();
// JAX-WS - set username and password in Binding Provider
((BindingProvider) binding).getRequestContext().put(
BindingProvider.USERNAME_PROPERTY, "user");
((BindingProvider) binding).getRequestContext().put(
BindingProvider.PASSWORD_PROPERTY, "password");
// create parameters (test.types.CustomerSimpleByNameAndAddressQueryMessageSync)
CustomerSimpleByNameAndAddressQueryMessage_SyncType parameters = new CustomerSimpleByNameAndAddressQueryMessage_SyncType();
//CustomerSimpleSelectionByNameAndAddress (test.types.CustomerSimpleSelectionByNameAndAddress)
CustomerSimpleSelectionByNameAndAddressAnonymous selection = new CustomerSimpleSelectionByNameAndAddressAnonymous();
// set selection in paramters
parameters.setCustomerSimpleSelectionByNameAndAddress(selection);
// CustomerName (test.types.OrganisationName)
OrganisationNameType customerName = new OrganisationNameType();
customerName.setFirstLineName("Julia");
// set customername in selection
selection.setCustomerName(customerName);

// call the service
System.out.println("Calling web service.....");
// response (test.types.CustomerSimpleByNameAndAddressResponseMessageSync)
CustomerSimpleByNameAndAddressResponseMessage_SyncType response = binding
.customerSimpleByNameAndAddressQueryResponseIn(parameters);

// create some output
List<CustomerAnonymous> customers = response.getCustomer();
for (CustomerAnonymous customer : customers)

Unknown macro: {System.out.println(customer.getBasicData().getCommon().getName().getFirstLineName());} }

catch (Exception e)

Unknown macro: {e.printStackTrace(System.err);} }

}

Optional: Proxy Settings in NWDS

in Eclipse NWDS 

  -Dhttp.proxyHost=proxy  -Dhttp.proxyPort=8080

  • No labels