Php 如何保存json的所有响应,并在我的soap api中使用nusoap在我的api响应中显示
大家好,我对编写和制作soap api以及它的运行都是新手,但我想在使用nusoap的soap api响应中展示整个json响应 我想显示一个完整的响应,如{“user”:“Exists”,“user_id”:2440} 但在我的api中,它只显示一个 这是我的soapapi代码Php 如何保存json的所有响应,并在我的soap api中使用nusoap在我的api响应中显示,php,json,api,soap,Php,Json,Api,Soap,大家好,我对编写和制作soap api以及它的运行都是新手,但我想在使用nusoap的soap api响应中展示整个json响应 我想显示一个完整的响应,如{“user”:“Exists”,“user_id”:2440} 但在我的api中,它只显示一个 这是我的soapapi代码 require 'nusoap/lib/nusoap.php'; header('Content-Type: text/xml'); $server = new soap_server(); $params = arr
require 'nusoap/lib/nusoap.php';
header('Content-Type: text/xml');
$server = new soap_server();
$params = array("identity"=> array("name" => "identity", "type" =>"xsd:string"));
$response = array("response"=> array("name" => "user", "type" => "xsd:string"),array("name" => "user_id", "type" => "xsd:string")),array("message"=> array("name" => "user", "type" =>"xsd:string"),);
$server->configureWSDL("authcode","http://23.97.56.249/WSDLWrapper/authcode.php?wsdl");
$server->wsdl->addComplexType('credentials', 'complexType', 'struct', 'all', '', $params);
$server->wsdl->addComplexType('response', 'complexType', 'struct', 'all', '', $response);
$server->register("authcode",array('userCredentials' => 'tns:credentials'), array("userResponse"=>"tns:response"),"http://23.97.56.249/WSDLWrapper/authcode.php","http://23.97.56.249/WSDLWrapper/authcode.php","rpc","encoded","authcode");
$server->service(isset($HTTP_RAW_POST_DATA) ?
$HTTP_RAW_POST_DATA : '');
function authcode($credentials) {
// Get cURL resource
$curl = curl_init();
// Set some options - we are passing in a useragent too here
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => 'https://api.forimazdoori.com/auth/request',
CURLOPT_USERAGENT => 'WSDL Wrapper Internal Call',
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => $credentials
));
// Send the request & save response to $resp
$resp = curl_exec($curl);
if ($resp === false) {
//$response['response'] = $result['message'];
$resp = curl_error($curl);
//$response['Code'] = "1111";
$response['response'] = "error";
} else {
$result = json_decode($resp, true);
$response['response'] = $result['message'];
if(array_key_exists('user', $result)) {
// $response['Code'] = '0000';
$response['response'] = $result['user_id'];
} else {
//$response['Code'] = '1111';
$response['response'] = $result['message'];
}
}
// Close request to clear up some resources
curl_close($curl);
//$response['response'] = $result['message'];
return $result;
}
基本上是用soap编写的Web服务,我希望json完整响应应该在我的soap api中生成响应基本上是用soap编写的Web服务,我希望json完整响应应该在我的soap api中生成响应