在一个包中我有两节课。我的GetParameterValue.java返回一个session_id。我需要在IVRTest.java中打印session_id
我的GetParameterValue.java
package com.raos.ivr;
import org.json.JSONException;
import org.json.JSONObject;
public class GetParameterValue
{
public static String conferenceurlmoderator(String responseString) throws JSONException
{
String url_moderator = responseString;
String response_string_moderatorvalue = JSONConverter.passbymoderatorvalue(url_moderator);
JSONObject jsonObj = new JSONObject(response_string_moderatorvalue);
JSONObject message_m = (JSONObject) jsonObj.get("response");
long message1 = (long) message_m.get("message");
String session_id_moderator = String.valueOf(message1);
System.out.println("session_id_moderator = " + session_id_moderator);
return session_id_moderator;
}
public static String conferenceurlparticipant(String responseString1) throws JSONException
{
String url_participant = responseString1;
String response_string_participantvalue = JSONConverter.passbyparticipantvalue(url_participant);
JSONObject jsonObj = new JSONObject(response_string_participantvalue);
JSONObject message_p = (JSONObject) jsonObj.get("response");
long message2 = (long) message_p.get("message");
String session_id_participant = String.valueOf(message2);
System.out.println("session_id_participant = " + session_id_participant);
return session_id_participant;
}
}
我的 IVRTest.java
package com.raos.ivr;
import java.util.ArrayList;
import java.util.List;
import org.json.JSONException;
import com.gpzhibernate.DBCommonOpertion;
import com.raos.ConferenceAPICall;
import com.raos.ivr.GetParameterValue;
import com.raos.KookooAPICall;
import com.raos.KookooAPISms;
import com.raos.tables.UserTable;
import com.raos.utils.DBConnect;
public class IVRTest
{
public static void main(String[] args) throws JSONException
{
String responseString = null;
String[] Moderator_name_array = {"kalai"};
String[] Participant_name_array = {"sundaresan"};
String caller_id = "918030";
String message_text = "Hi";
String conference_id = "11223";
String request = "conferencecall";
DBConnect dbConnect = new DBConnect();
boolean connectionStatus = dbConnect.establishConnection();
System.out.println("Connection Status:" + connectionStatus);
if (connectionStatus == true)
{
System.out.println("Connected");
ArrayList<String> Moderator_number = getUserTableList(Moderator_name_array);
System.out.println("Function call result:" + Moderator_number);
ArrayList<String> Participant_number = getUserTableList(Participant_name_array);
System.out.println("Function call result:" + Participant_number);
if (request == "conferencecall")
{
System.out.println("conferencecall");
String call_output = ConferenceAPICall.ConferenceAPICallconnect(Moderator_number,Participant_number, caller_id, conference_id);
GetParameterValue value = new GetParameterValue();
String session_id_moderatorvalue = GetParameterValue.conferenceurlmoderator(responseString);
System.out.println(session_id_moderatorvalue);
String send_values = InsertValues.Conferencevalues(Moderator_number, conference_id, Participant_number, caller_id);
}
}
}
}
`
我的输出为
`
Exception in thread "main" java.lang.NullPointerException
at java.io.StringReader.<init>(Unknown Source)
at org.json.JSONTokener.<init>(JSONTokener.java:83)
at org.json.XMLTokener.<init>(XMLTokener.java:55)
at org.json.XML.toJSONObject(XML.java:367)
at com.raos.ivr.JSONConverter.passbymoderatorvalue(JSONConverter.java:17)
at com.raos.ivr.GetParameterValue.conferenceurlmoderator(GetParameterValue.java:13)
at com.raos.ivr.IVRTest.main(IVRTest.java:61)`
请帮我告诉如何传递返回值
答案 0 :(得分:0)
我的建议是在IVRTest中将sessionId变量声明为静态类型