我正在尝试使用 wdsl 和 soap 创建 Web 服务。服务器是用php写的。
截至目前,我正在通过向 soap 服务器对象添加一个函数来尝试一些事情。我的要求是这个函数应该采用关联数组。现在它返回一个字符串,但它现在只是试用版,并且还将根据要求返回一个数组。
为了将关联数组作为输入,我在 wsdl 中定义了一个 complexType。 以下是代码
<types>
<xsd:schema
targetNamespace="http://projects.kp/test/webservice/StoreService.wsdl"
xmlns="http://www.w3.org/1999/XMLSchema/">
<xsd:complexType name="store">
<xsd:element name="name" type="xsd:string" />
<xsd:element name="subdomain" type="xsd:string" />
</xsd:complexType>
</xsd:schema>
</types>
<message name="StoreRequest">
<part name="store" type="tns:store"/>
</message>
<message name="StoreResponse">
<part name="url" type="xsd:string"/>
</message>
当我在浏览器中运行 soap 客户端文件时,出现以下错误。
Fatal error: Uncaught SoapFault exception:
[WSDL] SOAP-ERROR: Parsing Schema: unexpected in complexType
如果我使用字符串数据类型而不是复杂类型,它可以正常工作。 我想我还没有理解 complexTypes 是如何工作的,所以我无法调试它。
另外我想知道如果数组作为请求和响应类型是否有效 客户端使用其他语言编码,例如 .NET。
(现在我正在 ubuntu 桌面上的虚拟主机上测试这个,服务器和客户端在同一个虚拟主机上,都是用 php 编写的)
谢谢
最佳答案
我认为您需要在xsd:element
之前设置xsd:all 或xsd:sequence关于php - 使用 soap 和 wsdl 的网络服务无法正常工作 php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4634064/