SWS-785 - MTOM sample should not use deprecated api

This commit is contained in:
Arjen Poutsma
2012-08-07 10:20:14 +00:00
parent ed4310803a
commit 786ebe2a8b
2 changed files with 15 additions and 9 deletions

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2007 the original author or authors.
* Copyright 2005-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -16,9 +16,7 @@
package org.springframework.ws.samples.mtom.ws;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import javax.activation.DataHandler;
import javax.xml.bind.JAXBElement;
import org.springframework.util.Assert;
@@ -27,6 +25,8 @@ import org.springframework.ws.samples.mtom.schema.ObjectFactory;
import org.springframework.ws.samples.mtom.service.ImageRepository;
import org.springframework.ws.server.endpoint.annotation.Endpoint;
import org.springframework.ws.server.endpoint.annotation.PayloadRoot;
import org.springframework.ws.server.endpoint.annotation.RequestPayload;
import org.springframework.ws.server.endpoint.annotation.ResponsePayload;
/** @author Arjen Poutsma */
@Endpoint
@@ -43,13 +43,15 @@ public class ImageRepositoryEndpoint {
}
@PayloadRoot(localPart = "StoreImageRequest", namespace = "http://www.springframework.org/spring-ws/samples/mtom")
public void store(JAXBElement<Image> requestElement) throws IOException {
@ResponsePayload
public void store(@RequestPayload JAXBElement<Image> requestElement) throws IOException {
Image request = requestElement.getValue();
imageRepository.storeImage(request.getName(), request.getImage());
}
@PayloadRoot(localPart = "LoadImageRequest", namespace = "http://www.springframework.org/spring-ws/samples/mtom")
public JAXBElement<Image> load(JAXBElement<String> requestElement) throws IOException {
@ResponsePayload
public JAXBElement<Image> load(@RequestPayload JAXBElement<String> requestElement) throws IOException {
String name = requestElement.getValue();
Image response = new Image();
response.setName(name);

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
<bean id="imageRepository" class="org.springframework.ws.samples.mtom.service.StubImageRepository"/>
@@ -10,7 +10,12 @@
<bean class="org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping"/>
<bean class="org.springframework.ws.server.endpoint.adapter.GenericMarshallingMethodEndpointAdapter">
<bean class="org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapter">
<property name="methodArgumentResolvers" ref="methodProcessor"/>
<property name="methodReturnValueHandlers" ref="methodProcessor"/>
</bean>
<bean id="methodProcessor" class="org.springframework.ws.server.endpoint.adapter.method.MarshallingPayloadMethodProcessor">
<constructor-arg ref="marshaller"/>
</bean>
@@ -25,7 +30,6 @@
<property name="locationUri" value="http://localhost:8080/mtom-server/"/>
</bean>
<bean id="schema" class="org.springframework.xml.xsd.SimpleXsdSchema">
<property name="xsd" value="/WEB-INF/schema.xsd"/>
</bean>