현재 EJB3 기반 SOAP 웹 서비스를 개발 중이며, 검색되지 않은 예외를 처리하고 클라이언트에 형식화 된 SOAP 응답을 반환하는 모범 사례가 무엇인지 궁금합니다.ejb 3 기반 비누 웹 서비스에서 예외를 처리하는 방법
예 :
@WebMethod
public SomeResponse processSomeService(
@WebParam(name = "someParameters") SomeParameters someParameters)
{
// the EJB do something with the parameters
// and retrieve a response fot the client
SomeResponse theResponse = this.doSomething(someParameters);
return theResponse;
}
내가 좋아하는 일반적인 예외를 잡을 수 있습니까 :
@WebMethod
public SomeResponse processSomeService(
@WebParam(name = "someParameters") SomeParameters someParameters)
{
// the EJB do something with the parameters
// and retrieve a response to return to the client
try
{
SomeResponse theResponse = this.doSomething(someParameters);
}
catch (Exception ex)
{
// log the exception
logger.log(Level.SEVERE, "something is going wrong {0}", ex.getMessage());
// get a generic error response not to let the
// technical reason going to the client
SomeResponse theResponse = SomeResponse.createError();
}
return theResponse;
}
이것을 달성하기 위해 "모범 사례"어떤 종류가 있습니까? 당신이
아이디어는 일반적인 오류를 반환하는 것입니다 "서버 과부하"와 같은 메시지가 아니라 실제 오류가 클라이언트를 통과하게합니다. 귀하의 응답에 대한 감사합니다 –
@ Alexandre : 오류 코드를 클라이언트에 반환하여 실제 오류의 의미를 숨길 수 있습니다. 이것은 나중에 문제를 해결하는 데 도움이 될 수 있습니다. – Qwerky
마침내 일반 예외를 catch하고 예외 유형에 따라 오류 코드를 추가합니다. 제안 해줘서 고마워. –