Normaal lurk ik een beetje rond op deze forums, maar nu heb ik toch echt hulp nodig met dit probleem.
Het ophalen van een enkele array uit de getArtikel functie lukt wel, maar er moet nu een meerdimensionale array uit de functie gehaald worden, die dus ook via de webservice naar de client gestuurd wordt.
PHP:
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
| <<SERVER.PHP>> <?php // includes nusoap classes require('nusoap.php'); // create server $l_oServer = new soap_server(); // wsdl generation $l_oServer->debug_flag=false; $l_oServer->configureWSDL('eehmmDB', 'http://localhost'); $l_oServer->wsdl->schemaTargetNamespace = 'http://localhost'; // add complex type $l_oServer->wsdl->addComplexType( 'ArtikelData', 'complexType', 'struct', 'all', '', array( 'NI_HEADLINE' => array('name'=>'NI_HEADLINE', 'type'=>'xsd:string'), 'NI_ARTIKEL' => array('name'=>'NI_ARTIKEL', 'type'=>'xsd:string')) //'AANTAL' => array('name' => 'AANTAL', 'type' =>'xsd:string')) ); // register method $l_oServer->register('getArtikel', array('artikel' => 'xsd:string'), array('return'=>'tns:ArtikelData'), 'http://localhost'); // method code (get DB result) function getArtikel ($a_stInput) { if (is_string($a_stInput)) { $l_oDBlink = @mysql_connect( 'localhost', 'root', ''); $l_oDBresult = @mysql_db_query( 'eehmmDB', 'SELECT * FROM nieuwsberichten WHERE NI_HEADLINE = LCASE("' . mysql_escape_string((string)$a_stInput) . '") LIMIT 1'); // simple error checking if (!$l_oDBresult) { return new soap_fault('Server', '', 'Internal server error.'); } // no data avaible for artikelen if (!mysql_num_rows($l_oDBresult)) { return new soap_fault('Server', '','Niet gevonden.'); } mysql_close($l_oDBlink); // return data return mysql_fetch_array($l_oDBresult, MYSQL_ASSOC); } // we accept only a string else { return new soap_fault('Client', '', 'Service requires a string parameter.'); } } // pass incoming (posted) data $l_oServer->service($HTTP_RAW_POST_DATA); ?> <<CLIENT.PHP>> <?php // use form data if ((string)$_GET['action'] == 'get_data') { // includes nusoap classes require('nusoap.php'); // set parameters and create client $l_oClient = new soapclient_xxx('http://localhost/servert/server.php?wsdl', 'wsdl'); $l_oProxy = $l_oClient->getProxy(); // call a webmethod (getWeather) $l_stResult = $l_oProxy->getArtikel((string)$_POST['headline']); // check for errors if (!$l_oClient->getError()) { // print results print '<h1>Current data for: ' . (string)$_POST['headline'] . ':</h1><ul><li>hoofdlijn: ' . $l_stResult['NI_HEADLINE'] . '</li><li>inhoud: ' . $l_stResult['NI_ARTIKEL'] . '</li></ul>'; print_r(array_keys($l_stResult)); } // print error description else { echo '<h1>Error: ' . $l_oClient->getError() . '</h1>'; } } // output search fclientorm print ' <form name="input" action="'.$_SERVER['PHP_SELF'].'?action=get_data" method="POST"> Hoofdlijn: <input type="text" name="headline"> <input type="submit" value="Search"> </form> '; ?> |
Het ophalen van een enkele array uit de getArtikel functie lukt wel, maar er moet nu een meerdimensionale array uit de functie gehaald worden, die dus ook via de webservice naar de client gestuurd wordt.