【问题标题】:Integrate Avaya IVRS with Service now using rest web-service现在使用 REST Web 服务将 Avaya IVRS 与服务集成
【发布时间】:2015-09-24 10:05:37
【问题描述】:

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

【问题讨论】:

    标签: java rest servicenow avaya


    【解决方案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();
    
         }
    
    }
    

    【讨论】:

      【解决方案2】:

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

      【讨论】:

      • 你能告诉我如何从服务端配置Rest API吗?
      猜你喜欢
      • 2015-10-21
      • 1970-01-01
      • 2014-09-10
      • 1970-01-01
      • 2014-09-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多