如何禁用在肥皂,改装请求中编码的身体数据 [英] How to disable a body data getting encoded in soap, retrofit request
问题描述
我有一个请求数据,其中元素之一将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><![CDATA[<?xml version="1.0" encoding="utf-8"?><NewDataSet><Table><ASNId>21131248</ASNId><ASNLineId>108069195</ASNLineId><EANOCC>5051622303470</EANOCC><TUQuantityRecevied>2</TUQuantityRecevied><ItemDescription>sample 6X300ML</ItemDescription><TUSize>6</TUSize><TUDespatched>1</TUDespatched></Table></NewDataSet>]]></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><?xml version="1.0" encoding="utf-8"?><NewDataSet><Table><ASNId>21131248</ASNId><ASNLineId>108069195</ASNLineId><EANOCC>5051622303470</EANOCC><TUQuantityRecevied>2</TUQuantityRecevied><ItemDescription>sample 6X300ML</ItemDescription><TUSize>6</TUSize><TUDespatched>1</TUDespatched></Table></NewDataSet></strXML>
</UpdateASN>
</soap12:Body>
</soap12:Envelope>
这篇关于如何禁用在肥皂,改装请求中编码的身体数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!