Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?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/"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
- <SOAP-ENV:Body>
- <SOAP-ENV:Fault>
- <faultcode xsi:type="xsd:string">SOAP-ENV:Client</faultcode>
- <faultactor xsi:type="xsd:string"></faultactor>
- <faultstring xsi:type="xsd:string">Operation '' is not defined in the WSDL for this service
- </faultstring>
- <detail xsi:type="xsd:string"></detail>
- </SOAP-ENV:Fault>
- <?php
- require_once('lib/nusoap.php');
- $data = json_decode(file_get_contents("php://input"), true);
- $file_name = $data['file_name'];
- $location = $data['location'];
- $client = new nusoap_client('http://servername:port/WebService/server.php?wsdl', true);
- if ($SERVER['REQUEST_METHOD'] == 'POST') {
- $err = $client->getError();
- if ($err) {
- echo "<h2> Constructor error </h2><pre>" . $err. "</pre>" ;
- echo "<h2> Debug </h2><pre>" . htmlspecialchars($client->getdebug(), ENT_QUOTES) . "</pre>" ;
- exit();
- }
- $datas = array (
- 'file_name' => $file_name,
- 'location' => $location
- );
- $result = $client->call('InsertData', $datas);
- if ($client->fault) {
- echo "<h2> Fault (Expect - The request contains an invalid SOAP Body)</h2> <pre>" ;
- print_r ($result);
- echo "</pre>";
- } else {
- $err = $client->getError ();
- if ($err) {
- echo "<h2> Error </h2><pre>" . $err. "</pre>";
- } else {
- print_r ($result);
- }
- }
- } else if ($_SERVER['REQUEST_METHOD'] != 'POST') {
- echo "Method is not POST " ;
- }
- ?>
- <?php
- require_once('lib.nusoap');
- $server = new soap_server();
- $server->configureWSDL('Database Sample Insertion', 'urn:Insert');
- $server->soap_defenconding = 'UTF-8' ;
- $server->register('InsertData',
- array (
- 'file_name' => 'xsd:file_name',
- 'location' => 'xsd:location'
- ),
- array ('return' => 'xsd:string'),
- 'urn:Insert',
- 'urn:Insertwsdl#InsertDate',
- 'rpc',
- 'literal'
- );
- function InsertData ($file_name, $location) {
- $db_host = 'localhost';
- $db_username = 'username';
- $db_password = '' ;
- $db_name = 'sample' ;
- $conn = new mysqli ($db_host, $db_username, $db_password, $db_name);
- if ($conn->connect_error) {
- trigger_error('Database connection failed : ' .$conn->connect_error , E_USER_ERROR);
- }
- $sql = "INSERT INTO transaction (`filename`, `location`) VALUES ('$file_name', '$location')";
- $query = $conn->query($sql);
- }
- $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '' ;
- $server->service($HTTP_RAW_POST_DATA);
- ?>
- if (function_exists('getallheaders')){ ...
- if (0 && function_exists('getallheaders')){ ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement