这个问题

我试图用Zend_Soap Zend框架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(web服务类)

<?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存在,我为什么不能使用它?

更新

如果我添加以下功能到类:结果           / **结果            *添加方法结果            *点击            * @参数诠释$参数1点击            * @参数诠释$ param2的结果            * @返回诠释结果            * /点击          公共职能math_add($参数1,$参数2){点击              返回$参数1 + $参数2,点击          }搜索结果 该功能得到认可。但即使我将其更改为add_math2(),该函数不会再次认可。

有帮助吗?

解决方案

OK似乎PHP缓存第一次我创建了一个WSDL文件,并没有重新创建它。

皂缓存可由PHP指令被禁用soap.wsdl_cache_enabled = 0

其他提示

您应该为函数添加评论只,然后声明参数的输入,输出。例如:

/**
* Add method
*
* @param Int $param1
* @param Int $param2
* @return Int
*/
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top