denormalizer
denormalizer

Reputation: 2214

php SoapClient fails when passed a wsdl with relative path schemas

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:

Upvotes: 1

Views: 7424

Answers (1)

denormalizer
denormalizer

Reputation: 2214

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

Upvotes: 1

Related Questions