传递带有相对路径模式的wsdl时,php SoapClient失败 [英] php SoapClient fails when passed a wsdl with relative path schemas
问题描述
我有以下问题:
当我向其传递使用相对路径导入模式的wsdl时,我的SoapClient对象的实例化失败。 (我相信基于我的研究就是这种情况)
The instantiation of my SoapClient object fails when I pass it a wsdl that imports a schema using relative paths. (I believe this is the case anyway, based on my research)
我的代码如下:
$wsdl = 'http://myproxy/webservice?wsdl';
$options = array( /* options */ );
$client = new SoapClient($wsdl, $options);
wsdl的架构导入部分:
The schema import part of the wsdl:
<schema xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://myprovider/namespace1/namespace1" schemaLocation="schema1.xsd"/>
<import namespace="http://myprovider/namespace1/namespace2" schemaLocation="schema2.xsd"/>
<import namespace="http://myprovider/namespace1/namespace3" schemaLocation="schema3.xsd"/>
</schema>
我得到的错误:
SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://myproxy/webservice?wsdl' : Extra content at the end of the document
研究让我得到了这样的文章:
Research led me to articles such as this:
https://issues.apache.org/jira/browse/AXIS2-484
据我所知,似乎我有两个选择:
From what I can tell, it seems I have two options:
- 让我的提供者更改架构路径绝对
- 让我的提供商给我一份架构副本,这样我就可以在我的服务器上托管
SoapClient
被调用
- Get my provider to change the schema paths to absolute
- Get my provider to give me a copy of the schema so I can host on my server where the
SoapClient
is being called from
推荐答案
正如我所怀疑的那样。
模式的相对路径意味着SoapClient在解析wsdl时会尝试使用代理作为参考来访问模式文件,如下所示:
The relative path to the schema means that the SoapClient when parsing the wsdl, will try to access the schema files using the proxy as reference, like so:
http://myproxy/schema1.xsd
由于我没有xsd文件,这会导致SoapClient抛出错误。
Since I do not have the xsd files, this will cause the SoapClient to throw an error.
这个问题的解决方案就是消除代理,所以外部资源的相对路径不受影响。溶剂可以在这里找到:
The solution to this problem then is to eliminate the proxy, so that relative paths to external resources are not affected. The sollution can be found here:
扩展php SoapClient以进行siteminder身份验证
这篇关于传递带有相对路径模式的wsdl时,php SoapClient失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!