나는 봄과 웹 서비스를 사용하여 json 데이터를 통해 전화 번호로 전화를 제출하고 전화를 걸고 있으며 다음과 같은 URL을 얻고 싶습니다.
https://myservice.com/oapi/v1/call/click-to-call/phoneNumber
phoneNumber는 임의의 번호이며 사용자 가이 전화 번호를 클릭하면 json에서 자동 전화
이것은 내 JSP입니다.
<form action="https://myservice.com/oapi/v1/call/click-to-call/${orderDetail.phoneNumber}" method="POST">
<input type="submit" name="phoneNumber" value="${orderDetail.phoneNumber}" />
</form>
이것은 내 수업입니다 : ( UPDATED )
@RequestMapping(value="https://myservice.com/oapi/v1/call/click-to-call/{phoneNumber}", method = RequestMethod.POST)
public String clickToCall(HttpServletRequest request, @PathVariable("phoneNumber") String phoneNumber) {
logger.debug("Phone number is calling: " + phoneNumber);
phoneNumber = request.getParameter(phoneNumber);
// String url = "https://myservice.com/oapi/v1/call/click-to-call/0902032618";
try {
URL obj = new URL("https://myservice.com/oapi/v1/call/click-to-call/" + phoneNumber);
HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
String encoded = Base64.getEncoder().encodeToString((AppConstants.SIPUSERNAME+":"+AppConstants.SIPPASSWORD).getBytes(StandardCharsets.UTF_8)); //Java 8
// con.setRequestProperty("Authorization", "Basic "+encoded);
System.out.println("Original String is " + encoded);
//add reuqest header
con.setRequestMethod("POST");
con.setRequestProperty("Content-Type", "application/json"); // httpUrlConn
con.setRequestProperty("Accept", "application/json");
con.setRequestProperty("Accept-Language", "UTF-8");
con.setRequestProperty("x-auth-app-id", "61666411659356156");
con.setRequestProperty("x-auth-app-hash", "a44f4ea21475fa6761392ba4bc659994330bee771c413b2c207490a79f9ec78c2a6");
String urlParameters = "{\"sipUser\":\"vchi_cc\",\"sipPassword\" : \"m9Bp7s+CtQj85HygnIFjPn7O4Vithrun\"}";
// Send post request
con.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
wr.writeBytes(urlParameters);
wr.flush();
wr.close();
int responseCode = con.getResponseCode();
System.out.println("Response Code : " + responseCode);
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
//print result
System.out.println(response.toString());
}
catch (ConnectException ce) {
ce.printStackTrace();
System.out.println("Our server connection timed out");
}
catch (Exception e) {
e.printStackTrace();
System.out.println("https request error:{}");
}
return "orderDetailPop";
}
전화 번호를 클릭하면 다음과 같은 예외 및 오류가 발생합니다.
{"success":false,"message":"APPID_MISSING"}
제출할 때 내 수업이 아직 양식에서 호출되지 않은 것 같습니다. 문제를 해결하는 방법은 무엇입니까?