ZF 1.9.6 ZEND_SOAP: وظيفة ("DoString") ليست طريقة صالحة لهذه الخدمة

StackOverflow https://stackoverflow.com/questions/1907358

سؤال

نسخة مكررة هذا السؤال

أحاول العمل مع ZenD_SOAP باستخدام Zend Framework 1.9.6 و PHP 5.3.1.

SOAP.PHP (مولد WSDL)

<?php
   require_once('Zend/Soap/Server.php');
   require_once('Zend/Soap/AutoDiscover.php');
   require_once('Soaping.php');
   $_WSDL_URI="http://server/soap/soap.php?wsdl";

    if(isset($_GET['wsdl'])) {
            hadleWSDL();
        } else {
            handleSOAP();
        }
  function hadleWSDL() {
        $autodiscover = new Zend_Soap_AutoDiscover();
        $autodiscover->setClass('Soaping');
        $autodiscover->handle();
    }

     function handleSOAP() {
     global $_WSDL_URI;
        $soap = new Zend_Soap_Server($_WSDL_URI); 
       $soap->setClass('Soaping');
        $soap->handle();
    }

SOAPING.PHP (فئة خدمة الويب)

<?php
class Soaping {

   /**
    *
    * @param string $str
    * @return string 
    */
    function doString($str) {
        return $str;
    }

}

client.php - العميل

<?php
   require_once('Zend/Soap/Client.php');
   $_WSDL_URI="http://server/soap/soap.php?wsdl";
       $client = new Zend_Soap_Client($_WSDL_URI);
       $client->doString('aaa');

عندما أقوم بتنفيذ ملف Client.php، أحصل على الخطأ:Fatal error: Uncaught SoapFault exception: [Sender] Function ("do_math") is not a valid method for this service in /usr/local/ZendFramework-1.9.6/library/Zend/Soap/Client.php:1090 Stack trace: #0 /usr/local/ZendFramework-1.9.6/library/Zend/Soap/Client.php(1090): SoapClient->__soapCall('do_math', Array, NULL, NULL, Array) #1 [internal function]: Zend_Soap_Client->__call('do_math', Array) #2 /home/ufk/Projects/xpogames-development/xpo/soap/client.php(6): Zend_Soap_Client->do_math(1, 1) #3 {main} thrown in /usr/local/ZendFramework-1.9.6/library/Zend/Soap/Client.php on line 1090

XML الذي يتم إنشاؤه بواسطة متابعة الرابط http: //server/soap/soap.php؟ WSDL

<?xml version="1.0"?> <definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://xpogames/soap/soap.php" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="Soaping" targetNamespace="http://xpogames/soap/soap.php"><types><xsd:schema targetNamespace="http://xpogames/soap/soap.php"/></types><portType name="SoapingPort"><operation name="doString"><documentation>do string</documentation><input message="tns:doStringIn"/><output message="tns:doStringOut"/></operation></portType><binding name="SoapingBinding" type="tns:SoapingPort"><soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/><operation name="doString"><soap:operation soapAction="http://xpogames/soap/soap.php#doString"/><input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://xpogames/soap/soap.php"/></input><output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://xpogames/soap/soap.php"/></output></operation></binding><service name="SoapingService"><port name="SoapingPort" binding="tns:SoapingBinding"><soap:address location="http://xpogames/soap/soap.php"/></port></service><message name="doStringIn"><part name="str" type="xsd:string"/></message><message name="doStringOut"><part name="return" type="xsd:string"/></message></definitions>

أرى أن الوظيفة موجودة في XML، لماذا لا يمكنني استخدامه؟

تحديث

إذا أضفت الوظيفة التالية إلى الفصل:
/**
* إضافة طريقة
*
* param int $ Param1
* param int $ param2
* @ عودة int.
*/
الوظيفة العامة Math_add ($ param1، $ param2) {
عودة $ param1 + $ param2؛
}

الحصول على هذه الوظيفة معترف بها. ولكن حتى لو قمت بتغييره إلى add_math2 ()، لا يتم التعرف على الوظيفة مرة أخرى.

هل كانت مفيدة؟

المحلول

حسنا، يبدو أن PHP مخزنة مؤقتا في المرة الأولى التي قمت بإنشاء ملف WSDL ولم أعيد إعادة ذلك.

يمكن تعطيل التخزين المؤقت الصابون من قبل SOAP.WSDL_CACHE_ENAILIND = 0

نصائح أخرى

يجب عليك إضافة تعليق للحصول على وظيفة فقط، ثم تعلن إدخال المعلمة، والإخراج. مثال:

/**
* Add method
*
* @param Int $param1
* @param Int $param2
* @return Int
*/
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top