Hi,
I have developed a small web service that takes two arguments and then it performs an XSLT transformation over XML and should return the result to a client which will just display it for the mean while. Although the two arguments are passed successfully to the service but the service returns nil instead of the intended response. I can't see what is the problem!
I know that the XSLT and XML files work properly since I have tested them so many times, and I'm pretty sure the client is fine as well, there is something in the service's code that I don't know why it isn't working as it should!
Here is first my client:
<?php
require_once('nusoap.php')
;
$wsdl="
http:/myserver/AFS/AFS3.php?wsdl";
$client=new soapclient($wsdl, 'wsdl');
$Level="Advanced";
$LP="AL.xml";
$param=array("Level"=>$Lev
el,"LP"=>$
LP);
$result=$client->call('Get
_Chunks_na
mes', $param);
echo $result;
//for debugging
//Display the request and response
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>Error Message</h2>';
echo '<pre>' . htmlspecialchars($client->
debug_str,
ENT_QUOTES) . '</pre>';
?>
Here is my service:
<?php
/**
* Gets the level and LP location (via Aggregator Service AGS.php)
* Reads the specific LP to extract the chunks (AL.xml or Java.xml)
* Sends the Chunks names back to the AGS
*
*
*/
//Including NuSOAP library
require_once("nusoap.php")
;
//Defining the namespace for this service (a Distinct URI)
$ns="my server/AFS/AFS_nusoap";
//Instantiating the SOAP server and defining the settings for our WSDL file
$server = new soap_server();
$server->configureWSDL('Ad
aptionFilt
erService'
,$ns);
$server->wsdl->schemaTarge
tNamespace
=$ns;
/** Registering our PHP functions, making the server "aware" of the existence of
* those method and the values that will pass to and from the method.
* Different methods are registered independently
*/
$server->register('Get_Chu
nks_names'
,
array('Level' =>'xsd:string',"LP"=>'xsd:
string'), array('return' => 'xsd:string'),$ns);
function Get_Chunks_names($Level,$L
P)
{
$XSLFile = 'AFS6.xsl';
$XMLFile = $LP;
$xsl_params=array('Level'=
>$level);
function XSL_transformation($XMLFil
e,$XSLFile
,$ResultFi
le,$xsl_pa
rams)
{
$Str = '';
$xp = xslt_create() or trigger_error('Could not create XSLT process.',E_USER_ERROR);
xslt_set_encoding($xp, 'ISO-8859-1');
// read the files into memory
$xsl_string = join('', file($XSLFile));
$xml_string = join('', file($XMLFile));
// set the argument buffer
$arg_buffer = array('/xml' => $xml_string, '/xsl' => $xsl_string);
// process the two files to get the desired output
$Str = xslt_process($xp, 'arg:/xml', 'arg:/xsl', NULL,$arg_buffer, $xsl_params);
Saves transformation result into '$ResultFile'
$fp = fopen($ResultFile,"w+");
fwrite($fp,$Str);
fclose($fp);
//Free XSLT processor
xslt_free($xh);
return new soapval('return','xsd:stri
ng',$Resul
tFile);
}//end function2
} //end of function1
//Invoking the Service
$server->service($HTTP_RAW
_POST_DATA
);
?>
Below is the request and response from soap client:
Request
POST /AFS/AFS3.php HTTP/1.0
Host: bubba.cs.nott.ac.uk
User-Agent: NuSOAP/0.7.2 (1.94)
Content-Type: text/xml; charset=ISO-8859-1
SOAPAction: "
http://bubba.cs.nott.ac.uk/AFS/AFS3.php/Get_Chunks_names"
Content-Length: 663
<?xml version="1.0" encoding="ISO-8859-1"?><SO
AP-ENV:Env
elope 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:tns="
http://bubba.cs.nott.ac.uk/AFS/AFS_nusoap"><S
OAP-ENV:Bo
dy><tns:Ge
t_Chunks_n
ames xmlns:tns="
http://bubba.cs.nott.ac.uk/AFS/AFS_nusoap"><L
evel xsi:type="xsd:string">Adva
nced</Leve
l><LP xsi:type="xsd:string">
http://bubba.cs.nott.ac.uk/LPS/AL.xml</LP></
tns:Get_Ch
unks_names
></SOAP-EN
V:Body></S
OAP-ENV:En
velope>
Response
HTTP/1.1 200 OK
Date: Thu, 08 Nov 2007 15:36:20 GMT
Server: Apache/2.0.52 (CentOS)
X-Powered-By: PHP/4.4.7
X-SOAP-Server: NuSOAP/0.7.2 (1.94)
Content-Length: 558
Connection: close
Content-Type: text/xml; charset=ISO-8859-1
<?xml version="1.0" encoding="ISO-8859-1"?><SO
AP-ENV:Env
elope 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-E
NV:Body><n
s1:Get_Chu
nks_namesR
esponse xmlns:ns1="
http://bubba.cs.nott.ac.uk/AFS/AFS_nusoap"><r
eturn xsi:nil="true" xsi:type="xsd:string"/></n
s1:Get_Chu
nks_namesR
esponse></
SOAP-ENV:B
ody></SOAP
-ENV:Envel
ope>
Thanks
Start Free Trial