Comment configurer Spring-WS utiliser JAXB Marshaller?

Merci pour l'aide sur ce jusqu'à présent, je suis la mise à jour de question que je ne montre pas tout ce que je nécessaire à l', avec des changements recommandés montré. le savon de sortie n'est pas encore ce que je voulais.

servlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<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:p="http://www.springframework.org/schema/p"
    xmlns:sws="http://www.springframework.org/schema/web-services"
    xmlns:oxm="http://www.springframework.org/schema/oxm"
    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
                        http://www.springframework.org/schema/oxm 
                        http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd"
                        >

<!--Enables @Endpoint and related Spring-WS annotations.-->
<sws:annotation-driven marshaller="marshaller" unmarshaller="marshaller"/> 

<bean id="weatherService"
    class="au.test.weather.ws.WeatherServiceImpl" />

<bean id="schema" class="org.springframework.xml.xsd.SimpleXsdSchema" 
    p:xsd = "classpath:au/test/weather/ws/schemas/Temperature.xsd"/>

<oxm:jaxb2-marshaller id="marshaller" >
    <oxm:class-to-be-bound name="au.test.weather.ws.GetTemperaturesResponse"/> 
    <oxm:class-to-be-bound name="au.test.weather.ws.GetTemperaturesRequest"/>
    <oxm:class-to-be-bound name="au.test.weather.ws.schemas.Jaxb2Marshaller"/>  
</oxm:jaxb2-marshaller> 

<bean id="temperatureEndpoint"
    class="au.test.weather.ws.TemperatureMarshallingEndpoint">
    <property name="weatherService" ref="weatherService" />
</bean>

ce que mon annoté classes ressembler

@XmlRootElement(name = "GetTemperaturesRequest")
public class GetTemperaturesRequest {

    @XmlElement(required = true)
    protected String city;
    @XmlElement(required = true)
    @XmlSchemaType(name = "date")
    protected List<XMLGregorianCalendar> date;

    public String getCity() {
        return city;
    }

    public void setCity(String value) {
        this.city = value;
    }

    public List<XMLGregorianCalendar> getDate() {
        if (date == null) {
            date = new ArrayList<XMLGregorianCalendar>();
        }
        return this.date;
    }

    public void setDates(List<XMLGregorianCalendar> dates) {
this.date = dates;  
    }
}

Extrémité

@Endpoint
public class TemperatureMarshallingEndpoint {

    private static final String namespaceUri = "http://test.au/schema/weather";
    public static final String request_local_name = "GetTemperaturesRequest";
    private WeatherService weatherService;

    public void setWeatherService(WeatherService weatherService) {
        this.weatherService = weatherService;
    }

    @PayloadRoot(localPart = request_local_name, namespace = namespaceUri)
    @ResponsePayload
    public GetTemperaturesResponse getTemperature(@RequestPayload GetTemperaturesRequest request) throws JAXBException {
        List<GetTemperaturesResponse.TemperatureInfo> temperatures = weatherService.getTemperatures(request.getCity(), request.getDate());

        return new GetTemperaturesResponse(temperatures);
    }       
}

le test

@RunWith(SpringJUnit4ClassRunner.class)  
@ContextConfiguration(locations = {"classpath:servlet.xml"})

public class testOther {

    @Autowired
    private ApplicationContext applicationContext;                                           
    private MockWebServiceClient mockClient;

    @Before
    public void createClient() {
      mockClient = MockWebServiceClient.createClient(applicationContext);                  
    }

    @Test 
    public void TemperatureMarshallingEndpoint() throws Exception {
        Source requestPayload = new StringSource( 
        "<GetTemperaturesRequest xmlns='http://test.au/schema/weather'>" +
        "<city>Houston</city>" +
        "<date>2007-12-01</date>" + 
        "</GetTemperaturesRequest>");      

        Source responsePayload = new StringSource(
        "<GetTemperaturesResponse xmlns='http://test.au/schema/weather'>" +
        "<TemperatureInfo city='Houston' date='2007-12-01'><min>5.0</min><max>10.0</max><average>8.0</average></TemperatureInfo>" +
        "</GetTemperaturesResponse>");

        mockClient.sendRequest(withPayload(requestPayload)).  
        andExpect(payload(responsePayload));  
    }
} 

et ce test passe de sorte qu'il doit être droit, cependant, le savon de sortie ajoute le NS2 préfixe

DEBUG: org.springframework.ws.server.MessageTracing.sent - 
Sent response 
[<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/><SOAP-ENV:Body>
<ns2:GetTemperaturesResponse xmlns:ns2="http://test.au/schema/weather">
    <ns2:TemperatureInfo city="Houston" date="2007-12-01">
        <ns2:min>5.0</ns2:min>
        <ns2:max>10.0</ns2:max>
        <ns2:average>8.0</ns2:average>
    </ns2:TemperatureInfo>
</ns2:GetTemperaturesResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>] 
for request 
[<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/><SOAP-ENV:Body>
<GetTemperaturesRequest xmlns="http://test.au/schema/weather">
    <city>Houston</city>
    <date>2007-12-01</date></GetTemperaturesRequest>
</SOAP-ENV:Body></SOAP-ENV:Envelope>]

d'où vient cet espace de noms ajoutés?

Quelle est la version de Spring-WS utilisez-vous? En regardant la doc de org.springframework.ws.serveur.point de terminaison.l'adaptateur.GenericMarshallingMethodEndpointadapter, il est obsolète dès le Printemps de Services Web 2.0, en faveur de DefaultMethodEndpointAdapter et MarshallingPayloadMethodProcessor. Peut-être vous pouvez essayer les nouvelles classes.
ok, je ne suis plus à l'aide de l'amortissement des valeurs, mon spring-ws est la version 2.0.2
mon nouveau problème est similaire à this mais je ne sais pas comment l'appliquer

OriginalL'auteur Sean F | 2012-07-17