SOAP和REST如何使用XML / JSON响应? [英] How SOAP and REST work with XML/JSON response?

查看:850
本文介绍了SOAP和REST如何使用XML / JSON响应?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个非常常见的问题,一次又一次地问堆栈溢出,我读了很多这方面的答案,但我仍然有点困惑。

This is one very common question asked again and again on stack overflow and I read so many answers about this but I am still bit confused.

我需要打电话来自iPhone sdk的网络服务。

I need to call the webservices from iPhone sdk.

以下是我的问题:


  1. 我不清楚SOAP或REST返回什么响应。有什么特定的,如果响应是XML那么我们应该使用REST,如果JSON我们应该使用SOAP?

  1. I am not clear what response SOAP or REST return.Is there anything specific that if response is XML then we should use REST and if JSON we should use SOAP?

ASIHTTP与SOAP和REST的作用是什么?

What is the role of ASIHTTP with SOAP and REST?

如果我得到XML响应




<oproduct>
    <iid>113133791</iid>
    <icategoryid>270</icategoryid>
    <imerchantid>1547</imerchantid>
    <iadult>0</iadult>
    <sname>The Ashes / 1st Test - England v Australia - Day 1</sname>
    <sawdeeplink>http://www.acbcd.com/pclick.php?p=113133791&amp;a=111402&amp;m=1547&amp;platform=cs</sawdeeplink>
    <sawthumburl>http://images.abcdd.com/thumb/1547/113133791.jpg</sawthumburl>
    <fprice>69.99</fprice>
  </oproduct>


我需要手工解析吗?或者我如何处理XML响应?

Do I need to parse it by hand? or how do I handle XML response?

我收到了很多关于REST和SOAP的文章,但没有正确的代码来理解它。
如果对这些问题有任何帮助,我将不胜感激。

I got so many articles about REST and SOAP but no proper code to understand it. I would be grateful for any help regarding these questions.

推荐答案

SOAP - 简单对象访问协议

SOAP是一种通过Internet传输消息或少量信息的方法。 SOAP消息采用XML格式化,通常使用HTTP(超文本传输​​协议)发送。

SOAP is a method of transferring messages, or small amounts of information, over the Internet. SOAP messages are formatted in XML and are typically sent using HTTP (hypertext transfer protocol).

因此,SOAP有一个标准消息必须发送的标准。

So SOAP has a standard how a message has to be sent.

每个soap web服务都可以使用WSDL(Web服务定义语言)定义,这是一种传递SOAP XML的模式。

Each soap web service can be defined with a WSDL(Web Service Definition Language) which is kind of a schema for the SOAP XML transferred.

有许多工具可用于将WSDL(您的Web服务定义)转换为本机代码。

There are many tools available to convert WSDL(your webservice definition) to native code.

ObjC可用的工具之一是 Sudz-C ( http://sudzc.com/ 将任何Web服务的WDSL转换为ObjC代码以进行访问网络服务。

One of the tool available for ObjC is Sudz-C (http://sudzc.com/) which convert the WDSL of any webservice to ObjC code to access the Web service.

休息 - 代表性国家转移

Rest是在客户端和服务器之间发送和接收数据的简单方法,它没有定义任何标准,您可以以JSON,XML甚至文本的形式发送和接收数据。它的轻量级与SOAP相比。

Rest is a simple way of sending and receiving data between client and server and it don't have any much standards defined , You can send and receive data as JSON,XML or even a Text. Its Light weighted compared to SOAP.

要在iOS中处理Rest,有很多工具可用,我建议 RestKit http://restkit.org/ ,用于处理XML和JSON。

To handle Rest in iOS there are many tools available, I would recommend RestKit http://restkit.org/, for handling XML and JSON both.

I建议你选择Rest for mobile开发,因为它重量轻

I would suggest you to go with Rest for mobile development, since its light weight

(简单的例子,人们纠正我,如果我错了)

(Simple example, People correct me If I am wrong)

这篇关于SOAP和REST如何使用XML / JSON响应?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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