Nusoap WSDL请求无法正常工作

时间:2011-12-01 20:12:07

标签: xml nusoap

我在从WSDL获得我想要的结果时遇到了问题。

我的剧本:

<?php
require_once($_SERVER['DOCUMENT_ROOT'].'/lib/classes/class.glssoap.php');

$glssoap = new GLSSoap;

echo "<pre>";
//print_r($glssoap->GetOneParcelShop(96101)); // SUCCESS
//print_r($glssoap->GetAllParcelShops()); // SUCCESS
print_r($glssoap->GetAllParcelShopsInZipcode(8000)); // FAILS : RETURNS  operation GetAllParcelShopsInZipcode not present.
print_r($glssoap->GetNearestParcelShops('Kriegersvej 8', '8000')); // FAILS : RETURNS  operation GetNearestParcelShops not present.
print_r($glssoap->SearchNearstParcelShops('Kriegersvej 8', '8000')); // FAILS : RETURNS  operation SearchNearstParcelShops not present.
echo "</pre>";
?>

班级:

<?php
class GLSSoap {

    //Get one ParcelShop 
    public function GetOneParcelShop($parcelShopNumber)
    {
        $gls_params = array();
        $gls_params['ParcelShopNumber'] = $parcelShopNumber;

        $result = $this->_soapcall('GetOneParcelShop', $gls_params);

        return $result;
    }

    //Returns all ParcelShops in Denmark 
    public function GetAllParcelShops()
    {   
        $gls_params = array();
        $result = $this->_soapcall('GetAllParcelShops', $gls_params);

        return $result;
    }

    //Returns all ParcelShops in a zipcode 
    public function GetAllParcelShopsInZipcode($zipCode)
    {   
        $gls_params = array();
        $gls_params['Zipcode'] = $zipCode;

        $result = $this->_soapcall('GetAllParcelShopsInZipcode', $gls_params);

        return $result;
    }

    //Search for the nearest ParcelShops to an address - Strict version - used for automated processing 
    public function GetNearestParcelShops($street, $zipCode, $amount = 4)
    {   
        $gls_params = array();
        $gls_params['Street'] = $street;
        $gls_params['zipcode'] = $zipCode;
        $gls_params['amount'] = $amount;

        $result = $this->_soapcall('GetNearestParcelShops', $gls_params);

        return $result;
    }

    //Search for the nearest ParcelShops to an address - Loose version - user should veryfi data 
    public function SearchNearstParcelShops($street, $zipCode, $amount = 4)
    {   
        $gls_params = array();
        $gls_params['Street'] = $street;
        $gls_params['zipcode'] = $zipCode;
        $gls_params['amount'] = $amount;

        $result = $this->_soapcall('SearchNearstParcelShops', $gls_params);

        return $result;
    }

    private function _soapcall($call, $params)
    {
        require_once(dirname(__FILE__).'/class.nusoap.php');

        $soapclient = new nusoap_client('http://www.gls.dk/webservices_v2/wsPakkeshop.asmx?WSDL','wsdl');

        $result = $soapclient->call($call, array('parameters' => $params));

        /* Debug */
        echo '<h2>Request</h2><pre>' . htmlspecialchars($soapclient->request, ENT_QUOTES) . '</pre>';
        echo '<h2>Response</h2><pre>' . htmlspecialchars($soapclient->response, ENT_QUOTES) . '</pre>';
        //echo '<h2>Debug</h2><pre>' . htmlspecialchars($soapclient->debug_str, ENT_QUOTES) . '</pre>';
        echo '<pre>'; print_r($result); echo '</pre>';

        // Check for a fault
        if ($soapclient->fault) {
            echo '<div class="alert error"><h2>Fault</h2><pre>';
            print_r($result);
            echo '</pre></div>';
        } else {
            // Check for errors
            $err = $soapclient->getError();
            if ($err) {
                // Display the error
                echo '<div class="alert error"><h2>Error</h2><pre>' . $err . '</pre></div>';
            } else {
                return $result;
            }
        }

        return false;
    }
};
?>

我还使用了NUSOAP类,如下所示:http://sourceforge.net/projects/nusoap/


我的问题是GetAllParcelShopsInZipcode,GetNearestParcelShops&amp; SearchNearestParcelShops all返回“操作X不存在”。

我正在使用的服务位于:http://www.gls.dk/webservices_v2/wsPakkeshop.asmx

任何人都可以给我一个提示我做错了吗?

提前致谢

1 个答案:

答案 0 :(得分:1)

对于后来遇到这个问题的人来说,问题在于GLS文档没有正确更新。请注意其在线Web服务中不同方法的名称。