将 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)一起使用的任何解决方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)