soap包中,包含:
<param3 href="#id0"/>
<multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
xsi:type="xsd:long" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
3000
</multiRef>
java代码中,
@WebService(name = "**", targetNamespace = "***")
@SOAPBinding(use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.BARE)
抛出类型转换异常:
java.lang.NumberFormatException: For input string: ""
        at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
        at java.lang.Long.parseLong(Long.java:424)
        at java.lang.Long.parseLong(Long.java:461)
        at org.codehaus.xfire.aegis.AbstractMessageReader.getValueAsLong(AbstractMessageReader.java:78)
请大侠指点!

解决方案 »

  1.   

    你执行了
    Long.parseLong("")的动作,所以报错了。
    在AbstractMessageReader.java:78打个断点看看
      

  2.   

    AbstractMessageReader.java是xfire框架中的东西,问题出在xfire不识别param3。
      

  3.   

    这里很明确了,就是NumberFormatException,应为你调用Long.parseLong() 时参数输入为"".java.lang.NumberFormatException: For input string: ""
      at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
      at java.lang.Long.parseLong(Long.java:424)
      at java.lang.Long.parseLong(Long.java:461)
      at org.codehaus.xfire.aegis.AbstractMessageReader.getValueAsLong(AbstractMessageReader.java:78)
      

  4.   

    抛出这个异常的直接原因,就是类型转换异常(Long)(new String(""))。更深层的原因是,xfire 不能识别soap请求包中的 param3 href="  想知道如何使xfire识别param3的值。
    soap包如下
    <?xml version="1.0" encoding="UTF-8"?>
    <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>
    <ns1:receivePaymentConfirmation soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://Ws.impl.fundamo.acme.com"><param0 xsi:type="xsd:string">250788442368</param0>
    <param1 xsi:type="xsd:string">Testing Mmtest</param1>
    <param2 xsi:type="xsd:string">01868008835</param2><param3 href="#id0"/>
    <param4 xsi:type="xsd:string">test</param4></ns1:receivePaymentConfirmation><multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
    xsi:type="xsd:long" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
    3000
    </multiRef></soapenv:Body>
    </soapenv:Envelope>
      

  5.   

    java.lang.NumberFormatException: For input string: ""
    获得的是个空串
      

  6.   

    恩,是。就是这个问题,应该得到 3000(param3的值),却得到空串。
      

  7.   

    问题原因是xfire、cxf不能读取<param3 href="#id0"/><multiRef id="id0"..... 格式的数据,详见:http://stackoverflow.com/questions/4510101/soap-href-xml-mapping-problem-which-mapping-helps