Bonjour tout le monde ,
je suis entrain de développer un web service avec php5.3.1 nusoap-php5-0.9 et xampp.
j'ai eu un problème au niveau parsing mon résultat du php au xml
mon code server.php :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
error_reporting(E_ERROR | E_WARNING | E_PARSE);
// Pull in the NuSOAP code
require_once("nusoap/lib/nusoap.php");
$namespace = "http://localhost/webservice/new.php";
$server = new soap_server();// Create the server instance
$server->configureWSDL("getListSchedule");// configure our WSDL
$server->configureWSDL('schedulewsdl', 'urn:schedulewsdl');
$server->wsdl->schemaTargetNamespace = $namespace;// set our namespace
$server->methodreturnisliteralxml = TRUE;
$server->soap_defencoding = 'utf-8'; // Character encoding
$server->wsdl->addComplexType(
  'schedule',
  'complexType',
  'struct',
  'all',
  '',
  array(
    'id' => array('name' => 'id', 'type' => 'xsd:int'),
    'idBox' => array('name' => 'idBox', 'type' => 'xsd:string'),
    'network_id' => array('name' => 'network_id', 'type' => 'xsd:int'),
    'event_id' => array('name' => 'event_id', 'type' => 'xsd:int'),
    'serie_id' => array('name' => 'serie_id', 'type' => 'xsd:string'),
    'TS_id' => array('name' => 'TS_id', 'type' => 'xsd:int'), 
    'serv_id' => array('name' => 'serv_id', 'type' => 'xsd:int'),
    'title' => array('name' => 'title', 'type' => 'xsd:string'),
    'channel_name' => array('name' => 'channel_name', 'type' => 'xsd:string'),
    'startTime' => array('name' => 'startTime', 'type' => 'xsd:int'),
    'stopTime' => array('name' => 'stopTime', 'type' => 'xsd:int')
    )
);

$server->wsdl->addComplexType(
    'ScheduleArray',    // Name
    'complexType',    // Type Class
    'array',          // PHP Type
    '',               // Compositor
    'SOAP-ENC:Array', // Restricted Base
    array(),
    array(
        array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:schedule[]')
    ),
    'tns:schedule'
);
/*----------------------Register get all list schedule function---------------------------*/

$server->register('getListSchedule',
                           array('idBox'=>'xsd:string'), //paramètre en entré
                           array('schedule' => 'tns:scheduleArray')
               //array('return'=>'xsd:string')              
    );
/*---------------------------Body get all list schedule function--------------------------*/   

function getListSchedule($idBox) {
   
    $connect = mysqli_connect("localhost","root","","RecordScheduleDB");
    $sql = "SELECT * FROM schedule WHERE idBox='$idBox'";
    $query=mysqli_query($connect,$sql);
	while($result = mysqli_fetch_array($query)){
        $schedule = array(
            'id' => $result['id'],
            'TS_id' => $result['TS_id'],
            'network_id' => $result['network_id'],
            'serv_id' => $result['serv_id'],
            'serie_id' => $result['serie_id'],
            'event_id' => $result['event_id'],
            'title' => $result['title'],
            'channel_name' => $result['channel_name'],
            'startTime' => $result['startTime'],
            'stopTome' => $result['stopTime'],'type' => 'tns:scheduleArray');
            $ScheduleArray[]=$schedule;

    }
   return $ScheduleArray; 
}        
/*------------------------------------------------------------------------------------------*/              
$POST_DATA = isset($GLOBALS['HTTP_RAW_POST_DATA']) ? $GLOBALS['HTTP_RAW_POST_DATA'] : '';
$server->service($POST_DATA);// pass our posted data (or nothing) to the soap service
exit();
?>
code client client.php
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
error_reporting(E_ERROR | E_WARNING | E_PARSE); 
require_once('nusoap/lib/nusoap.php');

$client = new nusoap_client('http://localhost/webservice/new.php?wsdl',array('trace' => true, 'exceptions' => 0));			
$id='123hi';
$param = array('idBox'=>$id);
//$result = $client->getDebugLevel('getListSchedule',$param);

$result = $client->call('getListSchedule',$param);
$count = count($result);
echo $count;
print_r($result);

echo "<h2>Request</h2>";
echo "<pre>" . htmlspecialchars($client->request, ENT_QUOTES) . "</pre>";
echo "<h2>Response</h2>";
echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>";
echo '<h2>ResponseData</h2><pre>' . htmlspecialchars($client->responseData, ENT_QUOTES) . '</pre>';
echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '</pre>';
?>
la resultat est :
<?xml version="1.0" encoding="utf-8"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlnssd="http://www.w3.org/2001/XMLSchema" xmlnssi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body>
<ns1:getListScheduleResponse xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/">
Array
</ns1:getListScheduleResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
2014-07-15 16:28:38.741805 nusoap_client: Error: XML error parsing SOAP payload on line 1: Not well-formed (invalid token)
malgré qui'il ma fiche la bonne réponse en utilisant print_r mon tableau .
je serais trés reconnaissante si vous pouvez m'aider .