WSDL 肥皂退货问题
大家好,我如何返回包含我选择的所有用户的 SOAP 信封或数组? 我试图返回数据库结果集的数组,但没有返回,这是我
<?xml version='1.0' encoding='utf-8' ?>
<definitions name="ClientSearch" targetNamespace="urn:ClientSearch" xmlns:typens="urn:ClientSearch" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/">
<message name="searchUser">
<part name="userName" type="xsd:string" />
</message>
<message name="searchUserResponse">
<part name="searchUserReturn" type="xsd:string" />
</message>
<portType name="searchUserPortType">
<operation name="searchUser">
<input message="typens:searchUser" />
<output message="typens:searchUserResponse" />
</operation>
</portType>
<binding name="searchUserBinding" type="typens:searchUserPortType">
<operation name="searchUser">
<soap:operation soapAction="urn:searchUserAction" />
<input>
<soap:body namespace="urn:ClientSearch" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output>
<soap:body namespace="urn:ClientSearch" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<service name="clientSearchService">
<port name="searchUserPort" binding="typens:searchUserBinding">
<soap:address location="http://localhost/service/server.php"/>
</port>
</service>
</definitions>
用来获取数据库中的数据的 wsdl 函数
public function searchUser( $Name ){
$this->__getDatabase();
$this->Name = (string)$Name;
if( !is_null( $this->Name ) ){
$query = $this->db->query( 'SELECT * FROM `t_users` WHERE `nome` LIKE "%'.$this->Name.'%"' );
}
}
调用 webservice 的页面
<?php
ini_set("soap.wsdl_cache_enabled", "0");
$oSoapClient = new SOAPClient("http://localhost/service/service.wsdl");
var_dump( $oSoapClient->searchUser( 'name' ) ) ;
?>
Hey guys, how i can return SOAP Envelope or Array with all users of i selected ?
i trying to return array of database resultset, but not returning, here is my wsdl
<?xml version='1.0' encoding='utf-8' ?>
<definitions name="ClientSearch" targetNamespace="urn:ClientSearch" xmlns:typens="urn:ClientSearch" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/">
<message name="searchUser">
<part name="userName" type="xsd:string" />
</message>
<message name="searchUserResponse">
<part name="searchUserReturn" type="xsd:string" />
</message>
<portType name="searchUserPortType">
<operation name="searchUser">
<input message="typens:searchUser" />
<output message="typens:searchUserResponse" />
</operation>
</portType>
<binding name="searchUserBinding" type="typens:searchUserPortType">
<operation name="searchUser">
<soap:operation soapAction="urn:searchUserAction" />
<input>
<soap:body namespace="urn:ClientSearch" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output>
<soap:body namespace="urn:ClientSearch" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<service name="clientSearchService">
<port name="searchUserPort" binding="typens:searchUserBinding">
<soap:address location="http://localhost/service/server.php"/>
</port>
</service>
</definitions>
Function of i using to get data in database
public function searchUser( $Name ){
$this->__getDatabase();
$this->Name = (string)$Name;
if( !is_null( $this->Name ) ){
$query = $this->db->query( 'SELECT * FROM `t_users` WHERE `nome` LIKE "%'.$this->Name.'%"' );
}
}
Page of calls webserviçe
<?php
ini_set("soap.wsdl_cache_enabled", "0");
$oSoapClient = new SOAPClient("http://localhost/service/service.wsdl");
var_dump( $oSoapClient->searchUser( 'name' ) ) ;
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您的代码中有几个缺失的部分。
WSDL 定义表示您的响应是“字符串”类型,可能您需要创建一个复杂类型才能获取正确的信息,但由于我看不到您的表格,无法告诉您正确的答案
你没有从 php 函数返回任何内容.
纠正这些事情,你应该没问题。
I think you have several missing parts on your code.
The WSDL definition says your response is of type "string", may be you need to create a complex type to get the correct info, but as i cant see you table cant tell you the right answer
you are not returning anything from php function.
Correct those things and you should be fine.