我使用soap和jaxb2marshaller创建了一个Spring3.0WebService来封送xml。我正在wildfly服务器上部署它。一旦部署了15-20分钟,响应pojo中指定的所有字段都将填充到响应xml中。但15分钟后,所有对webservice的请求都只包含一个字段的响应。
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>
我从wsdl文件生成pojo,讨论中的pojo如下所示。
//
// 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>
* <complexType>
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="assessmentResult" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="resultStatus" type="{http://www.w3.org/2001/XMLSchema}string"/>
* <element name="resultMessage" type="{http://www.w3.org/2001/XMLSchema}string"/>
* </sequence>
* </restriction>
* </complexContent>
* </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>
* <complexType>
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="assessmentResult" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="resultStatus" type="{http://www.w3.org/2001/XMLSchema}string"/>
* <element name="resultMessage" type="{http://www.w3.org/2001/XMLSchema}string"/>
* </sequence>
* </restriction>
* </complexContent>
* </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 + "]";
}
}
我尝试使用defaultmethodendpointadapter,但结果相同。我找不到任何补救办法。
React迅速。
<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>
mobilewebserviceendpoint.java版本
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;
}
有人请给我一个解决方案。
暂无答案!
目前还没有任何答案,快来回答吧!