External Services used in CAF can be RFC/BAPI or Web Services. RFC or Enterprise Service can be imported from the original backend systems in the usual way. Otherwise Enterprise Services can also be imported from the Service Registry which is a new feature provided in Netweaver CE. To configure the Service Registry please refer the following blog:
After the Service Registry is configured specify the Registry details in Window->Preferences-> Web Services -> SAP Services Registry in the Netweaver Developer Studio of CE as below:
Next to import the Enterprise Service from the Service Registry select the External Service node right-click and select Import Web services.
In the next screen select the Services Registry option.
Clicking on next the login dialog box will pop-up where the login details of the Service Registry has to be specified. After logging in to the Registry the next screen displays the search criteria to search an Enterprise Service. Enter a search criteria with the name of the Enterprise Service and click on Next.
In the next screen based on the given search criteria all matching Enterprise Services registered in the Service Registry will be displayed.
Select an Enterprise Service from the list and its details will be displayed below. In this example ProductionOrderByIDQueryResponse Enterprise Service is selected. Click on Next to import the Enterprise Service in CAF. A logon dialog may pop-up asking for userid and password of the backend system to import the WSDL.
Once imported a new External Service with its operation will be created in the CAF project as below.
Now to use the External Service in the operation implementation of Application Service one way is to map its operations with that of a remote Business Object. Otherwise this can be directly used in the Application Service operation by creating a new wrapper operation for the external service in the application service. This is a new feature in CE. The external service cannot be added as a dependent to the application service as in the previous release. To create a new external service wrapper operation in the application service select the external service imported and right-click and select Default Mappings option.
In the next screen select the operation of the External Service and the Application Service in which the operation will be created. If no Application Service exists a new application service will be created automatically with the wrapper operation.
A new wrapper operation will be created in the Application Service with the same input and output parameter as the External Service operation.
In the Datasource tab of the application service the mapping of the external service operation parameters to that of the application service is provided.
The external service operation cannot be directly called from an application service custom operation implementation. To access the external service operation from the application service’s operation this wrapper operation needs to be called. Note that the wrapper operation created is not implemented. Create a new custom operation in the application service and check the Implemented checkbox.
Add the input and output parameters and fault as required.
In the implementation of the custom operation add the following code to call the external service operation through the wrapper operation:
In the implementation above the external service’s wrapper operation is called and the output parameter is returned as-is. If required extra business logic can be added here.