Hi,
I am a newbie to SOAP and PHP . I downloaded the NuSOAP Toolkit and copied a simple program from the internet and tried to get it to work but I am getting an error.
I will be highly thankful if somebody could please help !
When I go to
http://192.168.1.155/srividya/ws/taxCalcClient.php?rate=9&sub=856
I get the error :
Tax calculated:
FAULT:
Code: Server
String:
When I go to
http://192.168.1.155/srividya/ws/taxCalc.php?rate=9&sub=856
I get the error
<?xml version="1.0" ?>
- <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/" xmlns:si="http://soapinterop.org/xsd">
- <SOAP-ENV:Body>
- <SOAP-ENV:Fault>
<faultcode>Server</faultcode>
<faultactor>method '' not defined in service ''</faultactor>
<faultstring />
<faultdetail />
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
The source files are
Server Side :
<?php
/**
taxCalc.php
An example PHP script which uses NuSOAP to provide a
tax calculator function.
Created on August 7, 2002, 6:11 PM
@author Sean Campbell
@version 1.0
/
/ Include the NuSOAP library. /
require_once('nusoap.php');
/ Create a new SOAP server instance. /
$server = new soap_server;
$server->register('taxCalc');
/**
Calculates the total (including tax) for a purchase based on the
rate and subtotal provided.
@ string $rate The tax rate in percent.
@ string $sub The subtotal for the purchase.
@return float $total The total for the purchase.
@author Sean Campbell
@version 1.0
/
function taxCalc ($rate, $sub)
{
if ($rate == '' || $rate <= 0) {
/ Return a SOAP fault indicating a negative or
zero tax rate was transmitted. /
return new soap_fault(
'Client', '',
'Must supply a positive, non-zero tax rate.',''
);
}
if ($sub == '' || $sub <= 0) {
/* Return a SOAP fault indicating a negative or
* zero subtotal was transmitted. */
return new soap_fault(
'Client', '',
'Must supply a positive, non-zero subtotal.', ''
);
}
/* Return the generated total for the purchase. */
return (($rate / 100) * $sub) + $sub;
}
/ Register the taxCalc function for publication. /
/ Begin the HTTP listener service and exit. /
$server->service('HTTP_RAW_POST_DATA');
exit();
?>
Client Side
<html>
<head>
<title>Tax calculator Client</title>
</head>
<body>
<h1>Tax calculated:</h1>
<?php
/**
taxCalcClient.php
An example PHP script which uses NuSOAP to access
a tax calculator function.
Created on August 7, 2002, 6:11 PM
@author Sean Campbell
@version 1.0
/
/ Include the NuSOAP library. /
require_once('nusoap.php');
/ Initialize the client's parameter list. /
$param = array('rate' => $GET['rate'],
'sub' => $GET['sub']
);
/ Create a new client by providing the endpoint to the
constructor. */
$client = new soapclient(
'http://192.168.1.155/srividya/ws/taxCalc.php'
);
/ Call the taxCalc() function, passing the parameter list. /
$options = array('trace'=>'true','timeout'=>5);
$response = $client->call('taxCalc', $param,$options);
/ handle any SOAP faults. /
if ($client->fault) {
echo "FAULT: <p>Code: {$client->faultcode}<br />";
echo "String: {$client->faultstring}";
} else {
echo "$" . $response;
}
?>
</body>
</html>