Java SpringSOAPWebService+;JaxB Marshallar:soap响应xml中缺少字段

Java SpringSOAPWebService+;JaxB Marshallar:soap响应xml中缺少字段,java,spring,web-services,soap,jaxb2,Java,Spring,Web Services,Soap,Jaxb2,我使用soap和jaxb2marshaller创建了一个Spring3.0WebService来封送xml。我正在wildfly服务器中部署它。在部署前15-20分钟后,响应pojo中指定的所有字段都将填充到响应xml中。但15分钟后,对Web服务的所有请求都只包含一个字段的响应 Spring-servlet.xml <bean id="MobileWebservice" class="org.springframework.ws.wsdl.wsdl11.SimpleWsdl11D

我使用soap和jaxb2marshaller创建了一个Spring3.0WebService来封送xml。我正在wildfly服务器中部署它。在部署前15-20分钟后,响应pojo中指定的所有字段都将填充到响应xml中。但15分钟后,对Web服务的所有请求都只包含一个字段的响应

Spring-servlet.xml

<bean id="MobileWebservice"
    class="org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition">
    <constructor-arg value="/WEB-INF/wsdl/MobileWebservice.wsdl" />
</bean>

<bean
    class="org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping">
</bean>

<bean class="org.springframework.ws.server.endpoint.adapter.MarshallingMethodEndpointAdapter">
    <description>Enables the MessageDispatchServlet to invoke methods requiring OXM marshalling.</description>
    <constructor-arg ref="jaxb2Marshaller"/>
</bean>

<bean id="jaxb2Marshaller"
    class="org.springframework.oxm.jaxb.Jaxb2Marshaller" 
    scope="prototype">
    <property name="contextPath"
        value="com.webservice.mobilewebservice.vo" />
</bean>

有人请给我建议一个解决方案。

您忘记了包含端点。对不起。忘记加了。现在添加它。请检查。我建议删除所有配置,但要删除
simplewsdl11定义
,并添加
,这将注册所有需要的内容(您不需要封送拆收器。当然,您还需要将
sws
名称空间添加到xml中。看看这是否会让事情变得更好。接下来,您需要将
@RequestPayload
添加到方法参数中,并将
@ResponsePayload
添加到方法参数中。
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
// Any modifications to this file will be lost upon recompilation of the source schema. 
// Generated on: 2014.09.11 at 12:10:59 PM IST 
//


package com.webservice.mobilewebservice.vo;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;


/**
 * <p>Java class for anonymous complex type.
 * 
 * <p>The following schema fragment specifies the expected content contained within this class.
 * 
 * <pre>
 * &lt;complexType>
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;sequence>
 *         &lt;element name="assessmentResult" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         &lt;element name="resultStatus" type="{http://www.w3.org/2001/XMLSchema}string"/>
 *         &lt;element name="resultMessage" type="{http://www.w3.org/2001/XMLSchema}string"/>
 *       &lt;/sequence>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 * 
 * 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "assessmentResult",
    "resultStatus",
    "resultMessage"
})
@XmlRootElement(name = "PerformAssessmentResponse")
public class PerformAssessmentResponse {

    protected String assessmentResult;
    @XmlElement(required = true)
    protected String resultStatus;
    @XmlElement(required = true)
    protected String resultMessage;

    /**
     * Gets the value of the assessmentResult property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getAssessmentResult() {
        return assessmentResult;
    }

    /**
     * Sets the value of the assessmentResult property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setAssessmentResult(String value) {
        this.assessmentResult = value;
    }

    /**
     * Gets the value of the resultStatus property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getResultStatus() {
        return resultStatus;
    }

    /**
     * Sets the value of the resultStatus property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setResultStatus(String value) {
        this.resultStatus = value;
    }

    /**
     * Gets the value of the resultMessage property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getResultMessage() {
        return resultMessage;
    }

    /**
     * Sets the value of the resultMessage property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setResultMessage(String value) {
        this.resultMessage = value;
    }

}
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
// Any modifications to this file will be lost upon recompilation of the source schema. 
// Generated on: 2014.09.11 at 12:10:59 PM IST 
//


package com.webservice.mobilewebservice.vo;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;


/**
 * <p>Java class for anonymous complex type.
 * 
 * <p>The following schema fragment specifies the expected content contained within this class.
 * 
 * <pre>
 * &lt;complexType>
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;sequence>
 *         &lt;element name="assessmentResult" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         &lt;element name="resultStatus" type="{http://www.w3.org/2001/XMLSchema}string"/>
 *         &lt;element name="resultMessage" type="{http://www.w3.org/2001/XMLSchema}string"/>
 *       &lt;/sequence>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 * 
 * 
 */
@XmlType(name = "", propOrder = {
    "assessmentResult",
    "resultStatus",
    "resultMessage"
})
@XmlRootElement(name = "PerformAssessmentResponse")
public class PerformAssessmentResponse {


    protected String assessmentResult;
    protected String resultStatus;
    protected String resultMessage;

    /**
     * Gets the value of the assessmentResult property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    @XmlElement(required = false)
    public String getAssessmentResult() {
        return assessmentResult;
    }

    /**
     * Sets the value of the assessmentResult property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setAssessmentResult(String value) {
        this.assessmentResult = value;
    }

    /**
     * Gets the value of the resultStatus property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */

    @XmlElement(required = true)
    public String getResultStatus() {
        return resultStatus;
    }

    /**
     * Sets the value of the resultStatus property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setResultStatus(String value) {
        this.resultStatus = value;
    }

    /**
     * Gets the value of the resultMessage property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */

    @XmlElement(required = true)
    public String getResultMessage() {
        return resultMessage;
    }

    /**
     * Sets the value of the resultMessage property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setResultMessage(String value) {
        this.resultMessage = value;
    }

    @Override
    public String toString() {
        return "PerformAssessmentResponse [assessmentResult=" + assessmentResult + ", resultStatus=" + resultStatus
                + ", resultMessage=" + resultMessage + "]";
    }

}
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <SOAP-ENV:Body>
      <ns3:PerformAssessmentResponse xmlns:ns3="http://com.mobile.service/MobileWebservice/">
         <assessmentResult>true</assessmentResult>
         <resultStatus>1</resultStatus>
         <resultMessage>Success</resultMessage>
      </ns3:PerformAssessmentResponse>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <SOAP-ENV:Body>
      <ns3:PerformAssessmentResponse xmlns:ns3="http://com.mobile.service/MobileWebservice/">
         <resultStatus>1</resultStatus>
      </ns3:PerformAssessmentResponse>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
    package com.webservice.mobilewebservice.endpoint;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.zip.ZipException;

import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;

import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipFile;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.ws.server.endpoint.annotation.Endpoint;
import org.springframework.ws.server.endpoint.annotation.PayloadRoot;


@Endpoint
public class MobileWebServiceEndPoint {

    public static String INTERNAL_SERVER_ERROR_MESSAGE = "Internal Server Error";
    @PayloadRoot(localPart = "PerformAssessmentRequest", namespace = "http://com.mobile.service/MobileWebservice/")
    public PerformAssessmentResponse performAssessment(PerformAssessmentRequest request)
    {
        PerformAssessmentResponse response = new PerformAssessmentResponse();
        try
        {
            byte [] requestData = request.getRequestData();
            Map dataMap = new HashMap();
            dataMap.put("transactionId", request.getTransactionId());
            dataMap.put("requestData", requestData);


            response.setResultMessage("Success");
            response.setResultStatus("1");

            response.setAssessmentResult("true");
        }
        catch(Exception lre)
        {
            lre.printStackTrace();
            response.setResultStatus("500");
            response.setResultMessage(INTERNAL_SERVER_ERROR_MESSAGE);
        }
        return response;
    }