我需要使用之前准备的 Zend_Soap_Server 和 WSDL 来运行 SOAP 服务器。然而,当我尝试这样做时:
$server = new Zend_Soap_Server($wsdlUrl);
$server->setClass('Logic_WebService_Test');
$server->handle();
我收到错误:
SOAP-错误:解析架构:无法导入架构。命名空间不得 匹配封闭的模式“targetNamespace”
这是我的 WSDL:
<?xml version="1.0" encoding="UTF-8"?>
<!-- version="1.0" comment="" -->
<wsdl:definitions
targetNamespace="http://ws.orange.pl/mo-sms-service-ws"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:apachesoap="http://xml.apache.org/xml-soap"
xmlns:impl="http://ws.orange.pl/mo-sms-service-ws"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
------------------------------------------------------------------------------------------
Contract interface documentation
--------------------------------
Document release: V1_0
Author (entity): AMG.net
Creation date: 01/10/2013
Description: mo-sms-service-ws contract interface
------------------------------------------------------------------------------------------
Changes history
---------------
Version Date Comments
V1_0 01/10/2013 WSDL contract
------------------------------------------------------------------------------------------
</wsdl:documentation>
<wsdl:types>
<schema elementFormDefault="qualified"
targetNamespace="http://ws.orange.pl/mo-sms-service-ws"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:apachesoap="http://xml.apache.org/xml-soap"
xmlns:impl="http://ws.orange.pl/mo-sms-service-ws"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<xsd:import namespace="http://ws.orange.pl/mo-sms-service-ws" />
<element name="DeliverShortMessage">
<complexType>
<sequence>
<element name="sms" type="impl:SMSMessage" />
</sequence>
</complexType>
</element>
<element name="DeliverShortMessageResponse">
<complexType>
<sequence>
<element name="DeliverShortMessageReturn" nillable="true" type="xsd:boolean" />
</sequence>
</complexType>
</element>
<element name="DeliverNotification">
<complexType>
<sequence>
<element name="sms" type="impl:SMSNotification" />
</sequence>
</complexType>
</element>
<element name="DeliverNotificationResponse">
<complexType>
<sequence>
<element name="DeliverNotificationReturn" nillable="true" type="xsd:boolean" />
</sequence>
</complexType>
</element>
</schema>
<schema elementFormDefault="qualified"
targetNamespace="http://ws.orange.pl/mo-sms-service-ws"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:apachesoap="http://xml.apache.org/xml-soap"
xmlns:impl="http://ws.orange.pl/mo-sms-service-ws"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<complexType name="SMSMessage">
<sequence>
<element name="recipient" minOccurs="1" type="xsd:string" />
<element name="recipientAlias" minOccurs="0" type="xsd:string" />
<element name="originator" minOccurs="1" type="xsd:string" />
<element name="content" minOccurs="1" type="xsd:string" />
<element name="transactionId" minOccurs="1" type="xsd:string" />
<element name="timestamp" minOccurs="0" type="xsd:string" />
</sequence>
</complexType>
<complexType name="SMSNotification">
<sequence>
<element name="recipient" minOccurs="0" type="xsd:string" />
<element name="originator" minOccurs="0" type="xsd:string" />
<element name="transactionId" minOccurs="1" type="xsd:string" />
<element name="status" minOccurs="1" type="xsd:string" />
<element name="errorCode" minOccurs="0" type="xsd:string" />
<element name="content" minOccurs="0" type="xsd:string" />
<element name="timestamp" minOccurs="0" type="xsd:string" />
</sequence>
</complexType>
</schema>
</wsdl:types>
<wsdl:message name="DeliverShortMessageRequest">
<wsdl:part element="impl:DeliverShortMessage" name="parameters" />
</wsdl:message>
<wsdl:message name="DeliverShortMessageResponse">
<wsdl:part element="impl:DeliverShortMessageResponse" name="parameters" />
</wsdl:message>
<wsdl:message name="DeliverNotificationRequest">
<wsdl:part element="impl:DeliverNotification" name="parameters" />
</wsdl:message>
<wsdl:message name="DeliverNotificationResponse">
<wsdl:part element="impl:DeliverNotificationResponse" name="parameters" />
</wsdl:message>
<wsdl:portType name="MoSmsServiceWs">
<wsdl:operation name="DeliverShortMessage">
<wsdl:input message="impl:DeliverShortMessageRequest" name="DeliverShortMessageRequest" />
<wsdl:output message="impl:DeliverShortMessageResponse" name="DeliverShortMessageResponse" />
</wsdl:operation>
<wsdl:operation name="DeliverNotification">
<wsdl:input message="impl:DeliverNotificationRequest" name="DeliverNotificationRequest" />
<wsdl:output message="impl:DeliverNotificationResponse" name="DeliverNotificationResponse" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="MoSmsServiceWsSoapBinding" type="impl:MoSmsServiceWs">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="DeliverShortMessage">
<wsdlsoap:operation soapAction="http://ws.orange.pl/mo-sms-service-ws/delivershortmessage" />
<wsdl:input name="DeliverShortMessageRequest">
<wsdlsoap:body use="literal" />
</wsdl:input>
<wsdl:output name="DeliverShortMessageResponse">
<wsdlsoap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="DeliverNotification">
<wsdlsoap:operation soapAction="http://ws.orange.pl/mo-sms-service-ws/delivernotification" />
<wsdl:input name="DeliverNotificationRequest">
<wsdlsoap:body use="literal" />
</wsdl:input>
<wsdl:output name="DeliverNotificationResponse">
<wsdlsoap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="MoSmsService">
<wsdl:port binding="impl:MoSmsServiceWsSoapBinding" name="MoSmsServiceWs">
<wsdlsoap:address location="http://ws.orange.pl/mo-sms-service-ws/MoSmsServiceWs" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
有什么问题吗?
问题出在这一行:
<xsd:import namespace="http://ws.orange.pl/mo-sms-service-ws" />
它尝试递归导入名称空间“http://ws.orange.pl/mo-sms-service-ws”,这不是由 PHP 处理的。
就我而言,删除这一行有帮助。
查看关于这个问题的官方文档: https://www.w3.org/TR/2004/REC-xmlschema-1-20041028/structurals.html#element-import
具体如下第 1.1 条:
模式表示约束:导入约束和语义
除了模式模式对元素信息项施加的条件之外,以下所有条件都必须为真:
1 以下情况中的适当情况必须为真:
1.1 如果命名空间 [属性] 存在,则其“实际值”必须与封闭的的 targetNamespace [属性] 的“实际值”不匹配。
1.2 如果命名空间 [属性] 不存在,则封闭的必须有一个 targetNamespace [属性]