gpt4 book ai didi

php - Soap 错误解析模式 : can't import schema from unexpected targetNamespace

转载 作者:搜寻专家 更新时间:2023-10-31 22:05:48 24 4
gpt4 key购买 nike

我有一个 PHP Soap-Server。当(例如)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();

最佳答案

有两个明显的区别:

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

关于php - Soap 错误解析模式 : can't import schema from unexpected targetNamespace,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18741009/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com