php SoapClient 在传递具有相对路径模式的 wsdl 时失败

发布于 2024-11-09 14:59:59 字数 1123 浏览 4 评论 0原文

我遇到以下问题:

当我向 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

青春如此纠结 2024-11-16 14:59:59

正如我所怀疑的那样。

模式的相对路径意味着 SoapClient 在解析 wsdl 时,将尝试使用代理作为参考来访问模式文件,如下所示:

http://myproxy/schema1.xsd

由于我没有 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:

http://myproxy/schema1.xsd

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文