Part 2 – Connecting SOAP Web services with Integration Gateway in SMP3
This write-up is an extension to this blog How to connect SOAP WebServices with Integration Gateway in SMP3 written by Marvin Hoffmann
As you can see for the given SOAP WS, http://www.predic8.com:8080/material/ArticleService?wsdl there are 4 different methods. As we have already seen how to do OData modeling for get, getAll methods, now its time for other methods Create & Delete.
Assuming you have already installed “SAP Mobile Platform Tools” plugins in Eclipse Kepler. (How to?) and created one sample OData service Implementation project with having one main entity type and one complex type as mentioned in this blog.
CREATE:
1. Right click ArticleModel.odatasrv > Select Data source
2. Select “Create” as operation type and as data source “SOAP Service” > Click ‘Next’
3. Browse to the wsdl file path, select ‘create’ operation. Endpoint location will be populated automatically.
4. Right click on Create> Define Request mapping > OK
5. Request Mapping
6. Similarly, right click on create> Define Response Mapping
DELETE:
7. Repeat step #1.
8. Select “Delete” as operation type and as data source “SOAP Service“.
9. Select operation ‘delete‘
10. Request mapping:
11. Response Mapping:
Note: Since ArticleID is a key in the EntitySet so in the response mapping it can not be left unmapped. It has to be mapped otherwise you will get an error and so won’t be able to deploy the project.
12. Once done, right click on project > Generate and Deploy Integrate Content
13. To test service document for the newly added methods create & delete,first we need to get CSRF-TOKEN using GET method. So, make a GET request first as below
(OData service exposed via Integration Gateway listens on SMP Admin port 8083 (HTTPS), so pass SMP admin credentials under header section)
14. For creating a record, we have to call POST method. Pass the returned CSRF-TOKEN in the header section with below body section.
<?xml version="1.0" encoding="UTF-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<atom:content type="application/xml">
<m:properties>
<d:ArticleID />
<d:Name>Ginger tea</d:Name>
<d:Descirption>Good for health</d:Descirption>
<d:Price m:type="ArticleModel.Price">
<d:Amount>10</d:Amount>
<d:Currency>EUR</d:Currency>
</d:Price>
</m:properties>
</atom:content>
</atom:entry>
You must get “Status 201 Created” in the response.
15. For Deleting an existing record, select DELETE as below. You must get “Status 204 No Content” in the response.
Tips:
1. For Payload, it is always recommended to follow parameters data types and values as per service metadata document.
https://jk:8083/gateway/odata/sap/ArticleService;v=1/$metadata
2. If you are encountered with “Status 400 Bad Request” message in response then it might be of because of payload syntax missing/mismatch.
Use Xml formatterĀ http://www.freeformatter.com/xml-formatter.html for assistance
Hi!
There are some images that are not display.
Jorge Alberto Encinas Ocegueda
Thanks for highlighting. I have updated it now. Please let me know if you still have any issues in viewing the images.
Rgrds,
JK
Thank you,
I can't see the images on step 5, 10 and 14 (You must get "Status 201 Created" in the response)
I wanna use this in a Android native app, do you have any example on how to use this in a Android native app? I would appreciate a lot.
Rgrds,
Jorge Alberto Encinas Ocegueda
I guess, now you should not have any problem in viewing the images. I have not much explored on Android app development but i believe you should get good hints from this write-up. SMP 3 - Android Native App Development
Rgrds,
JK
Thank you!
Rgrds,
Jorge
Hi jitendra kansal !!
I'm trying to make a OData services using this SOAP WS
http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL.
I want to test "GetCityWeatherByZIP" operation. I did all the steps with "Read" as operation, but when I test it, returns this error message.
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<code/>
<message xml:lang="en">
"[com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper] is the parsing exception."
</message>
</error>
Do you have any idea what the reason could be?
Thank you in advance for your help.
Regards,
Jorge
Jorge Alberto Encinas Ocegueda
This is a known issue. A workaround is available here:
SMP 3.0: Integration Gateway Parsing Exception
For further queries(if not related to above blog), request you to raise a new thread.
Rgrds,
JK
Thank you!
It works!
Regards
Jorge
Hi jitendra
I tested the sample above. when I try create operation, I got following error:
<?xml version="1.0" ?>
<error
xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<code></code>
<message xml:lang="en">while trying to invoke the method com.sap.gateway.core.ip.component.commons.ODataResponseType.ordinal() of a null object loaded from local variable 'responseType'</message>
</error>
I guess it's because the response mapping. Normally, the SOAP return will have <ns:xxxxxresult> node before the real result data. but in this case, there is only id node under <ns: createresponse> node.
Any idea about that?
Thanks
Hi Nan Wang,
seems you are just trying to run http://localhost:8080/gateway/odata/SAP/ArticleService;v=1/ArticleSet in browser? Right?
Are you not trying it in a REST client? Are you able to get CSRF-TOKEN in GET request? Can you share screenshots of what you are trying?
Rgrds,
JK
hi jitendra
thanks for your reply. the problem is resolved. the root cause is the Article node can't be mapped to WS result. We need to set a constant value to Article node. than the project work.
Thanks!
hi jitendra
BTW: at the bottom of the IGW DT, there is many model tool. for example, node, string ... do you know where can we find the document to talk about how to use it?
Thanks!
Nan Wang
I didnt get it. Can you share more info on this?
Regards,
JK
Thank you jitendra kansal
when i try to create i get the following response message:
500 Internal Server Error
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<message xml:lang="en">Index: 0, Size: 0</message>
</error>
Regards,
Ahmed ElManawy
Ahmed ElManawy
Which operation you try with ? Create or delete?
Which smp version you are working with?
Did you also try with getall, get methods? Did it work?
Regards,
JK
Thank you jitendra kansal for fast reply,
I'm trying a create operation with SMP3.0 SP3, yes I tried all other operations and they worked successfully.
Regards,
A.ElManawy
Ahmed ElManawy
Let me understand what all you have for this create operation.
Are you done with request and response mapping for "CREATE" operation?
Are you getting CSRF-token in GET request?
Please share some screenshots to understand it better.
Regards,
JK
jitendra kansal
Yes I'm getting CSRF-Token before requesting a create operation.
Here is the request mapping:
Response mapping:
Here is the body sent in the request:
<?xml version="1.0" encoding="UTF-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<atom:content type="application/xml">
<m:properties>
<d:ArticleID />
<d:Name>Ginger tea</d:Name>
<d:Description>Good for health</d:Description>
<d:Price m:type="DataModel.Price">
<d:Amount>10</d:Amount>
<d:Currency>EUR</d:Currency>
</d:Price>
</m:properties>
</atom:content>
</atom:entry>
and this is the metadata:
Last, this is the response:
Regards,
A.ElManawy
Ahmed ElManawy
I have updated CREATE response mapping screenshot. Can you try once again?
Regards,
JK
Thank you very much jitendra kansal, the problem was solved and now it's working.
Best regards,
A.ElManawy
Nice post Jitendra. Very helpful.
Do you know if Integration Gateway supports SOAP Headers and SOAP header mapping? I didn't see it mentioned either way in help.sap.com. It is a requirement for the web service we have to call.
Thanks
Ryan
Ryan Murphy
Can you share some example regarding your scenario?
Regards,
JK
It's a pretty simple scenario. The backend application has exposed a SOAP service which requires the username and password to be provided in the SOAP Header section of the SOAP envelope.
I loaded the wsdl using your instructions and created a mapping, but it is only letting me map the Body section of the SOAP envelope. There seems to be no way to populate the SOAP header as required by my client.
From my experience, SAP's other tools (SAP PI & BPM) are lacking in SOAP Header support also, which is unfortunate because it is a common requirement for various backend application systems and is often out of our control.
Ryan Murphy
You can do it using "custom scripting". Have a look at this guide and its comment section.
Writing Custom Logic using Java Script in SMP Integration Gateway
Hi JK,
Do you have advanced guide to build request /response WS based SOAP ?
Thanks,
Eli
Hi Eli,
Did you get a chance to look at these documents:
Writing Custom Script in SMP 3 Integration Gateway
Writing Custom Logic using Java Script in SMP Integration Gateway
Regards, Midhun
SAP Technology RIG
Eli Harush
What exactly you are looking for?
Midhun has shared good guides. Check it.
Regards,
JK
I already looked at those guides but I've some challenges:
#[Gateway][BUSINESS][ReadEntitySetFailed]:Data Provider - readEntitySet failed: service = RUNPI , entity set = WorkOrderSet , message = java.lang.Exception: An Error has occured
ERROR2 :I added base security header and the procee request ignore from my custom code
"
gateway/odata/SAP/VISAINFO;v=1/VisaInfoSet, message = Could not send Message. |
2015 01 25 19:01:23#+0200#DEBUG#com.sap.mobile.platform.server.foundation.security.filter.AuthenticationFilter##anonymous#http-bio-8080-exec-2####null#null#null#debug#Security#null#null#9943f263-5f80-4f8b-bfc1-e2f7ba87823e#null#1422198083017#null#com.sap.mobile.platform.server.foundation.security.filter.AuthenticationFilter:doFilter#authfilter-1: Security Configuration set to: 'SAP'#null#650#RequestResponse#0#null "
Hi Eli,
If the issue mentioned is independent of the blog, could you raise a new thread with more details on the issue. Include details of the service you are using, odata model screen shot and script used.
Regards, Midhun
SAP Technology RIG
Updated for SMP 3.0 SP06
Jitendra KansalMarvin Hoffmann
Hi,
I have a soap webservice as below.Its giving me invalid WSDL.Am able to test this webservice through Storm,SOAPUI5.
Details:
smp 3.0 sp6
API Toolkit for sap mobile platform 1.3.1
Glanet Carol
Download WSDL file locally and then browse to it.
Regards,
JK
Hi JK,
I'm using SMP 3.0.5 and i defined read web services in SMP IGW with key parameters ,if i'm try GET request in POSTMAN is working fine , but in my case i have bigString (image binary) and too much big so i thought to use POST request to transfer big data in body request so i did the following steps :
1. Run get request to get X-CSRF-TOKEN and other cookies data .
2. Run POST request with headers data from Step 1 and i got always 403 code "Access to the specified resource has been forbidden", i tried post request just with X-CSRF token and got same result .
Can you please advise?
See attached print screen.
Thanks,
Eli
Eli Harush
Is that WS is REST or SOAP?
If SOAP, were you able to execute POST request in SOAP UI? Have you bound entityset to CREATE operation in eclipse? can you share request/response mapping screenshots? What is the datatype you have selected for image properties in OData model?
Regards,
JK
Hi Jitendra,
Unfortunately, i am not able to get token in response, when i try Get method in Rest Client.
I can see the data coming in response, but not token.
Regards
Saket
saket amraotkar
Its not the issue with SMP/IGW, sometime REST Client behaves like this. I would suggest you to try with other add-ons POSTMAN (chrome), or Fiddler. Fiddler free web debugging proxy
Please raise a new thread if you have any further queries, you may reference docs/blogs you are following.
Regards,
JK
Hi Jitendra,
I was wondering, how can we pass multiple records in request to insert two entries for Price.
I tried with below code, but only last record got updated:
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<atom:content type="application/xml">
<m:properties>
<d:ArticleID />
<d:Name>Ginger tea</d:Name>
<d:Descirption>Good for health</d:Descirption>
<d:Price m:type="ArticleModel.Price">
<d:Amount>10</d:Amount>
<d:Currency>EUR</d:Currency>
</d:Price>
<d:Price m:type="ArticleModel.Price">
<d:Amount>111</d:Amount>
<d:Currency>USD</d:Currency>
</d:Price>
</m:properties>
</atom:content>
</atom:entry>
Your help will be really appreciated.
Regards
Saket
Please create a new Discussion for your question. Comments to a blog is not the right vehicle. See the Getting Started link at the top right for more information.
Thanks, Mike (Moderator)
SAP Technology RIG
Hi Jitendra Kansal,
Nice blog. Also thanks Marvin Hoffmann .
So now we have read query create and delete, do you have any blog taking about update operation?
Thanks,
Billy