从 Oracle PL/SQL 使用 Web 服务

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37586/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 17:09:42  来源:igfitidea点击:

Consuming web services from Oracle PL/SQL

sqloracleweb-servicesplsql

提问by steevc

Our application is interfacing with a lot of web services these days. We have our own package that someone wrote a few years back using UTL_HTTP and it generally works, but needs some hard-coding of the SOAP envelope to work with certain systems. I would like to make it more generic, but lack experience to know how many scenarios I would have to deal with. The variations are in what namespaces need to be declared and the format of the elements. We have to handle both simple calls with a few parameters and those that pass a large amount of data in an encoded string.

如今,我们的应用程序与许多 Web 服务交互。我们有自己的软件包,几年前有人使用 UTL_HTTP 编写了它,它通常可以工作,但需要对 SOAP 信封进行一些硬编码才能与某些系统一起使用。我想让它更通用,但缺乏经验来知道我必须处理多少场景。变化在于需要声明的命名空间和元素的格式。我们必须处理带有几个参数的简单调用和那些在编码字符串中传递大量数据的调用。

I know that 10g has UTL_DBWS, but there are not a huge number of use-cases on-line. Is it stable and flexible enough for general use? Documentation

我知道 10g 有 UTL_DBWS,但在线用例并不多。它是否足够稳定和灵活以供一般使用?文档

采纳答案by Sten Vesterli

I have used UTL_HTTPwhich is simple and works. If you face a challenge with your own package, you can probably find a solution in one of the many wrapper packages around UTL_HTTP on the net (Google "consuming web services from pl/sql", leading you to e.g. http://www.oracle-base.com/articles/9i/ConsumingWebServices9i.php)

我已经使用了UTL_HTTP它,它简单且有效。如果您在使用自己的包时遇到挑战,您可能可以在网络上围绕 UTL_HTTP 的众多包装包之一中找到解决方案(谷歌“从 pl/sql 使用网络服务”,引导您到例如 http://www. oracle-base.com/articles/9i/ConsumingWebServices9i.php)

The reason nobody is using UTL_DBWSis that it is not functional in a default installed database. You need to load a ton of Java classes into the database, but the standard instructions seem to be defective - the process spews Java errors right and left and ultimately fails. It seems very few people have been willing to take the time to track down the package dependencies in order to make this approach work.

没有人使用的原因是UTL_DBWS它在默认安装的数据库中不起作用。您需要将大量 Java 类加载到数据库中,但标准指令似乎有缺陷 - 该过程左右抛出 Java 错误并最终失败。似乎很少有人愿意花时间追踪包的依赖关系以使这种方法起作用。

回答by Rob McCauley

I had this challenge and found and installed the 'SOAP API' package that Sten suggests on Oracle-Base. It provides some good envelope-creation functionality on top of UTL_HTTP.

我遇到了这个挑战,找到并安装了 Sten 在 Oracle-Base 上建议的“SOAP API”包。它在 UTL_HTTP 之上提供了一些很好的信封创建功能。

However there were some limitations that pertain to your question. SOAP_API assumes all requests are simple XML- i.e. only one layer tag hierarchy.

但是,您的问题存在一些限制。SOAP_API 假设所有请求都是简单的 XML——即只有一层标签层次结构。

I extended the SOAP_API package to allow the client code to arbitrarily insert an extra tag. So you can insert a sub-level such as , continue to build the request, and remember to insert a closing tag.

我扩展了 SOAP_API 包以允许客户端代码任意插入额外的标记。所以你可以插入一个子级别比如 ,继续构建请求,记得插入结束标记。

The namespace issue was a bear for the project- different levels of XML had different namespaces.

命名空间问题对项目来说是个难题——不同级别的 XML 具有不同的命名空间。

A nice debugging tool that I used is TCP Trace from Pocket Soap. www.pocketsoap.com/tcptrace/ You set it up like a proxy and watch the HTTP request and response objects between client and server code.

我使用的一个很好的调试工具是来自 Pocket Soap 的 TCP Trace。www.pocketsoap.com/tcptrace/ 您可以像代理一样设置它并观察客户端和服务器代码之间的 HTTP 请求和响应对象。

Having said all that, we really like having a SOAP client in the database- we have full access to all data and existing PLSQL code, can easily loop through cursors and call the external app via SOAP when needed. It was a lot quicker and easier than deploying a middle tier with lots of custom Java or .NET code. Good luck and let me know if you'd like to see my enhanced SOAP API code.

说了这么多,我们真的很喜欢在数据库中有一个 SOAP 客户端——我们可以完全访问所有数据和现有的 PLSQL 代码,可以轻松地遍历游标并在需要时通过 SOAP 调用外部应用程序。这比部署具有大量自定义 Java 或 .NET 代码的中间层要快得多、容易得多。祝您好运,如果您想查看我的增强型 SOAP API 代码,请告诉我。

回答by Mark Harrison

We have also used UTL_HTTP in a manner similar to what you have described. I don't have any direct experience with UTL_DBWS, so I hope you can follow up with any information/experience you can gather.

我们还以类似于您所描述的方式使用了 UTL_HTTP。我对 UTL_DBWS 没有任何直接经验,所以我希望你能跟进你能收集到的任何信息/经验。

@kogus, no it's a quite good design for many applications. PL/SQL is a full-fledged programming language that has been used for many big applications.

@kogus,不,对于许多应用程序来说,这是一个非常好的设计。PL/SQL 是一种成熟的编程语言,已用于许多大型应用程序。

回答by JosephStyons

Check out this older post. I have to agree with that post's #1 answer; it's hard to imagine a scenario where this could be a good design.

看看这个旧帖子。我必须同意那个帖子的#1 答案;很难想象这会是一个好的设计。

Can't you write a service, or standalone application, which would talk to a table in your database? Then you could implement whatever you want as a trigger on that table.

您不能编写一个服务或独立应用程序来与数据库中的表进行通信吗?然后你可以实现任何你想要的作为该表上的触发器。