Skip to Content
Author's profile photo Former Member

Dynamic Configuration of Some Communication Channel Parameters using Message Mapping

With XI 3.0 SP14, some paramters in the Integration Directory’s Communication Channel can be dynamically determined during runtime.  A couple of examples are the filename and directory used by the File Receiver Adapter.  The values for filename and directory can be obtained from the payload of the XML message.

Now, with XI 3.0 SP16, these values plus many additional ones can also be dyanmically configured using mapping programs, e.g. Message Mapping. In addition, many of these parameters are not available for dynamic configuration by using the Communication Channel as you can do with filename and directory.

For example, for an HTTP Receiver Adapter, the URL can be dynamically assigned with Message Mapping. In addition, the HTTP Header fields can also be assigned within Message Mapping.

Another benefit of using Message Mapping is that the value to be assigned does not have to be in the payload of the XML message, as what the File Receiver Communication Channel configuration requires in the case of filename and directory.

How do we determine which parameters can be assigned with a mapping program? Well, they will be listed in each of the Communication Channel configuration section, “Adapter-Speocific Message Attributes”. Once the option, “Use Adapter-Speocific Message Attributes”, is checked, all the values will be displayed.

For the discussion here, we will use the HTTP Receiver Adapter as an example. We will assign a value to the HTTP header, DOCTYPE, using Message Mapping.

Here are the steps:

  • Configure the HTTP Receiver Communication Channel.

    In the section, “Adapter-Speocific Message Attributes”, check the options: “Use Adapter-Speocific Message Attributes” and “Apply HTTP Header Fields”. Enter “DOCTYPE” in “Field 1”. This will be the HTTP header name.


image

    1. Create a user-function in Message Mapping:


image

The source code is below:

(Please note “HeaderFieldOne” is the technical name for “Field 1” in the Communication Channel configuration. The namespace used is also specific to the adapter. Please reference help.sap.com for the namespace and technical names.)

    1. Use the user-function in Message Mapping:


image


ALL_HTTP=HTTP_CONNECTION:close
HTTP_CONTENT_LENGTH:123
HTTP_CONTENT_TYPE:text/xml
HTTP_ACCEPT:/
HTTP_ACCEPT_ENCODING:gzip
HTTP_HOST:nspad391.pal.sap.corp
HTTP_USER_AGENT:SAP Web Application Server (1.0;640)
HTTP_DOCTYPE:SalesOrder


ALL_RAW=Connection: close
Content-Length: 123
Content-Type: text/xml
Accept: /
Accept-Encoding: gzip
Host: nspad391.pal.sap.corp
User-Agent: SAP Web Application Server (1.0;640)
doctype: SalesOrder


The header “DOCTYPE” is assigne the value “SalesOrder”.

Assigned Tags

      21 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member
      Hello William,

      This means we can get rid of our XSLT mappings to insert DOCTYPE tags for outgoing http I think

      Could this also help us getting rid of the DOCTYPE header field with incoming http? So far we have had no luck getting the working xslt for this to actually work in XI as well

      Kind regards
      Tom

      Author's profile photo Former Member
      Former Member
      Blog Post Author
      Hi Tom,
      I am uncertain of your question.  Can you give an example of what you wish to do?  Is it related to an HTTP adapter, in setting HTTP header info?

      This weblog only uses DOCTYPE as an arbitrary example.  In this weblog example, DOCTYPE is an HTTP header sent to a receiving HTTP application.

      The information that can be configured during runtime depend on the adapter being used.

      Thanks,
      Bill

      Author's profile photo Former Member
      Former Member
      Hello Bill

      We have a receiver HTTP which sends out a request message and receives a response. This response contains the !DOCTYPE tag.

      Before mapping the response message to its target I think the !DOCTYPE must be removed from the response message. A way to do this would be a simple XSLT mapping. But since this does not seem to work I was wondering if there might be another solution to this.

      Sorry if it is slightly off topic

      Kind regards
      Tom

      Author's profile photo Former Member
      Former Member
      Blog Post Author
      Hi Tom,
      Yes, this is slightly off the topic 🙂

      There is a method to accomplish what you want.  It will require java mapping.

      In Interface Mapping, you can assign multiple mapping steps.  Each mapping step is a mapping program, which can be Message Mapping, XSLT, Java or even ABAP.

      In your case, the 1st mapping step for the response can be a java mapping.  The java mapping program will simply edit the payload to get rid of the !DOCTYPE.  The java mapping program will read the payload exactly as is; it will not validate anything.  So, you can read the payload into a String and modify it.  The output will be sent to the 2nd mapping, which can be Message Mapping.

      Regards,
      Bill

      Author's profile photo Former Member
      Former Member
      I am not able to see the input boxes for the header fields or the URL etc. This does not work for the SOAP adapter either. We are on XI 7.0 SP 7. Any idea?
      Author's profile photo Former Member
      Former Member
      Blog Post Author
      Hi,
      You should see them if you check the box, "Use Adapter-specific Message Attributes", and then, check the box for "Apply HTTP Header Fields".

      Regards,
      Bill

      Author's profile photo Former Member
      Former Member
      In the Receiver SOAP adapter comm. channel, I am not seeing the "Apply HTTP header fields that you mention". All I see is the "Variable Transport Binding" which when I check, I see some authorization releated fields but no check box for URL or other header fields.
      Author's profile photo Former Member
      Former Member
      Blog Post Author
      Hi,

      The Header fields are only available for the HTTP adapter.  Pls reference the SOAP adapter documentation in SAP Help for what is available for the SOAP adapter and their usage.

      Regards,
      Bill

      Author's profile photo Kurt Rasmussen
      Kurt Rasmussen
      Hi William, this BLOG was exactly what i needed for a customerproject. But I was not setting the header fields. Instead I wanted to dynamically set some URL parameters. (URLParamOne-URLParamThree. I used your Java coding.
      I discovered the querystring was too long (228 char). I split it up in three, created three user defined functions and transferred to different ellements in target structure.
      And voila! It worked! I can now build a very long url dynamically based on the mapping.
      However this raises some questions about limitations or max lenght on each URL parameter.
      I also discovered that URL escaping must be disabled on the communication channel. (That could be related to the target service.
      Kind regards
      Kurt
      Author's profile photo Former Member
      Former Member
      Hi William,
      from your experience is there any chance to do the same by script in java shell?
      For instance there is any chance to switch a communcation channel at a moment?
      I see there is possibility to switch off a service but i do not know relating a single CC.

      thanks for any suggestions

      Author's profile photo Former Member
      Former Member
      Blog Post Author
      Hi Giovanni,
      The method described in this blog cannot do what you wanted to do.

      In a near future release, there will be capability to turn off a specific CC.  I do not the exact SP level.

      As for switching a CC, there might be a work-around.  You can use a multi-mapping (1-to-many).  You can assign the source to specific target interface.  Then, using Interface Determination in the Integration Directory to assign the target interface to specific CC.

      Regards,
      Bill

      Author's profile photo Former Member
      Former Member
      Hi Bill,
      thanks for your answer.
      I will discuss it wih the customer.
      thannks for your fast answer and sorry for my delay :-).

      Regards,
      Giamma

      Author's profile photo Former Member
      Former Member
      Hi,

      first of all thanks for your nice blog
      conf.put(keyHeader1, a);

      you never definied variable a in the code. is this refer to target url? if so can you specify how to define the Targeturl. appreciate for your time

      Author's profile photo Former Member
      Former Member
      Blog Post Author
      The URL can be configured using the example below:

      Addressing Type:  URL Addresses
      Target Host:  nspad391.pal.sap.com
      Service Number:  80
      Path:  /saveHTTPinfo.asp

      Author's profile photo Former Member
      Former Member
      Hi Bill,
      I went through your blog and it is a great one and i was able to get the parameter through mapping .. but i have an issue that mineis a IDOC to FIle interface and im getting the Idoc number but when i use the Use Temp file name my file name is padded with MSGID which i don't want, Is there any way to eliminate the MSG id.

      thankx,
      sri..

      Author's profile photo Former Member
      Former Member
      Blog Post Author
      Hi,
      I think by using Temp File name, it will try to make the filename unique.  Apparently, you do not have as many options.

      Can you use, write "directly", which give you much more options?

      Regards,
      Bill

      Author's profile photo Former Member
      Former Member
      Hi,

      I am sending a Binary file and want to extract its name and send to a separate receiver(may be a web service).
      My custom code for this is below:

      public String fnExtractName(Container container){

         //write your code here

      DynamicConfiguration conf = (DynamicConfiguration)container.getTransformationParameters( ).get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

      DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File",
      "FileName");

      String valueOld = (String)conf.get(key);

      if (valueOld != null) {
      AbstractTrace trace = container.getTrace();
      trace.addInfo("Got the name of the file"+valueOld);
      return valueOld;
      }
      else
      return "hello";
      }

      The problem is that I am unable to get the file name during Testing in interface mapping.

      Author's profile photo Kiran Sakhardande
      Kiran Sakhardande

      Hello Bill,

      Author's profile photo Former Member
      Former Member
      Hi Li,
      Thanks for this excellent blog
      but though you gave HEADERFIELD ONE:DOCTYPE
      at target its showing
      doctype:SalesOrder.
      that is its showing the header field name in smaller case rather than showing it in uppercase that you have given(ie doctype instead of DOCTYPE).
      I have a requirement which needs the same to be in uppercase.What should i do?

      ALL_HTTP=HTTP_CONNECTION:close
      HTTP_CONTENT_LENGTH:123
      HTTP_CONTENT_TYPE:text/xml
      HTTP_ACCEPT:*/*
      HTTP_ACCEPT_ENCODING:gzip
      HTTP_HOST:nspad391.pal.sap.corp
      HTTP_USER_AGENT:SAP Web Application Server (1.0;640)
      HTTP_DOCTYPE:SalesOrder

      ALL_RAW=Connection: close
      Content-Length: 123
      Content-Type: text/xml
      Accept: */*
      Accept-Encoding: gzip
      Host: nspad391.pal.sap.corp
      User-Agent: SAP Web Application Server (1.0;640)
      doctype: SalesOrder

      Author's profile photo Former Member
      Former Member
      hi, i am trying to do same kind of header customisation, but with XHeaderName1 for mail header fields like content-type, content-disposition, but it doesn't works ... Someone can help me ?
      Author's profile photo Rafael Vieira
      Rafael Vieira

      Hi William.

      Does this work in PI AEX (HTTP Receiver setting URL dynamically)?

      If yes, could you give your thoughts on how to achieve such?

      Tks!