简体   繁体   English

Spring Integration http出站网关POST响应不包含转义的&符号

[英]Spring Integration http outbound gateway POST response does not contain escaped ampersand

The original POST response received contains XML like below having escaped ampersand & 收到的原始POST响应包含如下所示的XML,其中包含转义&符号&

<Order>test&amp;test</Order>

But the Java application is receiving it as below where & is not escaped: 但Java应用程序正在接收它,如下所示&不进行转义:

<Order>test&test</Order>

I would prefer to receive the original XML having escaped ampersand &amp; 我更愿意收到逃脱&符号的原始XML &amp; in the XML. 在XML中。

The Spring Integration configuration used to handle POST request response is below: 用于处理POST请求响应的Spring Integration配置如下:

   <int:chain input-channel="requestChannel">
        <int-http:outbound-gateway url="http://example.com"
                                   http-method="POST"
                                   expected-response-type="java.lang.String"
                                   request-factory="requestFactory"
                                   charset="UTF-8"                                   
    />
    </int:chain>

   <bean id="requestFactory"
         class="org.springframework.http.client.SimpleClientHttpRequestFactory">
        <property name="connectTimeout" value="10000"/>
        <property name="readTimeout"    value="10000"/>
    </bean>

I was wondering if I was missing anything in the above configurations. 我想知道我是否在上述配置中遗漏了任何内容。 What can be the reason that &amp; 可能是什么原因导致&amp; is automatically converted to & in the payload that I extract from POST response. 在我从POST响应中提取的有效负载中自动转换为&

The other interesting thing that I noticed is when if the server side is sending &gt; 我注意到的另一个有趣的事情是,如果服务器端正在发送&gt; symbol Example <Order>test&gt;test</Order> I am receiving it as the same ie <Order>test&gt;test</Order> ; 符号示例<Order>test&gt;test</Order>我收到它是相同的,即<Order>test&gt;test</Order> ; But if the server is sending back both &gt; 但是如果服务器发回两个&gt; and &amp; &amp; together example <Order>test&gt;test&amp;test</Order> I am receiving it as <Order>test>test&test</Order> 示例<Order>test&gt;test&amp;test</Order>我收到它作为<Order>test>test&test</Order>

If you look at a network trace, I think you'll find that is happening on the server side. 如果你看一下网络跟踪,我想你会发现这是在服务器端发生的。

You might have to send &amp;amp; 您可能需要发送&amp;amp; .

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM