Reputation:
I have a WSDL that is defined as below. Unsure what is wrong with definition, but each time i try to import, I get Errors
<definitions targetNamespace="myservices"
xmlns:nslt2="myxsdspace"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="urn:myservices"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/">
<types>
<schema elementFormDefault="unqualified"
targetNamespace="myservices" xmlns="http://www.w3.org/2001/XMLSchema"/>
<xsd:schema>
<xsd:import namespace="myxsdspace" schemaLocation="ApplicaitonForm_Latest.xsd"/>
</xsd:schema>
</types>
<message name="processRequest">
... ... ...
I get the below error and have not been able to find a solution to it.
SOAP-ERROR: Parsing Schema: can't import schema from 'myxsd.xsd', unexpected 'targetNamespace'='myxsdspace
Greatly appreciate your help
Upvotes: 3
Views: 3327
Reputation: 441
An answer for people who have the same trouble,
It's usually related to a mismatch between the attributes: namespace
from the <import>
tag and the targetNamespace
from the schema
tag in the imported xsd file.
Example of mismatched attributes which raise an unexpected 'targetNamespace'
error:
file wsdl.xml
<xs:import namespace="http://www.example.fr/modules/payment/schema/qwerty"
schemaLocation="location.xsd"/>
file location.xsd
<xs:schema targetNamespace="http://www.example.fr/modules/payment/schema/azerty" ... >
So, simply correct one of the attributes, and the error should disappear:
file wsdl.xml
<xs:import namespace="http://www.example.fr/modules/payment/schema/qwerty"
schemaLocation="location.xsd"/>
file location.xsd
<xs:schema targetNamespace="http://www.example.fr/modules/payment/schema/qwerty" ... >
Upvotes: 2
Reputation: 961
What version of PHP are you using? Can you post your code for connecting to SOAP? The PHP-SOAP interface is still very picky, and you may have to do some modifications to your WSDL or PHP to make it happy. For starters, try setting the soap options to force the soap version. Also, see if you can get more details by running a var_dump
on the error as seen below.
$soapServer = 'http://yoursoap.com/wsdl';
$soapOptions = array(
'soap_version' => SOAP_1_1,
'exceptions' => true,
'trace' => 1,
'wsdl_local_copy' => true,
'keep_alive' => true,
'features' => SOAP_SINGLE_ELEMENT_ARRAYS
);
try
{
$soapClient = new SoapClient($soapServer, $soapOptions);
}
catch (Exception $e)
{
$message = "<h2>Connection Error!</h2></b>";
var_dump($e);
}
Upvotes: 1
Reputation: 12834
The WSDL you have submitted is incomplete. The root element is not closing, as well as there are other elements in incomplete form. You will not be able to parse a WSDL that is not having welformed syntax
Upvotes: 0