Skip to Content

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.

/wp-content/uploads/2014/08/1_526657.png

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’

/wp-content/uploads/2014/08/createdatasource_655682.png

3. Browse to the wsdl file path, select ‘create’ operation. Endpoint location will be populated automatically.

create.PNG

4. Right click on Create> Define Request mapping > OK

/wp-content/uploads/2014/08/createreq_655684.png

5. Request Mapping

/wp-content/uploads/2014/08/42_531439.png

6. Similarly, right click on create> Define Response Mapping

/wp-content/uploads/2014/08/articlecreateresponse_578124.png

DELETE:

7. Repeat step #1.

8. Select “Delete” as operation type and as data source “SOAP Service“.

delete.PNG

9. Select operation ‘delete

deleteselec.PNG

10. Request mapping:

/wp-content/uploads/2014/08/43_531557.png

11. Response Mapping:

/wp-content/uploads/2014/08/26_526685.png

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)

/wp-content/uploads/2014/08/createcsrfrequest_655687.png

14. For creating a record, we have to call POST method. Pass the returned CSRF-TOKEN in the header section with below body section.

createrequest.PNG


<?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.

/wp-content/uploads/2014/08/createresponse_655692.png

15. For Deleting an existing record, select DELETE as below. You must get “Status 204 No Content” in the response.

/wp-content/uploads/2014/08/deleteresponse_655693.png

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

 

metadta.PNG

2. If you are encountered with “Status 400 Bad Request” message in response then it might be of because of payload syntax missing/mismatch.

/wp-content/uploads/2014/08/27_526687.png

Use Xml formatterĀ  http://www.freeformatter.com/xml-formatter.html for assistance

To report this post you need to login first.

39 Comments

You must be Logged on to comment or reply to a post.

      1. Jorge Alberto Encinas Ocegueda

        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,

        (0) 
  1. Jorge Alberto Encinas Ocegueda

    Hi jitendra kansal !!

    I’m trying to make a OData services using this SOAP WS

    http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL.&nbsp;

    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

    (0) 
  2. Nan Wang

    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

    (0) 
      1. Nan Wang

        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!

        (0) 
      2. Nan Wang

        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!

        (0) 
  3. Jitendra Kansal Post author

    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

    (0) 
    1. Ahmed ElManawy

      jitendra kansal


      Yes I’m getting CSRF-Token before requesting a create operation.

      Here is the request mapping:

      ReqMapping.JPG

      Response mapping:

      ResMapping.JPG

      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:

      metadata.JPG


      Last, this is the response:

      Response.JPG

      Regards,

      A.ElManawy

      (0) 
  4. Ryan Murphy

    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

    (0) 
      1. Ryan Murphy

        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.

        (0) 
        1. Eli Harush

          I already looked at those guides but I’ve some challenges:

          1. In case i defined custom js for response and i saw in SMP log that it’s sent null , seems that message not sent.
            1. ERROR 1 :

          #[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 “

          (0) 
          1. Midhun VP

            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

            (0) 
  5. Eli Harush

    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,GET-Request.jpg

    Eli

    POST-Request.jpg

    (0) 
    1. Jitendra Kansal Post author

      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

      (0) 
  6. saket amraotkar

    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.

    Token.png

    Regards

    Saket

    (0) 
  7. saket amraotkar

    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:

    <?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> 

             <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

    (0) 
    1. Michael Appleby

      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

      (0) 

Leave a Reply