org.xml.sax.SAXException:反序列化参数' req':找不到类型{http:// localhost:1111 / WebService}请求的反序列化器

时间:2016-04-18 13:46:22

标签: java eclipse soapserver

我创建了一个java应用程序(使用quickserver),它将在没有应用程序服务器的情况下运行soap Web服务。我成功创建了一个,并且能够在我的浏览器上访问wsdl文件http://localhost:1111/WebService?wsdl,但是当我使用SoapUI并发送请求时,它会返回错误。

以下是SoapUI的回复:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"        xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <soapenv:Body>
  <soapenv:Fault>
     <faultcode>soapenv:Server.userException</faultcode>
     <faultstring>org.xml.sax.SAXException: Deserializing parameter 'req':  could not find deserializer for type {http://localhost:1111/WebService}Request</faultstring>
     <detail>
        <ns1:stackTrace xmlns:ns1="http://xml.apache.org/axis/">org.xml.sax.SAXException: Deserializing parameter 'req':  could not find deserializer for type {http://localhost:1111/WebService}Request
at org.apache.axis.message.RPCHandler.onStartChild(RPCHandler.java:277)
at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:236)
at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:81)
at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:454)
at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281)
at org.jSoapServer.SoapHandler.handleBinary(SoapHandler.java:588)
at org.quickserver.net.server.impl.BlockingClientHandler.processRead(BlockingClientHandler.java:366)
at org.quickserver.net.server.impl.BlockingClientHandler.run(BlockingClientHandler.java:193)
at org.quickserver.util.pool.thread.ClientThread.executeClient(ClientThread.java:107)
at org.quickserver.util.pool.thread.ClientThread.run(ClientThread.java:136)</ns1:stackTrace>
        <ns2:hostname xmlns:ns2="http://xml.apache.org/axis/">TLC-Rico</ns2:hostname>
     </detail>
  </soapenv:Fault>

ws.java:

public class ws {

@WebMethod
public @WebResult(name="ServiceResponse") Response string(@XmlElement(required=true) 
@WebParam(name="ServiceRequest") Request req){

    Response res = new Response();

    if(req.getString1().equals("") || req.getString2().equals("") || req.getString3().equals("")){
        res.setStatus(1);
        res.setDescription("null values");
    } else{
        res.setStatus(0);
        res.setDescription("success");
    }
    return res;

 }

}

Request.java:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name="StringRequest", propOrder={"string1", "string2", "string3"})
@XmlRootElement
public class Request {

@XmlElement(name="String1", required=true) 
private String string1;
@XmlElement(name="String2", required=true) 
private String string2;
@XmlElement(name="String3", required=true) 
private String string3;

public String getString1() {
    return string1;
}
public void setString1(String string1) {
    this.string1 = string1;
}
public String getString2() {
    return string2;
}
public void setString2(String string2) {
    this.string2 = string2;
}
public String getString3() {
    return string3;
}
public void setString3(String string3) {
    this.string3 = string3;
}

}

Response.java

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name="Response", propOrder={"status", "description"})
@XmlRootElement
public class Response {

@XmlElement(name="Status", required=true) 
private int status;
@XmlElement(name="Description", required=true) 
private String description;

public Response(){}

public Response(int status, String description){
    this.status = status;
    this.description = description;
}

public int getStatus() {
    return status;
}
public void setStatus(int status) {
    this.status = status;
}
public String getDescription() {
    return description;
}
public void setDescription(String description) {
    this.description = description;
}

}

test.java

public class test{

public static void main(String[] args) throws Exception{

    SoapServer server = new SoapServer();

    server.initService(Util.getWorkingDirectory() + "/jsoapserver.xml");
    server.deployRpcSoapService(ws.class, "WebService");
    server.startServer();


}

}

我的构建路径中包含以下库:

-activation-1.1.1.jar
-activation.jar
-axis-1.4.jar
-axis-jaxrpc-1.4.jar
-axis-saaj-1.4.jar
-axis-wsdl4j-1.5.jar
-commons-beanutils-1.6.1.jar
-commons-codec-1.2.jar
-commons-collections-3.1.jar
-commons-digester-1.5.jar
-commons-discovery-0.2.jar
-commons-httpclient-3.1.jar
-commons-logging-1.0.4.jar
-commons-pool-1.2.jar
-jsoapserver-0.3.jar
-log4j-1.2.8.jar
-mail-1.4.1.jar
-quickserver-1.4.7.jar
-xercesImpl-2.0.2.jar
-xml-apis-1.0.b2.jar

0 个答案:

没有答案