This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Summary The following document is intended to guide you through the Services Registry for ES Workplace and to show you how to use it efficiently for an accelerated enterprise SOA deployment. Author(s): Harish Mehta, Joerg Dehmel, Nikolay Kanchev Company: SAP AG Germany, SAP SI AG Germany, SAP AG – External Employee Created on: 02.11.2007
Author Bio Harish is currently working in the area of SAP NetWeaver SOA middleware for the development of Services Registry. Jörg is involved in the development of the SAP NetWeaver Developer Studio. His focus is on tools to provide and consume web services. Nikolay is an information developer for SAP NetWeaver SOA Middleware.
Table of Contents Applies to: ........................................................................................................................................ 1 Summary.......................................................................................................................................... 1 Author Bio ........................................................................................................................................ 1 Search and Browse Services in Services Registry ......................................................................... 3
Testing a Service in Web Services Navigator ............................................................................... 13 Use............................................................................................................................................. 13 Prerequisites .............................................................................................................................. 14 Procedure................................................................................................................................... 14
1. Testing a Web Service ....................................................................................................... 16 2. Saving the Test Scenario ................................................................................................... 19
Testing Web Services with Pre-Defined Input Data ...................................................................... 20 Use............................................................................................................................................. 20 Prerequisites .............................................................................................................................. 20 Procedure................................................................................................................................... 20
Service Consumption in NetWeaver Developer Studio................................................................. 25 Setting up preferences............................................................................................................... 25
Querying the Services Registry ................................................................................................. 27 Creating a dynamic web project ............................................................................................. 27 Starting the WSDL Import Wizard .......................................................................................... 29 Looking up service definitions ................................................................................................ 31 Downloading the WSDL ......................................................................................................... 32
Using the downloaded WSDL .................................................................................................... 32 Generating a Web Service Client ........................................................................................... 33 Implementing a Servlet that uses the Web Service Client ..................................................... 35 Deploying the client on the J2EE engine................................................................................ 36 Configuring the proxy settings on the J2EE engine ............................................................... 38 Calling the Web Service Client............................................................................................... 39
Related Content............................................................................................................................. 39 Copyright........................................................................................................................................ 40
Search and Browse Services in Services Registry This section gives user tips and tricks to search and browse web services exposed on ES Workplace Services Registry. Most of the UI parts used for Search and browse are explained as different steps along with snapshots.
Services Registry Navigation Services Registry UI on ES Workplace can be invoked by executing any one of the following links. http://sr.esworkplace.sap.com/webdynpro/dispatcher/sap.com/tc~esi~esp~er~ui/Menu?j_username=sruser&j_password=eswork123Or http://sr.esworkplace.sap.comOr http://sr.esworkplace.sap.com/webdynpro/dispatcher/sap.com/tc~esi~esp~er~ui/Menu(Please use user sruser/eswork123 in case system asks for authentication).
Search services
1. Choose option “Search” on the tab strip “Service Definitions”.
2. Search based on Port Type Name can be triggered by typing in the known part of PortType Name in the “Find” field with asterisk sign at the end e.g. “SalesOrderById*” and Choosing the option “Search by” with value “WSDL Porttype Name”.
3. Search based on Internal Name can be triggered by typing in the known part of Internal Name in the “Find” field with asterisk sign at the end e.g. “ECC_SALESORDER002QR*” and choosing the option “Search by” with value “Internal Name”. Internal Name is ABAP Service Definition Name of maximum length char30.
4. Search by “Free text” triggers search engine based search. This might be useful in cases where user is not sure about the entity type what he is looking for. SAP search engine TREX is used in the backend to provide the results. It should be able to provide fast and reliable text search for registered entities in UDDI server and not limited to only Port Type and Internal Name. For example Find “Sales Order” should return all the services where the text “Sales Order” has been used somewhere in their UDDI entities.
Note: Asterisk sign does not play and significant role in case of this option.
5. Search criteria can be refined by choosing the appropriate service provider system in “System” the drop down option.
6. Drop Down field “State” can also be chosen additionally to refine the search criteria. Value “Modelled” reflects list of Services coming from Enterprise Service Repository, Value “Activated/Deployed” reflects
7. Advance search options can also be defined by pressing the “Advanced” option as shown.
8. This additional option gives user a chance to define search criteria based on service classifications. User can first choose the required classification system from drop-down “Select Classification”, then choose one of the possible values and push it on the right side as “Selected classifications”. This process can be repeated with as many as classification systems along with their possible values. For example user can search for all services belonging to classification system “Deployment Unit” with ECC. Another example my be to search all services belonging to classification system “Business Object” with value “Sales Order” as shown.
Note: Logical “AND” operation is used as search criteria between values of different classification systems. Logical “OR” operation is used as search criteria between different values of same classification system.
9. “GO” button brings the result list based on the search criteria. Search results are listed in the form of table containing information about service Port Type Name, Namespace, State, Description and Provider System.
10. Choosing a row in the result table shows the detail information. Tab strip “General” tells about service Port Type Name, ABAP Name, Port Type WSDL url, Documentation url and service Description.
11. Tab strip “Endpoints” shows information about the service endpoints. Information about each “Endpoint Name”, “Target Address” and “Binding url” is contained here. Button “Test” brings user a possibility to test each and every endpoint for the selected service by opening the test application “WS Navigator”. This is also explained in detail ahead in this document.
Note: This information is available in case of configured services only. Services with state “Activated/Deployed” do not contain this information.
12. Tab strip “Classifications” shows the associated classification values for the selected service. These classification values bring a special semantic to the service. For example service “SalesOrderByIDQueryResponse_In” is associated to classification system “Deployment unit” with value “ECC”, classification system “Process Component” with value “Sales Order Processing”, classification system “Business Object” with value “Sales Order”. This combination makes a service meaningful in a
13. Tab strip “System Details” shows provider system details. Attributes “System Name”, “DB Host”, “SLD Identifier” “ABAP Client” and “System Type” can be seen here.
Browse services
1. Choose option “Browse” on the tab strip “Service Definitions”.
4. Classification systems “Deployment unit”, “Process component” and “Business Object” makes a hierarchical tree where “Deployment Unit” stays at top level and “Business Object” at the lowest level of this tree. User can start looking for services if “Deployment unit” is known for that service.
5. Expand Node with value “ECC” to get list of available “Process Component” under “ECC”.
8. Select the desired service to see further details.
Note: Service details are the same as described in case of “Search services” option. Browse option is useful if classification values are somehow known to user. This option is also useful to know what all services are available under a specific deployment unit, Process component or business object.
Testing a Service in Web Services Navigator Use The Web Services Navigator (WS Navigator) allows you to test a Web service without having a client for it. In the WS Navigator, you can:
• Test individual operations of individual service endpoints running on the local or remote provider systems
• Save the input data from the test of a service endpoint, and run the same test on the same endpoint multiple times.
• From a central location, test the same endpoint that runs on different provider systems
In the WS Navigator, you can test service endpoints, which require basic HTTP authentication (User
ID/Password) or no authentication.
Prerequisites You have credentials to execute Web Services, which are listed in the Services Registry. You can apply for credentials at the following address:
http://www.sdn.sap.com/irj/sdn/esareg
Procedure 1. To start the WS Navigator, in a Web browser, enter the following address:
http://sr.esworkplace.sap.com/wsnavigator
The WS Navigator opens.
2. In the WSDL URL field, enter the following address: http://erp.esworkplace.sap.com:80/sap/bc/srt/xip/sap/ecc_salesorder002qr?sap-client=800&wsdl=1.1&mode=sap_wsdl
2. In the Enter Input Parameters step, enter the following data in the provided fields:
a. In the Parameters area, enter input data for testing the Web service endpoint. The input data, which you enter, is a consumer request to the service endpoint.
b. In the Configuration area, proceed as follows:
• In the Timeout (in seconds) field, enter a timeout for the completion of the test.
• In the Endpoint in WSDL dropdown menu, choose the endpoint of the Web service.
You can test the same endpoint running on a remote provider system. In the Custom Endpoint field,
in the URL, replace the current host name and port number with the host name and port number of the remote system.
6. Choose Export Test Data. 7. Save the test scenario. 8. The system saves an XML document, which contains test input data and result. 9. You can import and run the exported test scenario on the same endpoint. The endpoint may be on the
same or on a different provider system. For more information read the next procedure.
Testing Web Services with Pre-Defined Input Data Use When you test a service endpoint, you can export the test data and save it in a test scenario in XML format. A test scenario contains information about, which endpoint you tested, with what input data you tested it, and specifies the output that the endpoint returned. You can re-use a test scenario to test the same endpoint with the same input data. For more information about exporting a test scenario, read the previous procedure.
Prerequisites The test scenario for the service endpoint is available.
Procedure 1. In the Select Service step, choose Import Test Scenario Data.
2. In the File to Import field, choose the test scenario, and then choose Next. 3. By default, the WSDL option is selected and the URL field is automatically populated. The WSDL URL
points to the endpoint available on the provider system to which the test scenario was exported.
If you run the test scenario on a provider system (for example System B) which is different from the
provider system (System A), to which the test scenario has been exported, then you have to enter a WSDL URL for the endpoint available on the provider system on which you want to test the endpoint (in our example, this should be System B).
If you do not know the WSDL URL for the endpoint, you can choose the WSIL option, and enter a WSIL URL in the URL field.
To save your changes, choose Save and Return. To cancel your changes, choose the Test Execution Status step of the wizard.
If you changed the input parameters of the test scenario, you have to execute the test again to get
the output from the new test scenario. The system notifies you that the expected result differs from the executed one due to the changes.
• To make a preview of the difference between executed result and the expected result, choose Show Difference.
The system directs you to the Parameter Difference step. You can make a preview of the difference and accept the new result.
To save the result in the test scenario, choose Accept Result and Return. To discard the result and leave the Parameter Difference step, choose Test Execution Status step.
• To re-export the test scenario, choose Export Test Data and save the test scenario document with the latest changes on your local machine.
• To return to the start screen of the WS Navigator, choose the Select Service step.
Service Consumption in NetWeaver Developer Studio Setting up preferences
Proxy
In case the connection between Developer Studio and Services Registry is established via proxy you have to configure the proxy settings of the Developer Studio in Window Preferences Internet Proxy Settings.
Figure 1 Proxy Settings
Services Registry
Furthermore you have to set up the preferences to connect to the Services Registry. Open the Eclipse preference dialog Select the preference page ”Web Services Services Registry” Enter the required data as shown below
At later point in time it will be necessary to deploy the JEE application to the engine from within the IDE. Therefore you have to configure the IDE accordingly. Please open ”Window Preferences SAP AS Java”, enter instance host and number and press “Register SAP Instance”.
Querying the Services Registry The IDE provides an import wizard to lookup the services registry and download WSDL files of the found services into the Eclipse workspace.
2. Choose an output location to import the WSDL. Please use one of the folders in the project created before. Choose “Services Registry” as WSDL source. Press “Next”.
3. A dialog appears to authenticate to the Services Registry. Enter the credentials issued for you which correspond to the Services Registry configured above. Press “Ok” to go ahead.
1. Enter the search expression “SalesOrderById*” in the “Find” field. (Don’t forget the star at the end of the String – it is used as wildcard symbol here.) This triggers a lookup for all services which “WSDL Porttype Name” starts with this term.
2. You could enter other search criteria to narrow down your search results. But this is not needed in our case.
1. After pressing “Next” the Services Registry will be queried using the specified search criteria. Click on the found Service Definition “SalesOrderByIDQueryResponse_In” in the upper table and then on the endpoint displayed in the lower table.
2. Press “Finish” to trigger the download of the WSDL file.
3. Another login dialog appears, this time to authenticate to the backend system the WSDL will be downloaded from. Enter your backend credentials and press “OK”. You can apply for backend credentials via SDN:https://www.sdn.sap.com/irj/sdn/esareg
4. The WSDL import has completed and you can see the file in your Eclipse workspace now.
Using the downloaded WSDL In this part you will generate a deployable web service client out of the downloaded WSDL. After deployment on the server the client will be called in a final step.
2. Select the WSDL file in the Project Explorer and call context action “Web Services Generate Client”
3. Choose “SAP Server” and “SAP NetWeaver” in the configuration area of the wizard. Choose the existing web- and ear- projects as shown on the screenshot. Pull down the slider on the left side as far as possible. Press “Next”.
Implementing a Servlet that uses the Web Service Client
1. Select the “clientWeb” project in the project explorer and call the context action “New Servlet”.
2. Enter “test” as package- and “TestServlet” as class name. Press “Finish”.
3. Add the following annotated field to the Servlet class to inject the service reference: @WebServiceRef(name="SalesOrder") SalesOrderByIDQueryResponseInService service;
Note: Instead of the String (“SalesOrder”) you can use any other String that is unique for this purpose inside of the JEE application.
4. Add the following code to the “doGet” method of the Servlet. Replace username / password with your credentials for the backend system the Web Service is running on.
try { // Get the port from the service instance SalesOrderByIDQueryResponseIn port = service.getSalesOrderByIDQueryResponse_InSoapBinding(); // Specify username and password issued for you via SDN // to authenticate to the backend as follows javax.xml.ws.BindingProvider bp = (javax.xml.ws.BindingProvider) port; Map<String,Object> context = bp.getRequestContext(); context.put("javax.xml.ws.security.auth.username", username); context.put("javax.xml.ws.security.auth.password", password); // Construct the input to be applied to the service call SalesOrderByIDQueryMessageSync input = new SalesOrderByIDQueryMessageSync(); SalesOrderSelectionByID selectionById = new SalesOrderSelectionByID(); input.setSalesOrderSelectionByID(selectionById);
SalesOrderID id = new SalesOrderID(); selectionById.setSalesOrderID(id); id.setValue("9999"); // Call the service SalesOrderByIDResponseMessageSync output = port.salesOrderByIDQueryResponseIn(input); SalesOrder order = output.getSalesOrder(); // Evaluate and display the response PrintWriter writer = response.getWriter(); writer.println("Details found for order " + id.getValue() + ":"); writer.println("<br>buyerID: " + order.getBuyerID().getValue()); writer.println("<br>date: " + order.getDate()); writer.println("<br>payerParty: " + order.getPayerParty().getFormattedName().getValue()); writer.println("<br>pricingTerms / currency: " + order.getPricingTerms().getCurrencyCode()); } catch (SalesOrderByIDQueryResponseInFault e) { throw new ServletException(e); }
Deploying the client on the J2EE engine
1. Open the “Servers” view. First call menu action “Windows Show View Others”. A view selection dialog appears. Enter the search term “servers” there, select the one remaining node and press “OK”.
2. Add the EAR project to the configured server. On the “Servers” view select the server that points to the J2EE engine configured above. Call context action “Add and Remove Projects” then. On the displayed dialog select the EAR project on the left side and press “Add”. Leave the dialog pressing “Finish”.
3. Deployment of the EAR project to the server is starting automatically. You will be prompted to enter J2EE engine credentials now to get authenticated for the deployment. Press “OK” to continue the deployment.
Configuring the proxy settings on the J2EE engine
1. Open the start page of the J2EE engine via Internet Explorer by entering the address: http://<server>:<port>
2. Click on the icon next to “SAP NetWeaver Administrator”.
3. You will be prompted to enter your J2EE credentials now. After confirming the authentication page you will see the main page of the “NetWeaver Administrator”.
4. Navigate to “SOA Management System Global Settings”
5. Enter the proxy settings needed to connect the J2EE engine with the backend system the Web Service is running on. Press “Sichern / Save” to apply the settings.
Calling the Web Service Client
1. Now you are able to call the deployed Web Service Client. Open the Internet Explorer and enter the following address: http://<j2ee-server>:<http-port>/clientWeb/TestServlet If nothing went wrong you should see the response beside.
Related Content help.sap.com: Importing WSDL Documents in the SAP NetWeaver Developer StudioApplying for backend credentials on SDN
completeness of the Code given herein, and SAP shall not be liable for errors or damages caused by the usage of the Code, except if such damages were caused by SAP intentionally or grossly negligent.