如何学习SOAP?

发布于 2024-10-03 07:06:05 字数 524 浏览 4 评论 0原文

我创建了一个带有映射组件的 Web 应用程序。我想使用除 google 之外的其他地理编码服务,但我发现的所有地理编码服务都使用 SOAP 与网站进行通信。我以前从未用过肥皂。有谁知道有什么好的资源可以帮助我解决这个问题吗?我正在使用 PHP 来集成来构建 Web 应用程序。

编辑:我现在需要使用 Soap 进行地理编码...所以如果您也知道任何好的服务,那就太好了。谢谢!

再次编辑:我基本上需要学习肥皂,这样我就可以与 http:// /www.nn4d.com/site/global/build/web_services/geocoding_reversegeocoding/map24geocoder51service/map24geocoder51service.jsp

I've created a web application with a mapping component. I want to use another geocoding service other than google, but all the ones I've found use SOAP to communicate with the website. I've never used soap before. Does anyone know of any good resources to help me figure this out? I"m using PHP to integrate to build the web app.

Edit: I need to use Soap for geocoding right now... so if you know any good services for that too, that'd be great. Thanks!

EDIT Again: I basically need to learn soap so I can interact with http://www.nn4d.com/site/global/build/web_services/geocoding_reversegeocoding/map24geocoder51service/map24geocoder51service.jsp

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

始于初秋 2024-10-10 07:06:05

单独学习 SOAP 需要您学习 XML 和许多 SOAP 特定的内容。

但是,您已将您的问题标记为 PHP,因此我假设您实际上要问的是学习如何通过 PHP 使用 SOAP Web 服务。这与学习 SOAP 本身不同,因为 PHP(与大多数其他语言一样)抽象了 SOAP 的混乱 XML 部分,并将其转换为易于使用的对象。

无论如何,这就是理论。

PHP 上常用的有两个 SOAP 工具包。一种称为 NuSOAP。这工作得相当好,但不再处于积极的开发中(它是在 PHP 提供自己的内置 SOAP 类之前编写的)。
如果您想使用 NuSOAP,这里是官方项目网站:http://nusoap.sourceforge.net/

如果您是使用 PHP5.2 或 5.3(您应该使用 PHP5.2 或 5.3,因为它们是当前唯一受支持的版本),那么您将拥有一个内置的 SOAP 类。
如果您想使用官方 PHP SOAP 类,请参阅以下手册页: http://php.net/manual/ en/book.soap.php

一旦您选择了要使用的 SOAP 类,您将需要了解一些有关 SOAP Web 服务的一般信息以及您要使用的特定服务的信息。

首先,您需要知道该服务是否提供 WSDL。 WSDL 是另一个 XML 文档,它定义 SOAP 服务上可用的方法和参数。这允许您的 SOAP 类为 SOAP 服务定义一个类,这使您作为程序员的工作更加轻松。但在 PHP 实践中,这并没有多大区别。

我还建议您下载 SOAP UI,它是 SOAP 服务的调试工具。它允许您查看和修改正在发送和接收的确切 XML 代码。它将帮助您学习和理解 SOAP 的工作原理,并且如果您的 PHP 代码未按预期工作,还可以帮助您进行调试。

[编辑]
显然,最重要的是了解您正在使用的 API。

如果您正在处理的服务具有 WSDL,那么当您创建对象时,PHP 将自动为您生成适当的方法。例如:

$client = new SoapClient("http://somedomain/stockquote.wsdl");
print($client->getStockQuote("MSFT"));

确实就是这么简单。当然,这是一个相当简单的例子;大多数 SOAP 服务(当然是我使用过的服务!)需要的参数比这多得多,并且它们通常以巨大的嵌套数组结构的形式获取它们。

如果您的服务没有 WSDL,则必须使用稍微不同的方法来调用方法:

$client = new SoapClient(null, array('location' => "http://somedomain/stockquote.asp"));
print($client->__soapCall('getStockQuote',"MSFT"));

希望这可以帮助您更好地理解它。

我仍然建议尝试一下 SOAP UI,因为它将帮助您更好地理解 SOAP。您还应该阅读 PHP SOAP 类手册页:http://php.net/manual/en/book。 soap.php - 文档非常详尽,尽管与所有这些内容一样,一开始可能会令人畏惧,因为它是参考,而不是教程。

Learning SOAP on its own requires you to learn XML and lots of SOAP-specific stuff.

However, you've tagged your question PHP, so I assume what you're actually asking is to learn how to use a SOAP web service through PHP. This is different to learning SOAP itself because PHP (like most other languages) abstracts the messy XML bits of SOAP and turns it into an easy-to-use object.

That's the theory, anyway.

There are two SOAP toolkits in common use on PHP. One is called NuSOAP. This works fairly well, but is no longer in active development (it was written before PHP provided its own built-in SOAP class).
If you want to use NuSOAP, here is the official project web site: http://nusoap.sourceforge.net/

If you're using PHP5.2 or 5.3 (which you should be, since they're the only currently supported versions), then you'll have a built-in SOAP class.
If you want to use the official PHP SOAP class, here's the manual page: http://php.net/manual/en/book.soap.php

Once you've picked which the SOAP class you want to use, you will need to know a bit about SOAP web services in general, and about the specific service you want to use.

Firstly, you'll need to know if the service provides a WSDL. A WSDL is another XML document which defines the methods and parameters available on the SOAP service. This allows your SOAP class to define a class for the SOAP service, which makes life easier for you as a programmer. In practice in PHP it doesn't really make much differench though.

I also recommend you download SOAP UI, which is a debugging tool for SOAP services. It allows you to see and modify the exact XML code being sent and received. It'll help you learn and understand how SOAP works, and also help you with debugging if your PHP code doesn't work as expected.

[EDIT]
Obviously the most important thing is to know the API you're working with.

If the service you're dealing with has a WSDL, PHP will automatically generate the appropriate methods for you when you create the object. For example:

$client = new SoapClient("http://somedomain/stockquote.wsdl");
print($client->getStockQuote("MSFT"));

It really is as simple as that. Granted, this is a fairly simple example; most SOAP services (certainly the ones I've used!) take a lot more parameters than that, and they usually take them in the form of a giant nested array structure.

If your service doesn't have a WSDL, you'll have to call the methods using a slightly different method:

$client = new SoapClient(null, array('location' => "http://somedomain/stockquote.asp"));
print($client->__soapCall('getStockQuote',"MSFT"));

Hope that helps you understand it a bit better.

I still recommend having a go with SOAP UI, as it will help you understand SOAP in general a lot better. You should also definitely read the PHP SOAP class manual pages: http://php.net/manual/en/book.soap.php - the documentation is very thorough, though as with all these things it can be daunting to approach at first as it is a reference, not a tutorial.

倚栏听风 2024-10-10 07:06:05

连同这里的其他答案,我发现我最好通过学习如何使用 SOAPUI 来学习 SOAP:

http://www.soapui .org/

这是一个很棒的应用程序,用于调试您的肥皂界面,并帮助我尝试弄清楚我的 PHP 调用中发生了什么。

Along with the other answers here, I found that I best learned SOAP by learning how to use SOAPUI:

http://www.soapui.org/

It's a great app for debugging your soap interface and helped me a ton trying to figure out what was happening in my PHP calls.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文