简体   繁体   English

使用soap和wsdl的web服务不能运行php

[英]web service using soap and wsdl is not working php

I am trying to create a web service using wdsl and soap. 我正在尝试使用wdsl和soap创建一个Web服务。 The server is to be written in php. 服务器将用php编写。

As of now I am trying out things by adding just one function to the soap server object. 截至目前,我通过向soap服务器对象添加一个函数来尝试一些事情。 My requirement is that this function should take an associative array. 我的要求是这个函数应该采用一个关联数组。 Right now it returns a string but its just trial for now and will also be returning an array as per requirement. 现在它返回一个字符串,但它现在只是试用,并将根据要求返回一个数组。

For taking an assoc array as input I defined a complexType in the wsdl. 为了将一个assoc数组作为输入,我在wsdl中定义了一个complexType。 Following is the code 以下是代码

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

When I run the soap client file in the browser, it gives the following error. 当我在浏览器中运行soap客户端文件时,它会出现以下错误。

Fatal error: Uncaught SoapFault exception: 
[WSDL] SOAP-ERROR: Parsing Schema: unexpected in complexType

If I use a string datatype instead of a complexType, it works properly. 如果我使用字符串数据类型而不是complexType,它可以正常工作。 I guess i haven't yet understood how complexTypes work so I am unable to debug this. 我想我还没有理解complexTypes是如何工作的,所以我无法调试它。

Also I would like to know if array as the request and response type will work if the client is coded in some other language say .NET. 此外,我想知道如果客户端使用其他语言(例如.NET)编码,则数组作为请求和响应类型是否有效。

(Right now I am testing this on a virtual host on a ubuntu desktop and the server and client are on the same vhost and both written in php) (现在我在ubuntu桌面上的虚拟主机上进行测试,服务器和客户端在同一个虚拟主机上,并且都是用php编写的)

Thanks 谢谢

我认为你需要在xsd:element之前设置xsd:allxsd:sequence

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM