我正在使用soap创建简单的Web服务。在尝试运行soap客户端时,请继续获取此错误“仅在文档开头允许的XML声明”。这是我的代码
服务器:
<?php
class Member extends CI_Controller
{
function Member()
{
parent::__construct();
$ns = 'http://192.168.19.25/xampp/CodeIgniter/index.php/member';
// load nusoap toolkit library in controller
$this->load->library("nusoap_library");
// create soap server object
$this->nusoap_server = new soap_server();
// wsdl cinfiguration
$this->nusoap_server->configureWSDL("SOAP Server Using NuSOAP in CodeIgniter", $ns);
// server namespace
$this->nusoap_server->wsdl->schemaTargetNamespace = $ns;
// "addnumbers" method parameters
$input_array = array ('a' => "xsd:string", 'b' => "xsd:string");
$return_array = array ("return" => "xsd:string");
$this->nusoap_server->register(
'addnumbers',
$input_array,
$return_array,
"urn:SOAPServerWSDL",
"urn:".$ns."/addnumbers",
"rpc",
"encoded",
"Addition Of Two Numbers"
);
}
function index()
{
function addnumbers($a,$b)
{
$c = $a + $b;
return $c;
}
$this->nusoap_server->service(file_get_contents("php://input"));
// read raw data from request body
}
}
?>