복붙노트

[SPRING] soap spring ws - <faultcode>를 사용자 정의하는 방법 soapenv : 서버 </ faultcode>에서 <faultcode> 일부 오류 code.eg (숫자) </ faultcode>

SPRING

soap spring ws - 를 사용자 정의하는 방법 soapenv : 서버 에서 일부 오류 code.eg (숫자)

나는 soap webservice를 만들기 위해 비누 스프링을 사용하고 있는데 성공적으로 지금이 비누 서비스에서 잘못 구현하고 있었고 내가 다음과 같이 만든 수업으로 할 수있다.

public class ServiceSoapFaultMappingExceptionResolver extends SoapFaultMappingExceptionResolver

다음 오버라이드 된 함수 내에서,

@Override
 protected void customizeFault(Object endpoint, Exception ex, SoapFault fault) {
//code for adding fault details

    Result result = fault.addFaultDetail().getResult();

            // marshal
            try {
                 JAXBContext.newInstance(ExceptionListType.class).createMarshaller().marshal(exceptionList, result);

}

사용자 정의 비누 폴트 오브젝트를 작성하여 리턴했습니다. 이 반환 된 사용자 정의 비누 폴트가 세부 태그 안에 있습니다. 그래서 내 잘못은 이렇게 보입니다.

<soapenv:Fault>
         <faultcode>soapenv:Server</faultcode>
         <faultstring>INVALID NUMBER</faultstring>
         <detail>
            <ns5:exceptionListType xmlns:ns5="http://wellpoint.com/esb/header/v2">
               <ns5:errorCount>1</ns5:errorCount>
               <ns5:Exception>
                  <ns5:UUID> 889c-6f73671534af</ns5:UUID>
                  <ns5:timestamp>09/04/2015 05:47:40</ns5:timestamp>
                  <ns5:node>mynode</ns5:node>
                  <ns5:process>JAVA</ns5:process>
                  <ns5:component>Unknown Component</ns5:component>
                  <ns5:code>5009</ns5:code>
                  <ns5:severity>FATAL</ns5:severity>
                  <ns5:message>An unexpected server error occurred: INVALID   NUMBER</ns5:message>
               </ns5:Exception>
            </ns5:exceptionListType>
         </detail>
      </soapenv:Fault>

지금 내가 뭘하고 싶은 오류 코드가 위의 오류와 관련된 그것은 코드 tag.But 안에 오는이 오류 코드 가이 태그 안에 올 필요가있다

<faultcode>soapenv:Server</faultcode>

처럼

<faultcode>5009</faultcode>

나는 많은 인터넷 검색과 운이 없었습니다. 미리 정의 된 값 집합 이외의 값을 사용하는 것이 좋지 않다는 것을 알고 있습니다. 그러나 고객의 요구는 이것입니다. 아무도 대답을 모른다면 저를 도우십시오. 많은 감사드립니다.

해결법

  1. ==============================

    1.마지막으로 문제를 해결할 수있는 방법을 찾았습니다. customizeFault 메서드 내에서 아래 코드를 넣습니다.

    마지막으로 문제를 해결할 수있는 방법을 찾았습니다. customizeFault 메서드 내에서 아래 코드를 넣습니다.

        SoapFaultDefinition soapFaultDefinition = new SoapFaultDefinition();
        String ENVELOPE_NAMESPACE_URI = "http://schemas.xmlsoap.org/soap/envelope/";
        QName FAULT_NAME = new QName(ENVELOPE_NAMESPACE_URI, "5999, "e");
        //      soapFaultDefinition.setFaultStringOrReason("--" + ex);
        //      soapFaultDefinition.setLocale(Locale.ENGLISH);
        soapFaultDefinition.setFaultCode(FAULT_NAME);
        super.setDefaultFault(soapFaultDefinition);
    
  2. from https://stackoverflow.com/questions/32395104/soap-spring-ws-how-to-customise-faultcodesoapenvserver-faultcode-to-fault by cc-by-sa and MIT license