問題描述
我有一個(gè)在服務(wù)器上以 CLI 模式運(yùn)行的應(yīng)用程序,它既沒有也不需要運(yùn)行本地 httpd.該應(yīng)用程序使用 SOAP 與 Web 服務(wù)提供者進(jìn)行傳出交互.有問題的提供程序存在一些可用性問題,我們正在嘗試通過按照他們的建議在本地托管 WSDL 文件來減少問題的數(shù)量.
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 構(gòu)造函數(shù)(在 WSDL 模式下)只能使用 URI WSDL 文件,但我試圖找出某種方法來解決此限制,并讓它從本地文件系統(tǒng)中讀取 WSDL 文件某種方式.我很驚訝 SoapClient 構(gòu)造函數(shù)沒有傳遞文件名或文本字符串的選項(xiàng),我可以在之前簡單地閱讀.
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.
有沒有人就如何避開這個(gè)限制并做我正在嘗試的事情提出建議?
Has anyone got a suggestion on how to sidestep this limitation and do what I am attempting?
推薦答案
SoapClient()
采用一個(gè) URI,它不僅支持網(wǎng)址,還支持本地文件路徑.但是相對路徑在這里不起作用,所以它需要是完整的文件路徑.
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 與當(dāng)前 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');
或者如果它在當(dāng)前 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');
或者如果它在當(dāng)前 PHP 文件的父文件夾中:
or if it's in a parent folder of the current PHP file:
new SoapClient(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'the.wsdl.xml');
這篇關(guān)于將 PHP SoapClient 與本地 WSDL 文件(非 URI)一起使用的任何解決方法?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!