我的WSDL文件: -如何从php soap web服务的json响应中去除反斜线?
<?php
/**
@Description: Book Information Server Side Web Service:
This Sctript creates a web service using NuSOAP php library.
fetchBookData function accepts ISBN and sends back book information.
@Author: http://programmerblog.net/
@Website: http://programmerblog.net/
*/
require_once('dbconn.php');
require_once('lib/nusoap.php');
$server = new nusoap_server();
/* Fetch 1 book data */
function presentStatusPull($rnbcode){
global $dbconn;
$sql = "SELECT * FROM rnb_gpl_data where did = :rnbcode";
// prepare sql and bind parameters
$stmt = $dbconn->prepare($sql);
$stmt->bindParam(":rnbcode", $rnbcode);
// insert a row
$stmt->execute();
$data = $stmt->fetch(PDO::FETCH_ASSOC);
return json_encode($data);
$dbconn = null;
}
$server->configureWSDL('index', 'urn:index');
$server->register('presentStatusPull',
array('rnbcode' => 'xsd:string'),
array('data' => 'xsd:string'),
'urn:index',
'urn:index#presentStatusPull'
);
$server->service(file_get_contents("php://input"));
?>
然后呼叫我的PHP文件中的WSDL服务器: - URL的
<?php
require_once('lib/nusoap.php');
$result = array();
$wsdl = "http://meter.digireach.com/RnBCode/index.php?wsdl";
$rnbcode = $_GET['rnbcode'];
//create client object
$client = new nusoap_client($wsdl, true);
$result = $client->call('presentStatusPull', array($rnbcode));
// $result = json_decode($result);
// echo json_encode($result);
echo json_encode($result, JSON_NUMERIC_CHECK);
?>
和响应: - http://meter.digireach.com/RnBCode/presentstatus.php?rnbcode=DR00098EM
和输出是这样的: - “{\”srno \“:\”1 \“,\”tr_date \“:\”2017-08-22 11:53:33 \“,\”did \“:\”DR00098EM \“ ,\ “P1 \”:\ “455 \” \ “P2 \”:\ “0 \”,\ “P3 \”:\ “0 \”,\ “P4 \”:\ “48 \”,\ “p 5 \ “:\” 0 \ “\ ”P6 \“:\ ”0 \“,\ ”P7 \“:\ ”60 \“,\ ”P8 \“:\ ”40 \“,\” P9 \ “:\” 0 \”,\ “P10 \”:\ “0 \”,\ “P11 \”:\ “5 \”,\ “P12 \”:\ “0 \”,\ “P13 \”: \ “0 \”,\ “P14 \”:\ “1103 \”,\ “P15 \”:\ “36170 \”,\ “P16 \”:\ “511046 \” \ “P17 \”:\” 0 \ “\ ”P18 \“:\ ”1 \“ \ ”P19 \“:\ ”1 \“ \ ”P20 \“:\ ”1 \“ \ ”TNO \“:\” 理想\ “,\”ser_date \“:\”2017-08-22 11:54:12 \“}”
所以,我想从这个JSON响应中删除反斜杠()。
谢谢...... –