开发者

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. I need to create an app that consumes those webservices in the same manner as the webpsite does. There are two problems. First, I have no specification about th开发者_高级运维ose webservice methods (calls, used format and etc). And second, I only have build an app that uses JSON-framework for getting JSON data from flick using its API. 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. So, I don't know how to identify the format of webservices of current website. 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. So, how to identify the correct format?


If it's a .NET ASMX service then it is always SOAP. A SOAP service exposed over HTTP will always use HTTP POST methods for communication. 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.

This question seems to have the answers you need for doing this in Objective-C.


As @whaley says in his answer, it looks like you're dealing with a SOAP service here. 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.

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. 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. In Safari, enable the developer tools menu and then show the web inspector. You can see the details of the HTTP requests and see what is going on. Firefox has the firebug plugin that can do the same and more. 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. 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. If not, you may be out of luck unless you can track down a WSDL file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜