轴序列化错误:数字格式异常

时间:2013-10-22 09:01:35

标签: java spring web-services soap wsdl

我正在STS中开发一个Web应用程序。在其中调用web服务并显示结果。我使用STS本身从wsdl生成Web服务客户端。 我创建了一个示例java文件,它向此Web服务发送请求并返回结果。以下是代码:

public final class Client {
static Answer answerObj;
private Client() {
}

public static Answer webCall() throws Exception {
    // START SNIPPET: client

    Question questionObj = new Question();

    questionObj.setName("t");
    questionObj.setNameStartsWith(true);
    questionObj.setDistrict("kob");
    questionObj.setHouseNo("0");
    questionObj.setPhone("0");
    questionObj.setStreet("hai");
    questionObj.setStreetStartsWith(false);
    //questionObj.setAccountantName("")
    questionObj.setCvrNo(1);
    //questionObj.setDistrict("Soendergade 2C ");

    //Like this set all the values here .
    /*System.getProperties().put("proxySet", "true");
    System.getProperties().put("https.proxyHost", "");  
    System.getProperties().put("https.proxyPort",80 );*/

       answerObj =nne_PortTypeProxyObj.search(questionObj, 10, 10, 0, "");

           System.out.println(answerObj.getCompanyBasic().length);


    return answerObj;
    // END SNIPPET: client
}

}

现在我的问题是,当我在Web服务中调用方法搜索时,会发生以下异常:

AxisFault
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Client
 faultSubcode: 
 faultString: caught exception while handling request: deserialization error: java.lang.NumberFormatException: For input string: ""
 faultActor: 
 faultNode: 
 faultDetail: 
    {http://xml.apache.org/axis/}stackTrace:caught exception while handling request: deserialization error: java.lang.NumberFormatException: For input string: ""
    at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
    at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
    at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:601)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1774)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2930)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:807)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:107)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
    at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
    at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
    at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
    at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
    at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:796)
    at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)
    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.client.AxisClient.invoke(AxisClient.java:165)
    at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
    at org.apache.axis.client.Call.invoke(Call.java:2767)
    at org.apache.axis.client.Call.invoke(Call.java:2443)
    at org.apache.axis.client.Call.invoke(Call.java:2366)
    at org.apache.axis.client.Call.invoke(Call.java:1812)
    at net.stibo.com.nne._3_1.PortTypeBindingStub.search(PortTypeBindingStub.java:1446)
    at net.stibo.com.nne._3_1PortTypeProxy.search(PortTypeProxy.java:188)
    at com.sapienter.jbilling.server.util.Client.webCall(Client.java:51)
    at com.sapienter.jbilling.server.util.Client$webCall.call(Unknown Source)

我在stackoverflow中搜索了相同的内容,发现了这个: multiRef in generated xml sending by WS

我认为这是问题,因为我用搜索方法尝试了各种参数。但是没有找到好的解决方案。任何人都可以帮助我吗?PLZZZ帮助....

1 个答案:

答案 0 :(得分:0)

我不知道AXIS生成的存根有什么问题。但是我通过使用java SAAJ库来克服这种情况,通过webservice根据需要构建请求,如链接: Working Soap client example