如何禁用在肥皂,改装请求中编码的身体数据 [英] How to disable a body data getting encoded in soap, retrofit request

查看:97
本文介绍了如何禁用在肥皂,改装请求中编码的身体数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个请求数据,其中元素之一将xml作为值.使用 @Body 将数据发送到服务器时,我的内部xml得到了编码(html编码).由于此服务在服务器端出现故障.如何禁用内部 xml编码.

I have a request data where one of the element takes xml as value. While sending the data to the server using @Body my inner xml is getting encoded(html encoded). Because of this service is failing in server side. How to disable the inner xml getting encoded.

样本:

<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/soap/envelope/">
   <soap12:Body>
      <UpdateASN xmlns="http://tempuri.org/">
         <SecureCode>VkdWelkyOUJVMDQ9</SecureCode>
         <strXML>&lt;![CDATA[&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;&lt;NewDataSet&gt;&lt;Table&gt;&lt;ASNId&gt;21131248&lt;/ASNId&gt;&lt;ASNLineId&gt;108069195&lt;/ASNLineId&gt;&lt;EANOCC&gt;5051622303470&lt;/EANOCC&gt;&lt;TUQuantityRecevied&gt;2&lt;/TUQuantityRecevied&gt;&lt;ItemDescription&gt;sample 6X300ML&lt;/ItemDescription&gt;&lt;TUSize&gt;6&lt;/TUSize&gt;&lt;TUDespatched&gt;1&lt;/TUDespatched&gt;&lt;/Table&gt;&lt;/NewDataSet&gt;]]&gt;</strXML>
      </UpdateASN>
   </soap12:Body>
</soap12:Envelope>

推荐答案

我自己找到了它.

这就是我正在做的,我删除了将内部xml封装在 CDATA 内,以便在服务器端可以在处理之前获取并解码内部xml.

Here is what I'm doing, I have removed enclosing the inner xml inside CDATA so that in server side it can take and decode the inner xml before processing.

如果我们将内部xml用 CDATA 括起来,它将不会对该字符串进行解码,并且会使服务失败.

If we enclose the inner xml with CDATA it won't decode the string and it make service to fail.

这是我的最终要求:

<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/soap/envelope/">
   <soap12:Body>
      <UpdateASN xmlns="http://tempuri.org/">
         <SecureCode>VkdWelkyOUJVMDQ9</SecureCode>
         <strXML>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;&lt;NewDataSet&gt;&lt;Table&gt;&lt;ASNId&gt;21131248&lt;/ASNId&gt;&lt;ASNLineId&gt;108069195&lt;/ASNLineId&gt;&lt;EANOCC&gt;5051622303470&lt;/EANOCC&gt;&lt;TUQuantityRecevied&gt;2&lt;/TUQuantityRecevied&gt;&lt;ItemDescription&gt;sample 6X300ML&lt;/ItemDescription&gt;&lt;TUSize&gt;6&lt;/TUSize&gt;&lt;TUDespatched&gt;1&lt;/TUDespatched&gt;&lt;/Table&gt;&lt;/NewDataSet&gt;</strXML>
      </UpdateASN>
   </soap12:Body>
</soap12:Envelope>

这篇关于如何禁用在肥皂,改装请求中编码的身体数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆