使用AFNetworking发布XML的示例? [英] Example on using AFNetworking to post XML?
问题描述
作为此问题的后续内容,我无法理解工作所以我需要退后一步。
As a followup to this question, I cannot get this to work so I need to take a step back I think.
有人可以发布一些示例代码,说明如何在不使用params的情况下将XML发布到休息服务吗?它甚至可能吗?基本上我有一个具有多个属性的对象,我将其转换为XML然后需要上传它。但如果在XML中将图像转换为字符串,则会失败。没有它就可以正常工作。
Can someone post some sample code on how to post XML to a rest service WITHOUT using params? Is it even possible? Basically I have an object with several properties, and I convert this to XML and then need to upload it. But it fails if there is an image converted to string in the XML. Without that it works fine.
即使是JSON示例也会有帮助......
Even a JSON example would be helpful...
这里完全被阻止: P
Totally blocked here :P
推荐答案
使用 NSMutableURLRequest -setHTTPBody:
,并设置 Content-Type
HTTP标头到 application / xml
。
Use NSMutableURLRequest -setHTTPBody:
, and set the Content-Type
HTTP header to application/xml
.
如果你一直这样做,你可能想要考虑继承 AFHTTPClient
来添加XML参数序列化选项。
If you're doing this consistently, you may want to consider subclassing AFHTTPClient
to add an XML parameter serialization option.
这篇关于使用AFNetworking发布XML的示例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!