banner



How To Set The Response Time In Soap Service

A Soap messages consists of Lather headers and a Soap trunk wrapped by a Lather envelope. The SOAP trunk can exist accessed and modified in the integration flow. With the 14-April-2019 release it is also possible to access SOAP headers received past a sender channel and to set Lather headers to exist sent to a receiver system.

This web log describes how Soap headers can exist processed in an integration flow.

Example Integration Catamenia

The instance shows how Lather headers tin can be ready in the request and in the response message and how they can be evaluated within the integration menstruum. I use one integration process (Integration Process I) to build a message that contains an boosted SOAP header. This process is started by a SOAP message that is received by a Lather sender channel. Thus, y'all could utilize a tool like SOAPUI to create a Lather message with an arbitrary Soap trunk and send information technology to this channel. Some other possibility to start a scenario would exist to use a timer step and a content modifier to set an XML payload in the integration period.

A second integration flow (Integration Process II) receives the request message with the added Lather header, evaluates the content and adds another SOAP header for the response that is sent back to the starting Integration Procedure I. The response header is also evaluated.

Instead of using 2 integration processes ane tin can as well use two divide integration flows.

There are iii new methods available in the Bulletin interface to procedure SOAP headers:

  • Method getSoapHeaders: This method returns a listing (blazon ArrayList) of SOAP headers represented by objects of type SoapHeader. This list is filled later on a message was received past channel.
  • Method setSoapHeaders: This method can exist used to set SOAP headers in a request or response bulletin before the message is sent. The types used are the same equally in setSoapHeaders: instances of SoapHeader in an ArrayList object are passed as parameter.
  • Method clearSoapHeaders: This method can be used to remove Soap headers that were received. Therefore, they will not be propagated to avoid undesired consequences. No parameter needs to exist set, and the method returns no issue.

Prerequisite

Due to the complex objects (a SOAP header is based on XML) the SOAP header processing can but be done in a script stride. Therefore, some bones knowledge almost Groovy script and how to create a script step in an integration menstruation is required to understand all aspects of this blog.

Integration Process I

A Soap sender which could be a Lather UI client or whatever other tool/arrangement that tin can send SOAP messages sends a message to Integration Process I. Now I want to add a SOAP header to send the original payload including the added header to the SOAP receiver 'Receiver'. Be aware that I apply a Request-Reply call to the receiver organisation. The reason is I want to evaluate the response returned past the receiver system. For simplicity I use a receiver channel without WSDL configuration.

Let the states assume I want or I must send a message identifier to the receiver organisation via SOAP header. I use the Soap header that is divers for the SAP RM protocol. I have added the script step 'SetRequestSoapHeader' to add this header via Groovy script:

          import com.sap.gateway.ip.core.customdev.util.Message; import javax.xml.namespace.QName; import com.sap.gateway.ip.cadre.customdev.util.SoapHeader;  def Message processData(Message message) {     //Trunk         def headers = new ArrayList();        def xml = "<?xml version=\"ane.0\" encoding=\"utf-eight\"?><messageId xmlns=\"http://www.sap.com/webas/640/lather/features/messageId/\" xmlns:soap=\"http://schemas.xmlsoap.org/lather/envelope/\">urn:uuid:4CF78C4F-7395-9312-E100-00000A4286B3</messageId>";        def header = new SoapHeader(new QName("http://www.sap.com/webas/640/lather/features/messageId/", "messageId"), xml, false, "");        headers.add(header);        message.setSoapHeaders(headers);        return message; }                  

The goal is to create an instance of form com.sap.gateway.ip.core.customdev.util.SoapHeader. I use the constructor of the form that allows passing the header as cord. For simplicity I use a constant string where the messageId is set. A variable messageId could be fix using string operations. Be aware that you must mask double quotes ('"') as shown in this example. If the operations are more than complex to obtain the header information technology tin can be beneficial to use a DOM parser/renderer to create the header and set an element instance instead of the cord instance. The qualified name that identifies the type of the header is set by creating an example of javax.xml.namespace.QName. The value for the SAP RM bulletin id header is gear up. MustUnderstand is ready to false. That means that if the receiver does not know the header he can ignore it. If I set MustUnderstand to truthful in our scenario  I must declare the header in the WSDL of the sender channel of Integration Process Two. Actor is gear up to an empty string. In the integration flow Histrion is not evaluated by the aqueduct and tin therefore be freely used for your ain purposes. The header object is added to an array listing and the method setSoapHeaders of the bulletin interface is chosen. That is all. You lot can add other headers by using the same method at whatever place in your Integration Menses before you lot send the message.

Before I now move on to Integration Process II to see how this header is evaluated, let me go on this process and show how the response Lather header is processed. As already mentioned I use a Request-Answer telephone call to contact the receiver system. That ways I can go on modelling the menstruation after calling the receiver channel and process the response.

The script footstep GetResponseSoapHeader is doing that:

          import com.sap.gateway.ip.core.customdev.util.Message; import com.sap.gateway.ip.core.customdev.util.SoapHeader;   def Message processData(Message message) {        def headers = new ArrayList();        headers = bulletin.getSoapHeaders();        if(headers.size !=ane){            throw new Exception("no Lather header found");        }        def header = headers.get(0);        qname=header.getQname();        if(!qname.getNamespaceURI().equals("http://www.sap.com/webas/640/soap/features/messageId/")){            throw new Exception("incorrect namespace");        }        if(!qname.getLocalPart().equals("messageId")){            throw new Exception("wrong name");        }        message.setHeader("SapMessageIdEx", header.getElement().getTextContent());        message.clearSoapHeaders();        render message; }                  

The method getSoapHeaders of the bulletin interface returns the headers in an array list. Showtime a few checks are executed. There should exist exactly one SOAP header (headers.size()!=i) and then the qualified name (qname) should exist the expected one, name and namespace must match. I utilize again the same header for the response as for the request. That ways I receive a message id. The header representation in the com.sap.gateway.ip.core.customdev.util.SoapHeader example is at present an Element instance. The method getTextContent of Element returns a string representation of the header content and in this case the message id. For more circuitous header structures, the Element is only the starting betoken to a complex DOM tree and the DOM parser API must be used to get the desired information. Equally an example, I ready the integration flow header SapMessageIdEx from the result. Equally a final step I delete the SOAP header received by calling the method clearSoapHeaders of the bulletin interface. As a result, the header will not be propagated back to the sender.

Integration Procedure II

The message is received via Soap sender aqueduct. No WSDL is configured here. Every bit a start stride the SOAP header is evaluated in the script pace GetRequestSoapHeader.

          import com.sap.gateway.ip.core.customdev.util.Message; import com.sap.gateway.ip.cadre.customdev.util.SoapHeader;   def Message processData(Message message) {        def headers = new ArrayList();        headers = message.getSoapHeaders();        if(headers.size !=1){            throw new Exception("no Lather header establish");        }        def header = headers.go(0);        qname=header.getQname();        if(!qname.getNamespaceURI().equals("http://www.sap.com/webas/640/soap/features/messageId/")){            throw new Exception("wrong namespace");        }        if(!qname.getLocalPart().equals("messageId")){            throw new Exception("wrong proper noun");        }        bulletin.setHeader("SapMessageIdEx", header.getElement().getTextContent());        return message; }                  

In fact, the same steps equally in the script step GetResponseSoapHeader were executed. It is checked whether the correct header was received, and then the header is processed and afterwards the header is deleted. If the header is not deleted it will be sent back equally role of the response in this scenario and Integration Process I will receive two message id headers.

The script step SetResponseSoapHeader sets a message id Lather header that contains a different message id.

          import com.sap.gateway.ip.core.customdev.util.Message; import com.sap.gateway.ip.core.customdev.util.SoapHeader; import javax.xml.namespace.QName; def Bulletin processData(Message message) {        message.clearSoapHeaders();        def headers = new ArrayList();        def xml = "<?xml version=\"1.0\" encoding=\"utf-viii\"?><messageId xmlns=\"http://www.sap.com/webas/640/soap/features/messageId/\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">urn:uuid:4CF78C4F-7395-9312-E100-00000A4286B4</messageId>";        def header = new SoapHeader(new QName("http://www.sap.com/webas/640/soap/features/messageId/", "messageId"), xml, imitation, "");        headers.add together(header);        bulletin.setSoapHeaders(headers);        return message; }                  

This step is very like to the script SetRequestSoapHeader.

Execution

To see how the integration menses is executed, I enable MPL log level Trace and check the message content at the receiver channel:

When I now switch to the message content I see three messages. The first 1 is the original message:

The second one is the message after the additional SOAP header was added:

And the third message is the response message sent by Integration Process II:

Summary

You lot have learned how to set a SOAP header in a SOAP request and access it in an receiver integration flow using script steps. I showed the same for the SOAP response. The result of the change tin be visualized using the existing MPL.

Please share feedback in comments

How To Set The Response Time In Soap Service,

Source: https://blogs.sap.com/2019/04/08/cloud-integration-accessing-and-setting-soap-headers-in-an-integration-flow/

Posted by: jaynesdiouse.blogspot.com

0 Response to "How To Set The Response Time In Soap Service"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel