Skip to content

Commit

Permalink
fix(on-error): fix content-type in case of response coming from the o…
Browse files Browse the repository at this point in the history
…n-error api product policy
  • Loading branch information
CianoDanilo authored and pasqualespica committed Jan 16, 2025
1 parent 7fd2747 commit b961501
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/core/api_product/nodo_pagamenti_api/on_error_soap_req.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<trace source="first-when" severity="information">execute on-error request</trace>
<choose>
<when condition="@(context.Variables.ContainsKey("soapAction") && context.Variables.GetValueOrDefault<string>("soapAction", "")!= "")">
<set-variable name="contentType" value="text/xml"/>
<!-- SOAP requests -->
<send-request mode="new" ignore-error="true" response-variable-name="risposta">
<set-url>@{return ((string) context.Variables["baseUrl"]+"/webservices/input"); }</set-url>
Expand All @@ -26,6 +27,7 @@
</send-request>
</when>
<otherwise>
<set-variable name="contentType" value="application/json"/>
<!-- REST requests -->
<send-request mode="new" ignore-error="true" response-variable-name="risposta">
<set-url>@{return (string) context.Variables["baseUrl"] + "/" + (string)context.Request.Url.Path; }</set-url>
Expand All @@ -44,13 +46,9 @@
</choose>
<set-variable name="leggirisposta" value="@((string)((IResponse)context.Variables["risposta"]).Body.As<string>(preserveContent: true))" />
<return-response>
<choose>
<when condition="@(!((string)context.Response.Headers.GetValueOrDefault("Content-Type","NONE")).Equals("NONE"))">
<set-header name="Content-Type" exists-action="override">
<value>@(context.Response.Headers.GetValueOrDefault("Content-Type","")</value>
</set-header>
</when>
</choose>
<set-header name="Content-Type" exists-action="override">
<value>@((string)context.Variables["contentType"])</value>
</set-header>
<set-body>@{
string message = (string)context.Variables["leggirisposta"];
return message;
Expand Down

0 comments on commit b961501

Please sign in to comment.