0

私は Web サービスについて学び始めており、いくつかのテストを行っています。

テーブルのすべてのデータをクライアントに渡すサービスを作成しようとしていますが、機能させることができません。

最初の 'servei' は機能しますが、2 番目は機能しません。

任意の提案をいただければ幸いです。ありがとう

service.php

require 'lib/nusoap.php';    

$server = new nusoap_server();
$server->configureWSDL("test" . "urn:test");    

include 'functions.php';    

$server->wsdl->addComplexType('servei', 'complexType', 'struct', 'all', '', array(
    'preu_antic' => array('name' => 'preu_antic', 'type' => 'xsd:float'),
    'preu_actual' => array('name' => 'preu_actual', 'type' => 'xsd:float'),
    'descompte_servei' => array('name' => 'descompte_servei', 'type' => 'xsd:float'),
));    

$server->wsdl->addComplexType('ServiceTypes', 'complexType', 'struct', 'all', '', array(
    'id_tipus_servei' => array('name' => 'id_tipus_servei', 'type' => 'xsd:inter'),
    'nom_tipus_servei' => array('name' => 'nom_tipus_servei', 'type' => 'xsd:string'),
    'descripcio_tipus_servei' => array('name' => 'descripcio_tipus_servei', 'type' => 'xsd:string'),
));    

$server->wsdl->addComplexType('ArrayOfServiceTypes', 'complexType', 'array', '', 'SOAP-ENC:Array', array(), array(
    array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:ServiceTypes[]')), 'tns:ServiceTypes');    

$server->register('servei', array("id_servei" => 'xsd:inter'), array("return" => 'tns:servei'));
$server->register('getServiceTypes', array("idioma" => 'xsd:string'), array("return" => 'tns:ArrayOfServiceTypes'));    


$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
?>

関数.php

function servei($id){
    conexio();
    $query_servei = mysql_query("SELECT * FROM servei WHERE id_servei = '$id'")or die(mysql_error());
    $row = mysql_fetch_array($query_servei);
    $preu_antic = $row['preu_antic'];
    $preu_actual = $row['preu_actual'];
    $descompte_servei = $row['descompte_servei'];

    $servei = array('preu_antic'=>$preu_antic,'preu_actual'=>$preu_actual,'descompte_servei'=>$descompte_servei);

    return $servei;
}    

function getServiceTypes($idioma){
    conexio();
    $query = mysql_query("SELECT id_tipus_servei, nom_tipus_servei, descripcio_tipus_servei FROM idioma_tipus_servei WHERE id_idioma = '$idioma'") or die(mysql_error());
    $n = 0;
    while ($row = mysql_fetch_array($query)) {
        $result[$n]['id_tipus_servei'] = $row['id_tipus_servei'];
        $result[$n]['nom_tipus_servei'] = $row['nom_tipus_servei'];
        $result[$n]['descripcio_tipus_servei'] = $row['descripcio_tipus_servei'];
        $n++;
    }
    return $result;
} 
?>

client.php

<?php
    require 'lib/nusoap.php';
    include 'functions.php';
    $client = new nusoap_client("http://192.168.8.155:8090/webservice/service.php?wsdl");    

   //$id=1;
   // $servei = $client -> call('servei',array("id_servei"=>"$id"));
   // print_r($servei);    


    $idioma ='ca';
    $servicetypes = $client -> call('getServiceTypes',array("idioma"=>"$idioma"));
    print_r($servicetypes);    

    ?>
4

2 に答える 2

0

わかりました、私はそれを処理しました。

PHP 5.4 を使用している場合は、nusoap.php の 6132 行をコメント化する必要があります。

于 2013-07-17T07:46:42.460 に答える
0

次のように変更した場合、これを修正できませんでした:

$this->debug("serializing array element: $k, $v of type: $typeDef[arrayType]");

に:

$this->debug("serializing array element: $k, $v of type: " . $typeDef['arrayType'] );

于 2014-10-21T23:11:02.950 に答える