1

我现在必须通过 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();
  }
4

2 回答 2

1

您可以集成 OD 中给出的 REST API 默认选项,或者您可以编写自定义 Java 代码或在 OD 中创建应用程序调用的 jar

试试下面在 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();

     }

}
于 2019-06-05T12:04:00.407 回答
0

如果您谈论的是体验门户,那么您有两个选择。您可以使用 Orchestration Designer 的内置 REST 客户端(文件/新建/Web 服务操作文件 (REST)),也可以在单独的项目中实现它并将其余客户端附加到您的 OD 项目。

于 2015-09-25T11:06:15.547 回答