2010-05-11 2 views
4

나는 스프링 WS 버전 1.5.8을 사용하고있다.응답에 xsd 네임 스페이스를 추가하도록 스프링 웹 서비스를 강요한다.

<?xml version="1.0" encoding="UTF-8"?> 
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
        xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">   
    <soapenv:Body> 
     ... 
    </soapenv:Body> 
</soapenv:Envelope> 

을 내가 할 수있는 방법 :

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> 
    <SOAP-ENV:Header/> 
    <SOAP-ENV:Body> 
     ... 
    </SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 

하지만, (나는 통합) 제 의뢰인은 내가 성공을 구문 분석 위해서는 더 네임 스페이스 declerations합니다을 추가 할 것을 요구한다 : 나의 응답은 다음과 같습니다 그것?

답변

4

문서에서 네임 스페이스가 사용되지 않을 때 특정 네임 스페이스 선언이 있어야하는 SOAP 클라이언트가 손상되었다고 말할 필요는 없을 것입니다. 그래서 저는 언급하지 않을 것입니다.

그러나 응답을 변경하려면 EndpointInterceptor, 구체적으로 SoapEndpointInterceptor을 사용할 수 있습니다. 끝점 요격기 as described here까지 연결할 수 있습니다.

당신이 그에게 무엇을해야 SoapMessagemessageContext.getResponse()을 캐스팅하고 추가하는 handleResponse 방법을 구현할 수 있습니다 귀하의 사용자 정의 인터셉터 :

public class MyInterceptor implements SoapEndpointInterceptor { 

    public boolean handleResponse(MessageContext messageContext, Object endpoint) throws Exception { 
     SoapMessage message = (SoapMessage) messageContext.getResponse(); 
     message.getEnvelope().addNamespaceDeclaration(....); 
     return true; 
    } 

    // ... other methods here 
} 

하지만, 부작용이 있으므로 신중 수 있습니다 낮은 수준의 네임 스페이스 선언을 추가 .

+0

빠른 응답을 위해 skaffman에게 감사드립니다. –

관련 문제