【问题标题】:Soap-error Parsing Schema: can't import schema from unexpected targetNamespaceSoap-error Parsing Schema: can't import schema from unexpected targetNamespace
【发布时间】:2013-09-11 12:18:42
【问题描述】:

我有一个 PHP Soap 服务器。 当(例如)python-suds 脚本询问 WSDL 时,它会正确。 WSDl 确实导入了位于同一站点某处的 XSD。 这也很顺利,因为 python 可以使用工厂来创建在导入的 xsd 中定义的类型。 当使用 client.service.ActionName() 处理请求时,PHP 脚本启动。

PHP 先初始化自己的 wsdl,然后在导入自己服务器上的 xsd 时出错。

小问题:为什么python可以加载xsd导入而php不能?

这里有 wsdl 的开头:

<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:tns="http://---/webservices/2012-09/" xmlns:eba="http://---/schemas/1-0/" xmlns:xsd="http://www.w3.org/2001/XMLSchema/" targetNamespace="http://---/webservices/2012-09/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/">
<wsdl:types>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://---/webservices/2012-09/" elementFormDefault="qualified">
        <xsd:import namespace="http://---/schemas/1-0/" schemaLocation="xsd/XSDName"/>
    </xsd:schema>
</wsdl:types>

这是xsd的开始:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:element name="ElementName" type="ElementType">

这是 Python 脚本:

url = 'http://---/wsdl&' + str(uuid.uuid1())
client = Client(url)

print client

wb = client.factory.create('ns0:MyType')
print wb

post_result = client.service.RequestFunction(wb)

这是 PHP 脚本:

$soapServer = new SoapServer('http://---/wsdl'); // <-- fails here
$soapServer->setClass('SoapHandler'); 
$soapServer->handle(); 

【问题讨论】:

    标签: php python soap


    【解决方案1】:

    有两个明显的区别:

    1. 在 PHP 中,您使用的是 SoapServer 而不是 SoapClient
    2. 在 Python 中,您的 URL 与在 PHP 中不同 - 您添加一些用户 ID 或类似 /wsdl& + str(uuid.uuid1()) 与 /wsdl

    【讨论】:

      猜你喜欢
      • 2012-02-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-26
      • 2016-03-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多