Additional Blogs by SAP
cancel
Showing results for 
Search instead for 
Did you mean: 
marvin_hoffmann
Active Participant

I already wrote several blog posts on how to use the Integration Gateway. But till now I was always using databases as data source. Using a SOAP web service as data source is even nicer, because you can use a graphical mapping editor (part of the GWPA eclipse plugin) to define the request and response mapping.

In this tutorial we will connect a SOAP web service to SMP3's integration gateway and realize a Query and a Read operation

How to connect SOAP WebServices with Integration Gateway in SMP3

In this example we will use the following free sample SOAP Web Service http://www.predic8.com:8080/material/ArticleService?wsdl . This is a small service which will give us a list of articles. We can list all, one specific, create or delete entries.

There are many different tools to test SOAP Web Services,e.g. SOAP UI. Another free, very small and nice utility is Storm (http://storm.codeplex.com/) which I used here.

If you execute the getAll Operation you can see (at the moment) that there are two articles in the store (Black Tea and Assam Tea).

I assume that you already installed the GWPA plugin into eclipse. If not, please follow the steps as described in my previous blog post here: How to install Gateway Productivity Accelerator (GWPA) plugin for Integration Gateway

Model the OData Service

1. Open eclipse and create a new OData Development > Service Implementation Project

2. Define a project name, e.g. "ArticleService" and select the option "Create OData file manually"

3. Expand the newly created project and right click on the "model" folder inside src/main/resources and create a new OData Model

4. Provide a name for this model, e.g. DataModel (Initial model content: Blank OData model).

5. Let's build our ODataModel the same way our SOAP web service is modeled. Create a new "Entity Type" via Drag&Drop in the odata model editor. the name of the entity set will be your collection name that is also represented in your URL when you (later) request data from the OData service. Also create via Drag&Drop the complex type Price and add the two properties Amount and Currency.

6. Then add the properties to out Article Entity Type. Normal properties are ArticleID, Name and Description. Then choose "Add Complex Property" and call it Price.

7. Select the added complex property and choose the type in the Properties > General panel. Because we previously created the complex type in our OData Model we can find "DataModel.Price" in the drop down menu.

8. Now we finished modeling the Odata service.

Implement the OData Service

1. Right click on the OData model and choose "Implement Service". Be aware that if you change anything in the OData model you always have to re-implement the service!

2. Right click on the implemented service and choose "Select Data source"

3. Select "Query" as operation type and as data source "SOAP Service"

4. Provide the following connection details

PropertyValue
Endpointhttp://www.predic8.com:8080/material/ArticleService
Namespacehttp://predic8.com/wsdl/material/ArticleService/1/
OperationgetAll
Port TypeArticleServicePT

You can find these values by checking your wsdl file. So download the wsdl file of the SOAP web service http://www.predic8.com:8080/material/ArticleService?wsdl . Open it. You can find the SOAP endpoint usually at the end of the document inside the tag <soap:address location="....">

The target namespace is mentioned in the beginning inside the tag <xsd:schema ... targetNamespace="...">

The operations (tag <operation name="...">) can be also read out, usually wrapped by the port type (tag: <portType name="...">)

5. Expand the path below the OData implementation. A new SOAP operation should be added here. Right click on it and choose "Define Response Mapping". As the name said the response mapping is responsible inside our OData service for returning data as a response to a request. Here you can also implement a custom request logic by choosing "Define Custom Logic for Request". This is quite interesting, because in this way you have the possibility to write a Java class where you can implement filter or other operations your OData service should provide.

6. Choose "Browse..." and navigate to your downloaded wsdl file. If you don't have downloaded it, do it now: http://www.predic8.com:8080/material/ArticleService?wsdl

7. Define a message mapping. On the left side you can see the SOAP web service and on the right side our OData EntityType. Connect the properties via Drag&Drop. Don't forget to bind also the Entity itself, from "article" to "Article". Save the project after this actions.

8. Right click on your whole project and click "Generate and Deploy Integration Content".

9. the Service name will be the OData Service name running on the integration gateway. The Service Namespace will be also part of the URL and additionally it defines the security profile which should be checked when accessing this OData service.

Test the OData Service

1. After successful deployment, go to your browser and open the SMP3 Management Cockpit ( https://smpserver:8083/Admin/ ). Open tab Settings > Security Profiles and create a new Security Profile called "sap" (names like the Service Namespace we defined in the previous step during deployment). then add a new authentication provider for it. In this example we will add a "No Authentication Challenge" Provider which will simply let anyone access our OData service (should be only used for testing/development purpose!). Click on "Save".

2. Now open the Gateway Cockpit ( https://smpserver:8083/gateway/cockpit ). You should find a new service called "ArticleService". Click on "Open Service Document".

3. You can see the Service Document of your OData service.

4. Let's check if our implementation is working by accessing the ArticleSet Collection, the path will be http://smpserver:8080/gateway/odata/sap/ArticleService;v=1/ArticleSet

5. As you can see we are receiving OData coming from the SOAP web service.

Extend the OData Service with other Operations

1. If we want to access a single entity, e.g. by calling inside the browser:

http://smpserver:8080/gateway/odata/sap/ArticleService;v=1/ArticleSet('AR-00001') we will get the OData error "while trying to invoke the method java.lang.String.length() of a null objectt loaded from local variable 's'". And actually the OData Service is correct. We didn't implement the Read Operation, so it can' work...

2. So then let's implement the OData read operation. Inside your eclipse project right click on the service implementation and choose "Select Data Source" again. This time choose operation "Read".

3. Specify the connection details. This time we want to realize another operation, so we will specify the "get" operation of the SOAP web service.

4. Now you can see the two operations Query and Read. Right click on Read and choose "Define Request Mapping".

5. For the Request Mapping we want to give the Primary Key (ArticleID) and the OData service should return us the corresponding object.

6. Let's define the Response Mapping for the "Read" operation. This is straight forward...

7. After that save everything and deploy the OData Service to SMP3 (right click on the project and choose "Generate and Deploy Integration Content")

8. If you now are accessing our OData service with a specific element you will get returned the requested element...

9. So we have now an OData service which is realizing two operations of the SOAP web service. You could now continue and realize the CREATE and DELETE operations to let the OData service provide the same functionality than the chosen SOAP web service...

I hope this tutorial is helping to understand the idea behind integrating SOAP web services with SMP 3. Unfortunately, there are many restrictions/limitations at the moment in regards to the support SOAP web services. For a list of restrictions you can check the following two SAP notes:

For GWPA eclipse plugin: 1830710 - Gateway Productivity Accelerators Release Note & Constraints > Constraints > Toolkit for Integration Gateway

For Integration Gateway: 1931374 - Integration Gateway for SAP Mobile Platform 3.0 - Known Constraints

Anyway, the integration gateway is a powerful component and will be enhanced in future...

36 Comments