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
| <?PHP
// Include the NuSOAP library.
require("nusoap.php");
// Create a new SOAP server instance.
$server = new soap_server;
// Initialize WSDL support
$server->configureWSDL('BooksInterface', 'urn:BooksInterface');
// Put the WSDL schema types in the namespace with the tns prefix
$server->wsdl->schemaTargetNamespace = 'urn:BooksInterface';
$server->wsdl->addComplexType(
'ArrayOfstring',
'complexType',
'array',
'',
'',
array(),
array(array('ref'=>'SOAP-ENC:Array','wsdl:arrayType'=>'xsd:string[]')),
'xsd:string'
);
$server->wsdl->addComplexType(
'BooksResponse',
'complexType',
'struct',
'all',
'',
array(
'title' => array('name' => 'title', 'type' => 'xsd:string'),
'author' => array('name' => 'author', 'type' => 'xsd:string'),
'isbn' => array('name' => 'isbn', 'type' => 'xsd:string')
)
);
$server->wsdl->addComplexType(
'BooksResponseArray',
'complexType',
'array',
'',
'',
array(),
array(array('ref'=>'SOAP-ENC:Array','wsdl:arrayType'=>'tns:BooksResponse[]')),
'tns:BooksResponse'
);
// Register the method CheckMember
$server->register('BookInformation', // method name
array('queryarray' => 'tns:ArrayOfstring'), // input parameters
array('return' => 'tns:BooksResponseArray'), // output parameters
'urn:BooksInterface', // namespace
'urn:BooksInterface#BookInformation', // soapaction
'rpc', // style
'encoded', // use
'Get information about books' // documentation
);
function BookInformation($queryarray)
{
mysql_connect("localhost", "root", "");
mysql_select_db("test");
$books = array();
foreach ($queryarray as $value)
{
$sql = mysql_query("SELECT title, author, isbn FROM books WHERE title LIKE '%".$value."%' OR author LIKE '".$value."'");
$i=0;
while($row = mysql_fetch_array($sql))
{
$books[] = array(
'title' => $row['title'],
'author' => $row['author'],
'isbn' => $row['isbn']
);
$i++;
}
}
mysql_close();
return $books;
}
// Begin the HTTP listener service
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
?> |