|
|
|
| Пытаюсь написать простенький сервис, но никак не могу понять как из класса вернуть массив или объект через SOAP. Строку возвращает без проблем. Может у кого-то есть под рукой небольшой пример? | |
|
|
|
|
|
|
|
для: Loki
(26.09.2008 в 09:52)
| | C передачей объекта вроде разобрался:)
Теперь бы кто показал как передавать массив и сообщения об ошибках;) | |
|
|
|
|
|
|
|
для: Loki
(26.09.2008 в 10:27)
| | я с SOAP не особо, но мне думается, что коль скоро они (клиент и сервер) общаются по сети, передавая свои сообщения в XML формате, то никаких нескалярных ответов быть не может!
но раз получилось, покажите уж публике КАК? ) | |
|
|
|
|
|
|
|
для: mechanic
(26.09.2008 в 10:58)
| |
<?
class Users {
public function Login($login,$pass) {
$this->login=array('login'=>$login, 'pass'=>$pass);
return $this;
}
public function Logout() { return true; }
}
|
wsdl
<?xml version="1.0"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://domain.org/users.php" xmlns:soap-env="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" targetNamespace="http://domain.org/users.php">
<types>
<xsd:schema>
<xsd:complexType name="array">
<xsd:complexContent>
<xsd:restriction base="soapenc:array">
<xsd:attribute ref="soapenc:arrayType" arrayType="tns:mixed[]"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<complexType name="mixed">
<all>
<element name="varString" type="xsd:string"/>
<element name="varInt" type="xsd:int"/>
<element name="varFloat" type="xsd:float"/>
<element name="varArray" type="tns:array"/>
</all>
</complexType>
<complexType name="Users">
<all/>
</complexType>
</xsd:schema>
</types>
<message name="LoginInput">
<part name="login" type="xsd:string"/>
<part name="pass" type="xsd:string"/>
</message>
<message name="LogoutInput"/>
<message name="LoginOutput">
<part name="return" type="tns:Users"/>
</message>
<message name="LogoutOutput">
<part name="return" type="xsd:string"/>
</message>
<portType name="UsersPortType">
<operation name="Login">
<input message="tns:LoginInput"/>
<output message="tns:LoginOutput"/>
</operation>
<operation name="Logout">
<input message="tns:LogoutInput"/>
<output message="tns:LogoutOutput"/>
</operation>
</portType>
<binding name="UsersBinding" type="tns:UsersPortType">
<soap-env:binding xmlns="http://schemas.xmlsoap.org/wsdl/soap/" style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation xmlns:default="http://schemas.xmlsoap.org/wsdl/soap/" name="Login">
<input xmlns:default="http://schemas.xmlsoap.org/wsdl/soap/">
<soap-env:body xmlns="http://schemas.xmlsoap.org/wsdl/soap/" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output xmlns:default="http://schemas.xmlsoap.org/wsdl/soap/">
<soap-env:body xmlns="http://schemas.xmlsoap.org/wsdl/soap/" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
<operation xmlns:default="http://schemas.xmlsoap.org/wsdl/soap/" name="Logout">
<input xmlns:default="http://schemas.xmlsoap.org/wsdl/soap/">
<soap-env:body xmlns="http://schemas.xmlsoap.org/wsdl/soap/" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output xmlns:default="http://schemas.xmlsoap.org/wsdl/soap/">
<soap-env:body xmlns="http://schemas.xmlsoap.org/wsdl/soap/" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<service name="UsersService">
<port xmlns:default="http://schemas.xmlsoap.org/wsdl/soap/" name="UsersPort" binding="tns:UsersBinding">
<soap-env:address xmlns="http://schemas.xmlsoap.org/wsdl/soap/" location="http://domain.org/users.php"/>
</port>
</service>
</definitions>
|
А вот с массивом пока никак. Только если обернуть его в класс. | |
|
|
|
|
|
|
|
для: Loki
(26.09.2008 в 11:14)
| | Во первых wsdl не валидный, можно начать с этого. И покажите мне как вы описываете сервер и клиент. | |
|
|
|
|
|
|
|
для: StVolodimir
(27.09.2008 в 14:02)
| | клиент
<?
$client = new SoapClient("http://domain.org/wsdl/users.wsdl", array("trace"=>1));
$result = $client->login("login", "pass");
|
сервер
<?
$server = new SoapServer('http://domain.org/wsdl/users.wsdl');
$server->setClass('Users');
$server->handle();
|
| |
|
|
|