cancel
Showing results for 
Search instead for 
Did you mean: 

Integration between the SAP Cloud SDK and the Apache Axis2 framework for consuming SOAP APIs

vijetha_m1870
Explorer
0 Kudos

Hi,

Can you please help with references(sap docs/links) for integration between the SAP Cloud SDK and the Apache Axis2 framework in SAP BTP CAP Java for consuming SOAP APIs.

Currently, I'm able to generate the stubs in generate-sources folder.

<!--Apache Axis plugin--> <plugin> <groupId>org.apache.axis2</groupId> <artifactId>axis2-wsdl2code-maven-plugin</artifactId> <version>1.8.0</version> </plugin> <plugin> <groupId>org.apache.axis2</groupId> <artifactId>axis2-wsdl2code-maven-plugin</artifactId> <executions> <execution> <goals> <goal>wsdl2code</goal> </goals> <phase>generate-sources</phase> <configuration> <packageName>gen.test.soapclient</packageName> <wsdlFile>${project.basedir}/src/main/resources/wsdl/Test.wsdl</wsdlFile> <outputDirectory>${project.basedir}/src/gen/cloudsdk/axis2</outputDirectory> <databindingName>adb</databindingName> <syncMode>sync</syncMode> <unpackClasses>true</unpackClasses> </configuration> </execution> </executions> </plugin>

Axis2 version - 1.8.0

Cloud SDK version - 3.53.0

Thanks,

Vijetha

jschneider
Advisor
Advisor
0 Kudos

Hi vijetha_m1870,

could you please be more specific on your use case and the current state.
I'm imaging descriptions for the following questions:

* What do you want to achieve? - Desired state
* What are you currently able to achieve? - Current state
* What are you currently missing to achieve your use case? - Gap between desired and current state

Best regards,
Johannes

View Entire Topic
Ivan-Mirisola
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi vijetha_m1870,

As far as I understand, CAP doesn't support Axis2 integration directly in Java.

It does support the client side consumption of SOAP APIs via NodeJS. For that, please check:

https://blogs.sap.com/2022/04/11/consuming-soap-web-services-in-sap-cloud-application-programming-mo...

If you choose to use the Cloud SDK for Java, there are two options:

1) Simple HTTP Client - no ORM Classes for mapping Data Types, etc:

https://sap.github.io/cloud-sdk/docs/java/features/connectivity/sdk-connectivity-http-client

2) Axis2 Java Class generation:

https://blogs.sap.com/2018/09/13/deep-dive-17-with-sap-s4hana-cloud-sdk-convenient-consumption-of-sa...

Once you have all of the stubs generated on your project, you will be able to consume the SOAP API via SoapQuery class. SoapQuery is valid not just to read data, but is supports all SOAP methods implemented by an API. Therefore, it works also for data creation when you set proper API method. This is all explained on the above blog. Please check the blog's answers as well for additional questions already answered on this topic.

What you can do with CAP and SOAP while on a Java Project is:

1) Define your CDS service for your CDS data model

2) Create an extension to your service

3) Inside the extension's method you can perform such SOAP queries using the generated Axis2

4) The results obtained from the SoapQuery can then be mapped to a result that CAP is expecting.

Best regards,
Ivan

vijetha_m1870
Explorer
0 Kudos

Hello ivan.mirisola / johannes.schneider ,

Thank you very much for your response.

I have been following the below blog, since I need to implement the client in CAP Java for consuming an external service using wsdl.

https://blogs.sap.com/2018/09/13/deep-dive-17-with-sap-s4hana-cloud-sdk-convenient-consumption-of-sa...

However, In the blog, "Disclaimer" section mentions that, the solution will work if we use lower SAP Cloud SDK version of at most 2.19.2.

Disclaimer: This blog post is only applicable for the SAP Cloud SDK version of at most 2.19.2.

I'm currently using Cloud SDK version 3.53.0 and since SoapQuery is deprecated for the current/latest version and SoapRequest is the alternative, I was unable to find the documents/blogs which would help in implementing the client.

Now I understand, currently the feature is unavailable for CAP Java.

What I'm currently trying to achieve:

I have implemented CAP Java client to consume services using OpenAPITools library. You may know OpenAPITools helps in generating java classes by taking YAML file as the input.

I'm successfully able to to consume the service and process the response.

Since I had the downloaded wsdl file, I used the same to convert it into YAML file using online converter(manually).

Currently I'm trying to use Axis2 library which would take wsdl file as input(to avoid the wsdl to yaml conversion) to generate stubs and helps to implement the client.

What have I achieved so far:

Currently I'm able to generate the stubs using Axis2 plugin(version 1.8.0) and Cloud SDK version 3.53.0, by following the blog.

https://blogs.sap.com/2018/09/13/deep-dive-17-with-sap-s4hana-cloud-sdk-convenient-consumption-of-sa...

What are you currently missing to achieve your use case:

With the Axis2 generated stubs I'm unable to proceed with client implementation using SoapRequest, as I haven't found latest docs/blogs.

As I understand, I wouldn't be to able to implement the client using Axis2 plugin, so looking for an alternative solution which uses wsdl to implement the client.

Also I'm unsure if there are alternate plugins, if not Axis2 framework to integrate with Cloud SDK in SAP CAP Java for consuming external services.

Thanks,

Vijetha

Ivan-Mirisola
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi vijetha_m1870,

According to the following post:

https://blogs.sap.com/2019/08/01/migrate-to-version-3.0.0-of-the-sap-cloud-sdk-for-java/

SoapQuery and SoapRequest will work just the same. It is just a class renaming.

Best regards,
Ivan

vijetha_m1870
Explorer
0 Kudos

Hi ivan.mirisola ,

Thank you for the response and your time.
Currently, I'm trying to post the request via APIM using SoapRequest.
I'm somehow unable to set the request headers and few custom headers in the request.
Also the target URL present in the wsdl is the direct URL to the service and not the APIM url to which I ideally need to post the request using "Destination".
Any pointers on this would be really helpful.

Thanks,

Vijetha

Ivan-Mirisola
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi vijetha_m1870,

I am not familiar with APIM - so please keep in mind that this is not the forum for assistance with APIM.

As far as I recall, you can use a BTP destination to store some basic information about the SOAP end-point. However, you cannot use the Destination API to make calls to this end-point as it blocks some http headers by default. I had a really hard time using it together with SAPUI5 - which turned to be impossible at the end of the day.

The solution is to use a server side http client to this SOAP end-point by reusing the destination's attributes you already have on BTP and performing a request directly by using the SAP Cloud SDK HTTP Client. Fortunately there is an example here:

https://blogs.sap.com/2022/04/11/consuming-soap-web-services-in-sap-cloud-application-programming-mo...

You will see the code required for SOAP requests using BTP's destination definition right below figure 13.

Best regards,
Ivan