沃梦达 / 编程问答 / php问题 / 正文

将 PHP SoapClient 与本地 WSDL 文件(非 URI)一起使用的

Any workaround to use PHP SoapClient with a local WSDL file (NON-URI)?(将 PHP SoapClient 与本地 WSDL 文件(非 URI)一起使用的任何解决方法?)

本文介绍了将 PHP SoapClient 与本地 WSDL 文件(非 URI)一起使用的任何解决方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在服务器上以 CLI 模式运行的应用程序,它既没有也不需要运行本地 httpd.该应用程序使用 SOAP 与 Web 服务提供者进行传出交互.有问题的提供程序存在一些可用性问题,我们正在尝试通过按照他们的建议在本地托管 WSDL 文件来减少问题的数量.

I have an application running in CLI mode on a server that neither has nor needs to run a local httpd. The application does outgoing interactions with a web services provider using SOAP. The provider in question has some availability issues and we are trying to reduce the number of issues by hosting the WSDL file locally at their suggestion.

似乎 SoapClient 构造函数(在 WSDL 模式下)只能使用 URI WSDL 文件,但我试图找出某种方法来解决此限制,并让它从本地文件系统中读取 WSDL 文件某种方式.我很惊讶 SoapClient 构造函数没有传递文件名或文本字符串的选项,我可以在之前简单地阅读.

It seems that the SoapClient constructor (in WSDL mode) can only make use of a URI WSDL file, but I am trying to figure out some way to work around this limitation and have it read the WSDL file from the local filesystem in some way. I am surprised that the SoapClient constructor does't have an option to pass a filename or a string of text which I could have simple read in prior.

有没有人就如何避开这个限制并做我正在尝试的事情提出建议?

Has anyone got a suggestion on how to sidestep this limitation and do what I am attempting?

推荐答案

SoapClient() 采用一个 URI,它不仅支持网址,还支持本地文件路径.但是相对路径在这里不起作用,所以它需要是完整的文件路径.

SoapClient() takes a URI which supports not only web addresses, but local file paths. But relative paths aren't working here, so it needs to be the full file path.

这里介绍了如何使用相对引用加载本地 WSDL 文件.如果 WSDL 与当前 PHP 文件在同一目录中:

Here's how to load a local WSDL file with a relative reference. If the WSDL is in the same directory as the current PHP file:

new SoapClient(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'the.wsdl.xml');

或者如果它在当前 PHP 文件的子文件夹中:

or if it's in a subfolder of the current PHP file:

new SoapClient(dirname(__FILE__) . DIRECTORY_SEPARATOR. 'subfolder' . DIRECTORY_SEPARATOR . 'the.wsdl.xml');

或者如果它在当前 PHP 文件的父文件夹中:

or if it's in a parent folder of the current PHP file:

new SoapClient(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'the.wsdl.xml');

这篇关于将 PHP SoapClient 与本地 WSDL 文件(非 URI)一起使用的任何解决方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:将 PHP SoapClient 与本地 WSDL 文件(非 URI)一起使用的

基础教程推荐