This tutorial explains how to consume external services from the ESR using Composite Application Framework.
In order to consume the external services from the ESR we need to follow the below steps:
1. Configure Service Registry in the IDE.
2. Import the External Service.
3. Create the Application Service for the External Service.
4. Expose the Application Service as a Web Service, Deploy and Test the Application
5. Provide External Service Mapping.
Configure Service Registry in the IDE
In the Net Weaver Developer Studio go to Windows -> Preferences > General -> Network Connections.
Select Manual proxy configuration and give your internet explorer proxy settings.
For Example: HTTP Proxy: 10.100.201.16
Port: 8080 In the Net Weaver Developer Studio Go to Windows ->Preferences -> Web Services --> Services Registry. In the UDDI Server give Server Name as sr.esworkplace.sap.com. and Server Port as 80. Click on Apply and then Ok.
Now we can connect to the ESR's Service Registry from the Net weaver Developer Studio.
Import the External Service
In the Composite Application Perspective of Net Weaver Developer Studio create a new project say purchaseorderes. Right click on external and select Import Web Service.
Choose Services Registry and click on Next.
Enter the Service Registry Username and Password.
User Name = sruser
Password = eswork123 This will connect you to the ESR.
Search for Purchase* . This will list all the Service Operations related to Purchase.
Select the first WSDL Port Type Name
Under Endpoints for selected Service Definition you can find the Binding WSDL for the external service.
Click Next .
Enter the User Name and Password for the HU2 System.
Create the Application Service for the External Service
Right click on modeled node in the contextual panel select New Application Service. Name it as PurchaseOrderAS.
Create the Simple Types
Create the Complex Types
Now right click on the Service under external node and choose default mappings. Select all the attributes. In the Target Application Service, select Create methods in existing Application Service. Under modeled node, select PurchaseOrderAS (Application Service that you have created.).
Open the Application Service, PurchaseOrderAS and navigate to the Datasource tab.
Click on the External Service Operation available. Under Target Operation and Source Operation you can find the mapping between the External Service Operation and the Application Service.
This will show the mapping of the external service operation. Navigate to the Operations Tab. Click on Add Button to create a new Operation.
Select the operation type as Custom Operation.
Operation Name: readPurchaseOrderDetails
Description: Operation to read the Purchase Order Details from the External Service.
Now select the operation.
In the Operation Parameters, under Maintain Interface for selected operation you can see the CAF Project that you have created at the beginning of this tutorial.
Applying Input Parameters, Output Parameters and Faults to the Application Service Operation:
- Under purchaseorderes, go to modeled ->Data Types -> Complex Types.
- Select ReadPurchaseOrderDetailsReqMsg.
- Click on the button Add to Input.
- Name the Input Parameter as ReadPurchaseOrderDetailsReqMsg.
- Repeat step1.
- Select ReadPurchaseOrderDetailsResMsg.
- Click on Button Add to Output.
- Name the Output Parameter as ReadPurchaseOrderResMsg.
- Under caf.core, go to faults àData Types à Faults.
- Select CAFServiceException.
- Click on button Add to Fault.
Navigate to the Implementation Tab and open the link PurchaseOrderASBeanImpl.java.
This java class will contain the operation ReadPurchaseOrderDetails. Write the following code inside the class file.
The above code sets the purchaseOrderID to the External Service Operation PurchaseOrderByIDQueryResponse_In.
For PurchaseOrderByIDQueryResponse_In operation, the Input Parameter is of type PurchaseOrderByIDQueryMessage_SyncType. In order to pass the PurchaseOrderID of type String to the External Service Operation we need to do the following.
- Set PurchaseOrderID to the setSimpleContent method of the Complex Type PurchaseOrderIDType's instance purchaseOrderContentIDType.
- Set purchaseOrderIDContentIDType to the setPurchaseOrderID method of the PurchaseOrderByIDQueryMessage_SyncTypeCSIE instance purchase.
- Set purchase to the setPurchaseOrderSelectionByID method of the PurchaseOrderByIDQueryMessage_SyncType instance purchaseOrderInput.
Now we have mapped the PurchaseOrderID with the Input Parameter purchaseOrderInput of the External Service Operation.
Pass the Input Parameter to the External Service Operation. This operation will return output parameter of type PurchaseOrderByIDResponseMessage_Sync. Now we need to convert it to the Simple Type Amount Content and set it to the output Parameter readPurchaseOrderResMsg of Application Service Operation ReadPurchaseOrderDetails.
Expose the Application Service as a Web Service, Deploy and Test the Application
Right click on Application Service PurchaseOrderAS, from the context menu select Expose service as Webservice. Window Select Service Operations will appear. In that select the operation ReadPurchaseOrderDetails and click OK.
Save, Generate, Build and Deploy the Application.
Provide External Service Mappings
Go to Net Weaver Administrator
Go to SOA Management à SOA Middleware Global Settings
Host = Http Proxy
Port = 8080
Username =A Valid mail Id of your company
Password = Valid Password.
Go to SOA Management -> Destination Template Management -> Destination Template -->New
Destination Type = WSDL
Destination Name = EXTN_SERVICE (Give any name of your choice)
Authentication = HTTP Authentication
Select the Radio Button User ID/Password (Basic)
UserID = HU2 System UserID
Password = HU2 System Password.
Click Next and then Finish.
In Netweaver Administrator go to Configuration Management -> Destinations -> CAF Configuration.
Under External Services select the external service we have imported from ESR i.e. PurchaseOrderByIDQueryResponse_In.
Under Destinations select EXTN_SERVICE which we have created earlier.
Click Map and then Save.
Go to web service navigator and select the deployed application service and test it for PurchaseOrderID = 4500018023.