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

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

问题描述

我在既不需要也不需要运行本地httpd的服务器上以CLI模式运行的应用程序.该应用程序使用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文件(NON-URI)结合使用的任何解决方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆