{"id":2649,"date":"2019-08-12T08:31:26","date_gmt":"2019-08-12T07:31:26","guid":{"rendered":"https:\/\/www.int4.com\/?p=2649"},"modified":"2020-04-28T17:25:18","modified_gmt":"2020-04-28T16:25:18","slug":"sap-cpi-control-your-messages-with-custom-header","status":"publish","type":"post","link":"https:\/\/test11988.futurehost.pl\/sap-cpi-control-your-messages-with-custom-header","title":{"rendered":"SAP CPI: Control your messages with custom header"},"content":{"rendered":"
<\/p>\n

Introduction<\/h3>\n

Recently<\/span> I <\/span>encountered<\/span> a <\/span>basic<\/span> router <\/span>scenario<\/span>. <\/span>However<\/span> the <\/span>information<\/span> I <\/span>could<\/span> <\/span>use<\/span> as a <\/span>condition<\/span> was not <\/span>included<\/span> in the <\/span>message<\/span> <\/span>itself<\/span>. I <\/span>had<\/span> to pass <\/span>it<\/span> to CPI, but <\/span>didn’t<\/span> want to<\/span> <\/span>enrich<\/span> the <\/span>message<\/span> and mess <\/span>it<\/span> up<\/span>.<\/span> I <\/span>figured<\/span> out <\/span>that<\/span> <\/span>custom<\/span> <\/span>header<\/span> <\/span>would<\/span> be the <\/span>great<\/span> <\/span>solution<\/span>, <\/span>however<\/span> as <\/span>it<\/span> <\/span>occurred<\/span>, <\/span>it<\/span> <\/span>wasn’t<\/span> <\/span>so<\/span> <\/span>easy<\/span> (<\/span>now<\/span> <\/span>it<\/span> <\/span>is<\/span> of <\/span>course<\/span>).<\/span><\/span><\/span><\/p>\n

\n<\/div>\n

Steps<\/span><\/h2>\n

So<\/span> <\/span>you<\/span> <\/span>would<\/span> <\/span>like<\/span> to pass a <\/span>custom<\/span> <\/span>header<\/span> to CPI.<\/span><\/p>\n

SoapUI<\/span><\/h3>\n

In <\/span>SoapUI<\/span> <\/span>you<\/span> <\/span>would<\/span> pass <\/span>it<\/span> on <\/span>like<\/span> <\/span>this<\/span>:<\/span><\/p>\n

\"SAP<\/a>\"SoapUI<\/a><\/p>\n

 <\/p>\n

ABAP<\/span><\/h3>\n

In ABAP<\/span> <\/span>it<\/span> <\/span>is<\/span> <\/span>possible<\/span> <\/span>thanks<\/span> to the <\/span>best<\/span> <\/span>library<\/span> <\/span>cl_http_client<\/span>:<\/span><\/p>\n

\n


\n<\/span>\u00a0\u00a0\u00a0\u00a0<\/span>lo_httpclient<\/span>-><\/span>request<\/span>-><\/span>set_header_field<\/span>(<\/span>
\n<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span>name<\/span>\u00a0\u00a0<\/span>=\u00a0<\/span>‘<\/span>CustomHeader<\/span>‘<\/span>
\n<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span>value<\/span>\u00a0<\/span>=\u00a0<\/span>‘<\/span>100<\/span>‘<\/span> ).<\/span><\/p>\n<\/blockquote>\n

SAP CPI<\/span><\/h3>\n

<\/span>This<\/span> <\/span>is<\/span> the most <\/span>important<\/span> step – <\/span>you<\/span> <\/span>need<\/span> to <\/span>enable<\/span> <\/span>custom<\/span> <\/span>headers<\/span> <\/span>so<\/span> CPI <\/span>can<\/span> <\/span>accept<\/span> <\/span>them<\/span>. Just go to <\/span>your<\/span> <\/span>iFlow<\/span>, <\/span>click<\/span> on the <\/span>white<\/span> <\/span>space<\/span> <\/span>behind<\/span> the <\/span>flow<\/span> and <\/span>you<\/span> <\/span>will<\/span> be <\/span>displayed<\/span> a “Integration <\/span>Flow<\/span>” menu. Go to “Runtime <\/span>Configuration<\/span>” and <\/span>fill<\/span> “<\/span>Allowed<\/span> <\/span>Header<\/span>(s)”.<\/span><\/p>\n

\"SAP<\/a><\/p>\n

 <\/p>\n

You could also type *. In this case CPI would accept all incoming headers.<\/span><\/p>\n

Read your header<\/span><\/h2>\n

Now your custom header will be visible in CPI. In order to read the value use the expression<\/span><\/p>\n

${header.CustomHeader}. Of course you could get access to any header using such expression. In my case I would use it in router step.<\/span><\/p>\n

 <\/p>\n

\"SAP<\/a><\/p>\n

Summary<\/span><\/h2>\n

I think it is a smarter and safer way to control your message flow. Instead of messing with payload you “hide” your controls in different part of message exchange. What do you think?<\/span><\/p>\n

 <\/p>\n","protected":false},"excerpt":{"rendered":"

Steps So you would like to pass a custom header to CPI. SoapUI In SoapUI you would pass it on like this:   ABAP In ABAP it is possible thanks to the best library cl_http_client: \u00a0\u00a0\u00a0\u00a0lo_httpclient->request->set_header_field( \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0name\u00a0\u00a0=\u00a0‘CustomHeader‘ \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0value\u00a0=\u00a0‘100‘ ). SAP CPI This is the most important step – you need to enable custom headers so […]<\/p>\n","protected":false},"author":17,"featured_media":5278,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"content-type":""},"categories":[1],"tags":[7,74,45],"acf":[],"yoast_head":"\nSAP CPI: Control your messages with custom header - INT4<\/title>\n<meta name=\"description\" content=\"SAP CPI: Custom header is a smarter and safer way to control your message flow. Instead of messing with payload you ?hide? your controls in different part of message exchange.\" \/>\n<meta name=\"robots\" content=\"noindex, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SAP CPI: Control your messages with custom header - INT4\" \/>\n<meta property=\"og:description\" content=\"SAP CPI: Custom header is a smarter and safer way to control your message flow. Instead of messing with payload you ?hide? your controls in different part of message exchange.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/test11988.futurehost.pl\/sap-cpi-control-your-messages-with-custom-header\" \/>\n<meta property=\"og:site_name\" content=\"INT4\" \/>\n<meta property=\"article:published_time\" content=\"2019-08-12T07:31:26+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-04-28T16:25:18+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/test11988.futurehost.pl\/wp-content\/uploads\/2019\/08\/CPI_custom_header_Halicki_p10.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"627\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Andrzej Halicki\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Andrzej Halicki\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/test11988.futurehost.pl\/sap-cpi-control-your-messages-with-custom-header\",\"url\":\"https:\/\/test11988.futurehost.pl\/sap-cpi-control-your-messages-with-custom-header\",\"name\":\"SAP CPI: Control your messages with custom header - INT4\",\"isPartOf\":{\"@id\":\"https:\/\/test11988.futurehost.pl\/#website\"},\"datePublished\":\"2019-08-12T07:31:26+00:00\",\"dateModified\":\"2020-04-28T16:25:18+00:00\",\"author\":{\"@id\":\"https:\/\/test11988.futurehost.pl\/#\/schema\/person\/4b9dd6ed1d0ca8054d444b47bb2393fd\"},\"description\":\"SAP CPI: Custom header is a smarter and safer way to control your message flow. Instead of messing with payload you ?hide? your controls in different part of message exchange.\",\"breadcrumb\":{\"@id\":\"https:\/\/test11988.futurehost.pl\/sap-cpi-control-your-messages-with-custom-header#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/test11988.futurehost.pl\/sap-cpi-control-your-messages-with-custom-header\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/test11988.futurehost.pl\/sap-cpi-control-your-messages-with-custom-header#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/test11988.futurehost.pl\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SAP CPI: Control your messages with custom header\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/test11988.futurehost.pl\/#website\",\"url\":\"https:\/\/test11988.futurehost.pl\/\",\"name\":\"INT4\",\"description\":\"Your soft landing in SAP API testing\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/test11988.futurehost.pl\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/test11988.futurehost.pl\/#\/schema\/person\/4b9dd6ed1d0ca8054d444b47bb2393fd\",\"name\":\"Andrzej Halicki\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/test11988.futurehost.pl\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/39edd33be18263d68f44ff45057e7227?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/39edd33be18263d68f44ff45057e7227?s=96&d=mm&r=g\",\"caption\":\"Andrzej Halicki\"},\"description\":\"Andrzej Halicki is an SAP integration consultant and developer. He has strong experience in ABAP development across local and international projects. Andrzej works with the latest solutions like ABAP for HANA and Cloud Platform Integration. Author of many technical articles that are available online in the SAP Community and Int4 website.\",\"url\":\"https:\/\/test11988.futurehost.pl\/author\/ahal\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SAP CPI: Control your messages with custom header - INT4","description":"SAP CPI: Custom header is a smarter and safer way to control your message flow. Instead of messing with payload you ?hide? your controls in different part of message exchange.","robots":{"index":"noindex","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"og_locale":"en_GB","og_type":"article","og_title":"SAP CPI: Control your messages with custom header - INT4","og_description":"SAP CPI: Custom header is a smarter and safer way to control your message flow. Instead of messing with payload you ?hide? your controls in different part of message exchange.","og_url":"https:\/\/test11988.futurehost.pl\/sap-cpi-control-your-messages-with-custom-header","og_site_name":"INT4","article_published_time":"2019-08-12T07:31:26+00:00","article_modified_time":"2020-04-28T16:25:18+00:00","og_image":[{"width":"1200","height":"627","url":"https:\/\/test11988.futurehost.pl\/wp-content\/uploads\/2019\/08\/CPI_custom_header_Halicki_p10.png","type":"image\/png"}],"author":"Andrzej Halicki","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Andrzej Halicki","Estimated reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/test11988.futurehost.pl\/sap-cpi-control-your-messages-with-custom-header","url":"https:\/\/test11988.futurehost.pl\/sap-cpi-control-your-messages-with-custom-header","name":"SAP CPI: Control your messages with custom header - INT4","isPartOf":{"@id":"https:\/\/test11988.futurehost.pl\/#website"},"datePublished":"2019-08-12T07:31:26+00:00","dateModified":"2020-04-28T16:25:18+00:00","author":{"@id":"https:\/\/test11988.futurehost.pl\/#\/schema\/person\/4b9dd6ed1d0ca8054d444b47bb2393fd"},"description":"SAP CPI: Custom header is a smarter and safer way to control your message flow. Instead of messing with payload you ?hide? your controls in different part of message exchange.","breadcrumb":{"@id":"https:\/\/test11988.futurehost.pl\/sap-cpi-control-your-messages-with-custom-header#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/test11988.futurehost.pl\/sap-cpi-control-your-messages-with-custom-header"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/test11988.futurehost.pl\/sap-cpi-control-your-messages-with-custom-header#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/test11988.futurehost.pl\/"},{"@type":"ListItem","position":2,"name":"SAP CPI: Control your messages with custom header"}]},{"@type":"WebSite","@id":"https:\/\/test11988.futurehost.pl\/#website","url":"https:\/\/test11988.futurehost.pl\/","name":"INT4","description":"Your soft landing in SAP API testing","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/test11988.futurehost.pl\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-GB"},{"@type":"Person","@id":"https:\/\/test11988.futurehost.pl\/#\/schema\/person\/4b9dd6ed1d0ca8054d444b47bb2393fd","name":"Andrzej Halicki","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/test11988.futurehost.pl\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/39edd33be18263d68f44ff45057e7227?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/39edd33be18263d68f44ff45057e7227?s=96&d=mm&r=g","caption":"Andrzej Halicki"},"description":"Andrzej Halicki is an SAP integration consultant and developer. He has strong experience in ABAP development across local and international projects. Andrzej works with the latest solutions like ABAP for HANA and Cloud Platform Integration. Author of many technical articles that are available online in the SAP Community and Int4 website.","url":"https:\/\/test11988.futurehost.pl\/author\/ahal"}]}},"_links":{"self":[{"href":"https:\/\/test11988.futurehost.pl\/wp-json\/wp\/v2\/posts\/2649"}],"collection":[{"href":"https:\/\/test11988.futurehost.pl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/test11988.futurehost.pl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/test11988.futurehost.pl\/wp-json\/wp\/v2\/users\/17"}],"replies":[{"embeddable":true,"href":"https:\/\/test11988.futurehost.pl\/wp-json\/wp\/v2\/comments?post=2649"}],"version-history":[{"count":0,"href":"https:\/\/test11988.futurehost.pl\/wp-json\/wp\/v2\/posts\/2649\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/test11988.futurehost.pl\/wp-json\/wp\/v2\/media\/5278"}],"wp:attachment":[{"href":"https:\/\/test11988.futurehost.pl\/wp-json\/wp\/v2\/media?parent=2649"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/test11988.futurehost.pl\/wp-json\/wp\/v2\/categories?post=2649"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/test11988.futurehost.pl\/wp-json\/wp\/v2\/tags?post=2649"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}