简体   繁体   English

如何区分它是SOAP还是REST Web服务?

[英]How to distinguish is it a SOAP or REST webservice?

I need to consume some .NET asmx webservices that are currently implemented in some website. 我需要使用一些目前在某些网站上实现的.NET asmx webservices。 I need to create an app that consumes those webservices in the same manner as the webpsite does. 我需要创建一个以与webpsite相同的方式使用这些web服务的应用程序。 There are two problems. 有两个问题。 First, I have no specification about those webservice methods (calls, used format and etc). 首先,我没有关于那些webservice方法(调用,使用的格式等)的规范。 And second, I only have build an app that uses JSON-framework for getting JSON data from flick using its API. 其次,我只构建了一个使用JSON框架的应用程序,使用其API从flick中获取JSON数据。 I guess that was done using REST webservices :) I do understand that in order to perform posts/gets to the server I need to construct a request string, then pass it to the webserver, get results, parse them (XML or JSON) and then view them. 我想这是使用REST webservices完成的:)我明白为了执行post / gets到服务器我需要构造一个请求字符串,然后将它传递给webserver,获取结果,解析它们(XML或JSON)和然后查看它们。 So, I don't know how to identify the format of webservices of current website. 所以,我不知道如何识别当前网站的webservices的格式。 I have viewed the source of that website, saw a bunch of Javascript code files that are doing a lot of mysterious checking, validation and etc stuff. 我查看了该网站的来源,看到了一堆Javascript代码文件正在做很多神秘的检查,验证等等。 So, how to identify the correct format? 那么,如何识别正确的格式?

If it's a .NET ASMX service then it is always SOAP. 如果它是.NET ASMX服务,那么它始终是SOAP。 A SOAP service exposed over HTTP will always use HTTP POST methods for communication. 通过HTTP公开的SOAP服务将始终使用HTTP POST方法进行通信。 It should also expose a .wsdl file for you to consume and generate client code from that as well so you should not have to worry about using a JSON framework or orchestrating your own HTTP requests to that web service... your generated Objective-C client should take care of that for you. 它还应该公开一个.wsdl文件供您使用并从中生成客户端代码,因此您不必担心使用JSON框架或将您自己的HTTP请求编排到该Web服务...您生成的Objective-C客户应该为您照顾。

This question seems to have the answers you need for doing this in Objective-C. 这个问题似乎有你在Objective-C中做到这一点所需要的答案。

As @whaley says in his answer, it looks like you're dealing with a SOAP service here. 正如@whaley在他的回答中所说,看起来你在这里处理的是SOAP服务。 Knowing that allows you to take a step in the right direction, but if you want to interact with it you'll need to do more than that. 知道这可以让你朝着正确的方向迈出一步,但如果你想与之互动,你需要做的不仅仅是这个。 You'll need to know the details of the SOAP operations it supports, the XML schema for the request and response messages, etc. If you're able to find the WSDL file it should provide you all of that information. 您需要知道它支持的SOAP操作的详细信息,请求和响应消息的XML模式等。如果您能够找到WSDL文件,它应该为您提供所有这些信息。

If you are unable to track down the WSDL file (some services don't like to make it easy for a variety of reasons), then you may still be able to figure it out. 如果您无法跟踪WSDL文件(某些服务不喜欢因各种原因而变得容易),那么您仍然可以找到它。 If the website truly interacts using the SOAP interface then you can look at the requests your browser sends out using any number of tools. 如果网站真正使用SOAP接口进行交互,那么您可以使用任意数量的工具查看浏览器发出的请求。 In Safari, enable the developer tools menu and then show the web inspector. 在Safari中,启用开发人员工具菜单,然后显示Web检查器。 You can see the details of the HTTP requests and see what is going on. 您可以查看HTTP请求的详细信息并查看正在进行的操作。 Firefox has the firebug plugin that can do the same and more. Firefox有一个firebug插件可以做同样的事情。 Each browser has its own tools for developers, but you'll have to find the right tool for your browser. 每个浏览器都有自己的工具供开发人员使用,但您必须为浏览器找到合适的工具。

Word of warning: Frequently a web page that interacts with your back-end service doesn't actually use the SOAP service directly. 警告:通常,与后端服务交互的网页实际上并不直接使用SOAP服务。 It may be using an alternate and non-public interface to make the calls it needs to. 它可能正在使用备用和非公共接口来进行所需的调用。 If you look at the requests your browser sends out and it looks like a SOAP message (lots of things like SoapEnvenlope elements with distinct request/response XML), then it is pretty safe to assume you can replicate those SOAP messages from objective-c. 如果你查看浏览器发出的请求,它看起来像一个SOAP消息(很多东西,比如具有不同请求/响应XML的SoapEnvenlope元素),那么假设你可以从objective-c复制那些SOAP消息是非常安全的。 If not, you may be out of luck unless you can track down a WSDL file. 如果没有,除非您可以追踪WSDL文件,否则您可能会失败。

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

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