php SoapClient fails when passed a wsdl with relative path schemas

泪湿孤枕 提交于 2019-12-20 05:28:37

问题


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

回答1:


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



来源:https://stackoverflow.com/questions/6132515/php-soapclient-fails-when-passed-a-wsdl-with-relative-path-schemas

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!