Blog Post

How to Modify SOAP Header in SAP CPI?

March 29, 2024

What Are SOAP Headers?

SOAP (Simple Object Access Protocol) headers are part of the SOAP envelope and contain additional information about the SOAP message. While the SOAP body carries the actual data, the header carries metadata and control information. This metadata can include authentication credentials, message routing instructions, and custom parameters necessary for processing the message on the recipient's end.

The Significance of SOAP Headers

SOAP headers play a pivotal role in ensuring secure and efficient communication between different systems. They enable features such as authentication, encryption, and message routing, making them a vital component of web service integration.

Modifying SOAP Headers in SAP CPI

Now that we have a clear understanding of SOAP headers, let's explore how to modify them within the SAP Cloud Platform Integration environment. To accomplish this task, we'll follow a systematic approach.

Prerequisites

To get started with SOAP requests in SAP Cloud Integration, you'll need to ensure you have the following prerequisites in place:

  1. SAP Cloud Integration Account: You must have access to an SAP Cloud Integration account. If you don't have one, you can sign up on the SAP website.
  2. Access to Web Services: Ensure that you have access to the web services you want to interact with using SOAP requests. You should have the endpoint URLs and necessary authentication credentials.

In SAP CPI when you uses the SOAP as the Sender and give the SOAP request to the Body of Content Modifier you  have to supply Soap envelope and header value in the request message, because the connector already removes the envelope and header by default.

While using the SOAP as the receiver you do not have to supply the SOAP envelope and header value to the request message as SOAP adapter already adds the envelope and header by default.

Considering you have the following Request payload and you have SOAP as the receiver.

You can write the above SOAP request in the following way.

  • Remove the SOAP Header and body from the payload.
  • Provide the xmlns to each node of XML.
  • You can also change the tags.

With this changes your Request will be like this as shown below.

In most of the Scenarios, We encounter some cases in which we have to pass the values inside the headers of the SOAP request, and in that scenarios the standard connectors will not pass the value to Soap header by default.

In some SAP Middleware like in SAP PI/PO there is an option do "Do Not use SOAP Envelope" by simple configuration and then pass the attributes in the Message mapping.

But in SAP CPI we do not have this option.

To manipulate the SOAP header, you have to use the platform script, i.e. Groovy Script, and example of the Groovy Script is shared below

The Resulting SOAP Header with part of SOAP Request will be :

You can also check the help.sap.com to learn more about this script.

In this way you can modify the SOAP Header.

Best Practices for Using SOAP Requests

To ensure the success of your integration projects using SOAP requests in SAP Cloud Integration, consider the following best practices:

  • Keep Security in Mind: Always use secure and encrypted communication when dealing with sensitive data through SOAP requests.
  • Error Handling: Implement robust error-handling mechanisms to handle unexpected issues gracefully.
  • Optimize Performance: Fine-tune your integration flows for optimal performance to minimize latency.
  • Documentation: Maintain comprehensive documentation of your integration flows for reference and troubleshooting.
  • Regular Updates: Stay updated with the latest features and improvements in SAP Cloud Integration to leverage new capabilities.

Conclusion

In the realm of SAP CPI, the ability to modify SOAP headers is a valuable skill for developers and administrators. Understanding the significance of SOAP headers and following a systematic approach to modify them within SAP CPI can streamline integration processes and ensure smooth communication between systems.

Remember that while modifying SOAP headers is a powerful capability, it should be used judiciously and in accordance with your integration requirements. With the knowledge and steps outlined in this guide, you are well-equipped to navigate the intricacies of SOAP header modification in SAP CPI and enhance your integration projects.

LinkedIn 
Forbes Technology Council, Official Member (2022)
LinkedIn
Forbes Technology Council, Official Member (2022)

About the Author

Jaspreet is an Executive Consultant with expertise in SAP, SaaS/Cloud Integrations, Cyber Security and Data Science. Jaspreet is hands-On Architect who does Pre-Sales, Solution Architecture, Development, Lead Delivery of Complex Integration programs, Manage disperse teams and Ensure successful Project Go-Live/Goals. He has made a lasting impact on global businesses IT projects including Aflac, Advanced Energy, Donnelley Financial Solutions(DFIN), Dell EMC and many more.

Do you want to
learn more about integration?

We are dedicated to make our knowledge accessible. You can either figure it out by yourself or you can let us give you a hand.

Let us take care of your integration.

We are SAP Certified and we can make your project happen. Explore our services and contact us. We will be happy to take on your project.

View Our Services