我现在必须通过java rest web-service将Avaya IVRS与Service集成。如果用户通过Avaya IVRS进行呼叫,他应该可以通过电话键盘选择菜单并执行以下功能: - 1.添加票证2.更新票证3.关闭票证 我已经编写了代码来创建和更新票证,但我现在还不知道如何与服务集成。
/////////////////////////////////////////////////
// POST OPERATION -- Create a new Incident ticket
/////////////////////////////////////////////////
String endpointPOST = baseURI + "/in";
PostMethod post = new PostMethod(endpointPOST);
post.addRequestHeader("X-AccessKey", accessKey);
post.addRequestHeader("Accept" , "application/xml");
post.addRequestHeader("Content-Type", "application/xml; charset=UTF-8");
post.setRequestBody("<in>" + "<customer COMMON_NAME=\"System_SD_User\"/>" +
"<description>Created from REST API Java Samples code</description>" + "</in>");
try {
System.out.println("Execute POST request for " + endpointPOST);
// Execute POST request
int result = client.executeMethod(post);
System.out.println("Response status code: " + result);
System.out.println("Response body: ");
System.out.println(post.getResponseBodyAsString());
System.out.println();
} catch (HttpException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
post.releaseConnection();
}
//////////////////////////////////////////////////////
// PUT OPERATION -- Update an existing Incident ticket
//////////////////////////////////////////////////////
String endpointPUT = baseURI + "/in/400001";
PutMethod put = new PutMethod(endpointPUT);
put.addRequestHeader("X-AccessKey", accessKey);
put.addRequestHeader("Accept" , "application/xml");
put.addRequestHeader("Content-Type", "application/xml; charset=UTF-8");
put.setRequestBody(
"<in>" + "<summary>Updated from REST API Java Samples code</summary>" + "</in>");
try {
System.out.println("Execute PUT request for " + endpointPUT);
// Execute PUT request
int result = client.executeMethod(put);
System.out.println("Response status code: " + result);
System.out.println("Response body: ");
System.out.println(put.getResponseBodyAsString());
System.out.println();
} catch (HttpException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
put.releaseConnection();
}
答案 0 :(得分:0)
如果您正在谈论体验门户,那么您有两个选择。您可以使用Orchestration Designer的内置REST客户端(文件/新建/ Web服务操作文件(REST)),也可以在单独的项目中实现它,并将其余客户端连接到OD项目。
答案 1 :(得分:0)
您可以集成OD中提供的REST API默认选项,也可以编写自定义Java代码或创建应用程序罐中的OD
尝试以下在Avaya实验室中测试过的代码
String webServiceURl =“ https:// XXXXXXXXXX / services / OceanaDataoceana / data / context / schema”;
try{
URL url = new URL(webServiceURl);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/json");
String input ="{""}";//pass paramenter for request
OutputStream os = conn.getOutputStream();
os.write(input.getBytes());
os.flush();
System.out.println("conn.getResponseCode() ::::"+conn.getResponseCode());
if (conn.getResponseCode() != 200) {
throw new RuntimeException("Failed : HTTP error code : "+ conn.getResponseCode());
}
BufferedReader br = new BufferedReader(new InputStreamReader(
(conn.getInputStream())));
String output;
System.out.println("Output from Server .... \n");
while ((output = br.readLine()) != null) {
JSONObject object;
try {
object = new JSONObject(output);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("json response::: "+output);
conn.disconnect();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}