проблема с soap

lokki

Guest
проблема с soap

При вызове функций с одним параметром всё нормально
PHP:
wsdl :
	<message name="get_User_List_a">
   		<part name="server"		type="xsd:string"/>
   		
	</message>
	<message name="get_User_List_Response">
		<part name="return"	type="xsd:boolean"/>
	</message>	
....
		<operation name="get_User_List">
			<input message="tns:get_User_List_a"/>
			<output message="tns:get_User_List_Response"/>
		</operation>


php :

class soap_server_1
{
	
	public function get_User_List($server)
	{
		return true;
	}
}		
$s_server1	=	new SoapServer('abstract_.wsdl');
$s_server1->setClass('soap_server_1');
$s_server1->handle();
ЕСЛИ СТАВЛЮ 2 аргумента в функции
PHP:
wsdl :
	<message name="get_User_List_a">
   		<part name="server"		type="xsd:string"/>
   		<part name="server1"	type="xsd:string"/>
	</message>
	<message name="get_User_List_Response">
		<part name="return"	type="xsd:boolean"/>
	</message>	
....
		<operation name="get_User_List">
			<input message="tns:get_User_List_a"/>
			<output message="tns:get_User_List_Response"/>
		</operation>


php :

class soap_server_1
{
	
	public function get_User_List($server, $server1)
	{
		return true;
	}
}		
$s_server1	=	new SoapServer('abstract_.wsdl');
$s_server1->setClass('soap_server_1');
$s_server1->handle();
пишет ошибку :
Fatal error: Uncaught SoapFault exception: [SOAP-ENV:Client] looks like we got "Body" with several functions call in C:\internet\home\localhost\www\docs\test\035_soap_client.php:28 Stack trace: #0 C:\internet\home\localhost\www\docs\test\035_soap_client.php(28): SoapClient_1->get_User_List('get_User_List', Array)


В чём может быть проблема ?
php 5.0.1
 

S.Andrew

Guest
Могу привести кусок моего работающего кода:


WSDL
------------------------------------------------------------------
PHP:
<definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:ns="http://chess/" targetNamespace="http://chess/">
  <types>
    <xsd:schema targetNamespace="http://chess/" elementFormDefault="qualified">
       <xsd:element name="registerResponceType">
          <xsd:complexType>
             <xsd:sequence>
                <xsd:element minOccurs="1" maxOccurs="1" name="code" type="xsd:int"/>
                <xsd:element minOccurs="1" maxOccurs="1" name="text" type="xsd:string"/>
             </xsd:sequence>
          </xsd:complexType>
       </xsd:element>
       <xsd:element name="registerRequestType">
          <xsd:complexType>
             <xsd:sequence>
                <xsd:element minOccurs="1" maxOccurs="1" name="login" type="xsd:string"/>
                <xsd:element minOccurs="1" maxOccurs="1" name="password" type="xsd:string"/>
                <xsd:element minOccurs="1" maxOccurs="1" name="email" type="xsd:string"/>
             </xsd:sequence>
          </xsd:complexType>
       </xsd:element>
       <xsd:element name="loginResponceType">
          <xsd:complexType>
             <xsd:sequence>
                <xsd:element minOccurs="1" maxOccurs="1" name="code" type="xsd:int"/>
                <xsd:element minOccurs="1" maxOccurs="1" name="text" type="xsd:string"/>
             </xsd:sequence>
          </xsd:complexType>
       </xsd:element>
       <xsd:element name="loginRequestType">
          <xsd:complexType>
             <xsd:sequence>
                 <xsd:element minOccurs="1" maxOccurs="1" name="login" type="xsd:string"/>
                 <xsd:element minOccurs="1" maxOccurs="1" name="password" type="xsd:string"/>
             </xsd:sequence>
          </xsd:complexType>
       </xsd:element>
    </xsd:schema>
  </types>
  <message name="RegisterRequest">
     <part name="param" element="ns:registerRequestType"/>
  </message>
  <message name="RegisterResponse">
     <part name="param" element="ns:registerResponceType"/>
  </message>
  <message name="LoginRequest">
     <part name="param" element="ns:loginRequestType"/>
  </message>
  <message name="LoginResponse">
     <part name="param" element="ns:loginResponceType"/>
  </message>
  <portType name="ChessPortType">
     <operation name="register">
        <input message="ns:RegisterRequest"/>
        <output message="ns:RegisterResponse"/>
     </operation>
     <operation name="login">
        <input message="ns:LoginRequest"/>
        <output message="ns:LoginResponse"/>
     </operation>
  </portType>
  <binding name="ChessBinding" type="ns:ChessPortType">
     <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
     <operation name="register">
        <soap:operation soapAction="http://chess/register" style="document"/>
            <input>
               <soap:body use="literal"/>
            </input>
            <output>
               <soap:body use="literal"/>
            </output>
     </operation>
     <operation name="login">
        <soap:operation soapAction="http://chess/login" style="document"/>
            <input>
               <soap:body use="literal"/>
            </input>
            <output>
               <soap:body use="literal"/>
            </output>
     </operation>
  </binding>
  <service name="ChessService">
     <port name="ChessPort" binding="ns:ChessBinding">
        <soap:address location="http://chess/chess.php"/>
     </port>
  </service>
</definitions>
------------------------------------------------------------------

PHP
------------------------------------------------------------------
PHP:
class user extends core{
   var $arr;
   function __construct(){
      $this->arr = new arrayQry (DATA_PATH, "users.dat");
   }
   function register($data){
      $this->arr->Select("login", $data->login, "=");
      if (sizeof($this->arr->Result) > 0){
         throw new SoapFault("401","Такой пользователь уже сцществует");
      }
      $id = $this->arr->NextVal("users");
      if ($this->arr->Insert(array("id" => $id, "login" => $data->login, "password" => $data->password, "email" => $data->email)))
         return array("code" => "200", "text" => "OK");
      else
         throw new SoapFault("400","Ошибка");
   }
   function login($data){
      $this->arr->Select(array ("login", "password"), array($data->login, $data->password), "=");
      if (sizeof($this->arr->Result) > 0){
         return array("code" => "401", "text" => "This login is already exists");
      }else{
         throw new SoapFault("410",urlencode("Нет такого пользователя"));
      }
   }
}
------------------------------------------------------------------

Думаю можно все решить и не используя таких схем, скорее всего на входе функции будет на 2 параметра а массив, а уже в нем интересующие данные. Но это надо пробовать.

PHP:
class soap_server_1 
{ 
     
    public function get_User_List($array) 
    { 
        return true; 
    } 
}         
$s_server1    =    new SoapServer('abstract_.wsdl'); 
$s_server1->setClass('soap_server_1'); 
$s_server1->handle();
 

lokki

Guest
Спасибо .
Похоже так и поступлю.
Непонятно по какой причине не работало (и не работает) хотя и переставил php 5.0.2
 
Сверху