ZF 1.9.6 ZEND_SOAP : 함수 ( "DOSTRING")는이 서비스에 유효한 방법이 아닙니다.

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

문제

복제 이 질문

Zend Framework 1.9.6 및 PHP 5.3.1을 사용하여 Zend_soap과 함께 작업하려고합니다.

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

링크 http : //server/soap/soap.php? wsdl에 따라 생성 된 xml

<?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
* @return int
*/
공개 기능 Math_add ($ param1, $ param2) {
$ param1+$ param2를 반환합니다.
}

이 기능은 인식됩니다. 그러나 add_math2 ()로 변경하더라도 함수는 다시 인식되지 않습니다.

도움이 되었습니까?

해결책

좋아, PHP는 처음으로 WSDL 파일을 만들었고 재현하지 않은 것 같습니다.

Php Directive Soap.wsdl_cache_enabled = 0에 의해 비누 캐싱을 비활성화 할 수 있습니다.

다른 팁

함수에 대한 주석을 추가 한 다음 매개 변수 입력, 출력을 선언해야합니다. 예시:

/**
* Add method
*
* @param Int $param1
* @param Int $param2
* @return Int
*/
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top