修改NUSOAP中的响应消息
您好,我正在使用网络服务,我的代码
<?php
// Pull in the NuSOAP code
require_once('nusoap/nusoap.php');
require_once('common.php');
header('Content-Type: text/xml; charset=utf8');
// Create the server instance
$server = new nusoap_server();
$server->xml_encoding = "utf-8";
$server->soap_defencoding = "utf-8";
//$server->decode_utf8 = false;
// Initialize WSDL support
$server->configureWSDL('hellowsdl2', 'urn:hellowsdl2');
$host="localhost";
$user="root";
$password="root";
/*$host="localhost";
$user="phpteam";
$password="phpteam";
*/
$dbname="fanticker";
$con = mysql_connect($host,$user,$password);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db($dbname);
// Register the method to expose
/*insert user function*/
$server->register(
'insertUser',
array('password'=>'xsd:string','email'=>'xsd:string','status'=>'xsd:string','nickname'=>'xsd:string','deviceserial'=>'xsd:string','devicename'=>'xsd:string','devicetype'=>'xsd:string'),
array('return'=>'xsd:string'),
'urn:hellowsdl', // namespace
'urn:hellowsdl#hello', // soapaction
'rpc', // style
'encoded', // use
'Says hello world to client' // documentation
);
/**
* @param $uname
* @param $password
* @param $email
* @param $status
* @param $nick
* @param $deviceserial
* @param $devicename
* @param $devicetype
* @param $credits
* @param $last_league_id
* @param $last_match_ticker_mat_id
* @param $lastmatchid
* @param $usr_preferences
* @return string
*/
function insertUser($password,$email,$status,$nickname,$deviceserial,$devicename,$devicetype)
{
$nick_check=check_nick_exists($nickname);
$email_check=check_email_exists($email);
if($nick_check==true)
{
return "RW1-Registration Warning Nick Exists";
}
if(!isValidEmail($email))
{
return "RW3-Registration Warning Email Format";
}
if($email_check==true)
{
return "RW2-Registration Warning Email Exists";
}
if(!isValidPassword($password))
{
return "RW4-Registration Warning Password Incorrect";
}
$qry="INSERT INTO usr_user (USR_password ,USR_email ,USR_status ,USR_nick ,USR_device_serial ,USR_device_name ,USR_device_type ,USR_last_league_LGT_id ,USR_last_match_ticker_MAT_id ,USR_last_match_reporting_MAT_id ,USR_Preferences)VALUES ('".$password."','".$email."','".$status."','".$nickname."','".$deviceserial."','".$devicename."','".$devicetype."')";
$query = mysql_query($qry);
if($query==true)
{
return "User Inserted";
}
else
{
return "some field missing";
}
}
//function for check exist data
// Use the request to (try to) invoke the service
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
exit();
?>
会生成像上面那样的响应,
-<SOAP-ENV:Body>
-<ns1:insertUserResponse xmlns:ns1="urn:hellowsdl2">
-<return xsi:type="xsd:string">RW1-Registration Warning Nick Exists</return>
</ns1:insertUserResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
而不是上面的响应,我想要这种类型的响应,
-<SOAP-ENV:Body>
-<ns1:insertUserResponse xmlns:ns1="urn:hellowsdl2">
<status>
<code>RW1</code>
<message>registration warning nick exists</message>
<status>
</ns1:insertUserResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
所以怎么可能,请帮忙
提前致谢
hi i am using webservice and my code i following
<?php
// Pull in the NuSOAP code
require_once('nusoap/nusoap.php');
require_once('common.php');
header('Content-Type: text/xml; charset=utf8');
// Create the server instance
$server = new nusoap_server();
$server->xml_encoding = "utf-8";
$server->soap_defencoding = "utf-8";
//$server->decode_utf8 = false;
// Initialize WSDL support
$server->configureWSDL('hellowsdl2', 'urn:hellowsdl2');
$host="localhost";
$user="root";
$password="root";
/*$host="localhost";
$user="phpteam";
$password="phpteam";
*/
$dbname="fanticker";
$con = mysql_connect($host,$user,$password);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db($dbname);
// Register the method to expose
/*insert user function*/
$server->register(
'insertUser',
array('password'=>'xsd:string','email'=>'xsd:string','status'=>'xsd:string','nickname'=>'xsd:string','deviceserial'=>'xsd:string','devicename'=>'xsd:string','devicetype'=>'xsd:string'),
array('return'=>'xsd:string'),
'urn:hellowsdl', // namespace
'urn:hellowsdl#hello', // soapaction
'rpc', // style
'encoded', // use
'Says hello world to client' // documentation
);
/**
* @param $uname
* @param $password
* @param $email
* @param $status
* @param $nick
* @param $deviceserial
* @param $devicename
* @param $devicetype
* @param $credits
* @param $last_league_id
* @param $last_match_ticker_mat_id
* @param $lastmatchid
* @param $usr_preferences
* @return string
*/
function insertUser($password,$email,$status,$nickname,$deviceserial,$devicename,$devicetype)
{
$nick_check=check_nick_exists($nickname);
$email_check=check_email_exists($email);
if($nick_check==true)
{
return "RW1-Registration Warning Nick Exists";
}
if(!isValidEmail($email))
{
return "RW3-Registration Warning Email Format";
}
if($email_check==true)
{
return "RW2-Registration Warning Email Exists";
}
if(!isValidPassword($password))
{
return "RW4-Registration Warning Password Incorrect";
}
$qry="INSERT INTO usr_user (USR_password ,USR_email ,USR_status ,USR_nick ,USR_device_serial ,USR_device_name ,USR_device_type ,USR_last_league_LGT_id ,USR_last_match_ticker_MAT_id ,USR_last_match_reporting_MAT_id ,USR_Preferences)VALUES ('".$password."','".$email."','".$status."','".$nickname."','".$deviceserial."','".$devicename."','".$devicetype."')";
$query = mysql_query($qry);
if($query==true)
{
return "User Inserted";
}
else
{
return "some field missing";
}
}
//function for check exist data
// Use the request to (try to) invoke the service
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
exit();
?>
it generate the response like
-<SOAP-ENV:Body>
-<ns1:insertUserResponse xmlns:ns1="urn:hellowsdl2">
-<return xsi:type="xsd:string">RW1-Registration Warning Nick Exists</return>
</ns1:insertUserResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
instead of above one i wanna this type of response like
-<SOAP-ENV:Body>
-<ns1:insertUserResponse xmlns:ns1="urn:hellowsdl2">
<status>
<code>RW1</code>
<message>registration warning nick exists</message>
<status>
</ns1:insertUserResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
so how it possible plz help
thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试为您的响应设置关联数组:
Try setting up an associative array for your response: