'SOAP Webservice - error on line 2 at column 1: Extra content at the end of the document
I'm trying to create a user-defined SOAP Webservice using nusoap with the following codes:
service.php
<?php
require 'nusoap/lib/nusoap.php';
require 'fetchdata.php';
$server = new nusoap_server();
$server->configureWSDL("Book Info Service","urn:soaptest");
$server->register(
"get_info",
array("input"=>"xsd:string"),
array("return"=>"xsd:string")
);
$server->service(file_get_contents("php://input"));
?>
fetchdata.php
<?php
function get_info($input)
{
$books = [
"9780435910105"=>["Opening Spaces: An Anthology of Contemporary African Women's Writing","Yvonne Vera","Heinemann"],
"9780394721170"=>["African Folktales","Roger D. Abrahams","Knopf Doubleday Publishing Group"],
"9781558615007"=>["Women Writing Africa: West Africa and the Sahel","Esi Sutherland-Addy","Feminist Press at CUNY"]
];
foreach($books as $isbn=>$info)
{
if($isbn==$input)
{
return "<b>Title:</b> ".$info[0]."<br /><br /><b>Author:</b> ".$info[1]."<br /><br /><b>Publisher:</b> ".$info[2];
break;
}
}
return "No information found for"." ".$input;
}
?>
When I run it locally, the WSDL page throws an error and the rest of the page is blank
This page contains the following errors:
error on line 2 at column 1: Extra content at the end of the document
Below is a rendering of the page up to the first error.
Why is this happening? I want to integrate this into an app so I need the WSDL link.
I honestly just copied and modified this so I don't really know what is happening. Can anyone help? Thank you.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|