php SoapClient 在传递具有相对路径模式的 wsdl 时失败
我遇到以下问题:
当我向 SoapClient 对象传递一个使用相对路径导入架构的 wsdl 时,它的实例化失败。 (根据我的研究,我相信情况确实如此)
我的代码如下:
$wsdl = 'http://myproxy/webservice?wsdl';
$options = array( /* options */ );
$client = new SoapClient($wsdl, $options);
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
研究使我找到了诸如此类的文章:
https://issues.apache.org/jira/browse/AXIS2-484
据我所知,它似乎我有两个选择:
- 让我的提供程序将架构路径更改为绝对
- 让我的提供程序为我提供架构的副本,以便我可以在调用
SoapClient
的服务器上托管
I have the following issue:
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)
My code is as follows:
$wsdl = 'http://myproxy/webservice?wsdl';
$options = array( /* options */ );
$client = new SoapClient($wsdl, $options);
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>
The Error that I get:
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:
- 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如我所怀疑的那样。
模式的相对路径意味着 SoapClient 在解析 wsdl 时,将尝试使用代理作为参考来访问模式文件,如下所示:
由于我没有 xsd 文件,这将导致 SoapClient 抛出错误。
那么解决这个问题的办法就是消除代理,这样外部资源的相对路径就不会受到影响。解决方案可以在这里找到:
扩展 php SoapClient 以进行 siteminder 身份验证
Just as I had suspected.
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:
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:
Extending php SoapClient for siteminder authentication