意外的'targetNamespace'无法导入XSD

时间:2012-10-11 19:06:58

标签: php namespaces wsdl

我有一个WSDL,定义如下。不确定定义有什么问题,但每次我尝试导入时,都会出现错误

    <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">

... ... ...

我收到以下错误,但无法找到解决方法。

SOAP-ERROR: Parsing Schema: can't import schema from 'myxsd.xsd', unexpected 'targetNamespace'='myxsdspace

非常感谢您的帮助

3 个答案:

答案 0 :(得分:2)

对遇到同样麻烦的人的答案,

这通常与以下属性不匹配:namespace标记中的<import>和导入的xsd文件中targetNamespace标记中的schema

引发unexpected 'targetNamespace'错误的不匹配属性示例:

文件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" ... >

因此,只需更正其中一个属性,错误就会消失:

文件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" ... >

答案 1 :(得分:1)

您使用的是哪个版本的PHP?您可以发布用于连接SOAP的代码吗? PHP-SOAP接口仍然非常挑剔,您可能需要对WSDL或PHP进行一些修改才能使其满意。首先,尝试设置soap选项以强制使用soap版本。另外,看看您是否可以通过对错误运行var_dump来获取更多详细信息,如下所示。

$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);
}

答案 2 :(得分:0)

您提交的WSDL不完整。根元素没有关闭,还有其他元素不完整。您将无法解析没有合法语法的WSDL

相关问题