Skip to end of metadata
Go to start of metadata

This tutorial explains how to consume external services from the ESR using Composite Application Framework. 

Prerequisites:

HU2 System.

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.

Click OK.

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  

Name

Base Type

AmountContent

BigDecimal

PurchaseOrderIDContent

String

Create the Complex Types

ReadPurchaseOrderDetailsReqMsg

Attribute Name

Attribute Type

Cardinality

purchaseOrderID

purchaseOrderIDContent

0:1

ReadPurchaseOrderDetailsResMsg

Attribute Name

Attribute Type

Cardinality

Price

AmountContent

0:1

 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.

Click Next.

Operation Name: readPurchaseOrderDetails

Description: Operation to read the Purchase Order Details from the External Service.

Click Finish.

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:  

  1.  Under purchaseorderes, go to modeled ->Data Types -> Complex Types.
  2. Select ReadPurchaseOrderDetailsReqMsg.
  3. Click on the button Add to Input.
  4. Name the Input Parameter as ReadPurchaseOrderDetailsReqMsg.
  5. Repeat step1.
  6. Select ReadPurchaseOrderDetailsResMsg.
  7. Click on Button Add to Output.
  8. Name the Output Parameter as ReadPurchaseOrderResMsg.
  9. Under caf.core, go to faults àData Types à Faults.
  10. Select CAFServiceException.
  11. 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.

  1. Set PurchaseOrderID to the setSimpleContent method of the Complex Type PurchaseOrderIDType's instance purchaseOrderContentIDType.
  2. Set purchaseOrderIDContentIDType to the setPurchaseOrderID method of the PurchaseOrderByIDQueryMessage_SyncTypeCSIE instance purchase.
  3. 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

URL http://<host_name>:<Port_Number>/nwa

Go to SOA Management à SOA Middleware Global Settings

Host = Http Proxy

E.g.: 10.100.201.16

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)

URL = Paste the WSDL URL. http://erp.esworkplace.sap.com:80/sap/bc/srt/xip/sap/ecc_purchaseorder002qr/version2?sap-client=800&wsdl=1.1&mode=sap_wsdl.

 Click Next.



 

Authentication = HTTP Authentication

Select the Radio Button User ID/Password (Basic)

Details:

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.

Related Content

http://help.sap.com/saphelp_nwce10/helpdata/en/ad/b88de027c34daf96db9ac3d8a92194/frameset.htm

  • No labels