2012-09-18 2 views
1

스프링 -WS 1.5를 사용하고 있습니다. spring-servlet.xml에는 다음과 같은 구성이 있습니다.엔드 포인트 핸들러 (스프링 ws)의 jaxb2 marshaller에 액세스하십시오.

<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:context="http://www.springframework.org/schema/context" 
    xmlns:sws="http://www.springframework.org/schema/web-services" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd             
    http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services-2.0.xsd              
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> 

    <context:component-scan base-package="com.test.mypackage"/> 

    <bean class="org.springframework.ws.server.endpoint.adapter.GenericMarshallingMethodEndpointAdapter"> 
     <constructor-arg ref="jaxbmarshaller"/> 
    </bean> 

    <bean id="jaxbmarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller"> 
     <property name="classesToBeBound"> 
       <list> 
         <value>com.test.myclass1</value> 
         <value>com.test.myclass2</value> 
       </list> 
     </property> 
    </bean> 

    <bean id="endpointMapping" class="org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping"> 
    <property name="interceptors"> 
      <list> 
       <bean class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor"/> 
      </list> 
    </property> 
    </bean> 

</beans> 

'GenericMarshallingMethodEndpointAdapter'은 요청이 비 정렬 구성 응답 마샬링 예상대로 작동된다. 그러나 끝점 메서드 처리기 내에서 요청을 마샬링하고 marshaller에 액세스하려고합니다. 마샬 러에게 어떻게 접근합니까? GenericMarshallingMethodEndpointAdapter에 제공된 것에 액세스 할 수 있습니까?

@Endpoint 
public class MyEndpoint { 

     private static final String NAMESPACE_URI = "http://www.test.org/9"; 

     @PayloadRoot(namespace = NAMESPACE_URI, localPart = "RequestData") 
     public JAXBElement<ResponseType> myEndpointHandler(JAXBElement<RequestType> request) { 
      /* how do I access the marshaller here to marshal the request */ 
     } 
} 

답변

0

당신은 그것을 autowire하기 수

@Service 
public class MarshallingServiceImpl implements MarshallingService{ 

    @Autowired 
    private Jaxb2Marshaller jaxbmarshaller; 

    @Override 
    public String marshal(Entity entity) { 
     StringResult marshalled = new StringResult(); 
     jaxbmarshaller.marshal(entity, marshalled); 
     return marshalled.toString(); 
    } 

}