[ http://jira.codehaus.org/browse/XFIRE-318?page=all ]
Dan Diephouse updated XFIRE-318:
--------------------------------
Fix Version: 1.1-beta-1
> Invalid exception on empty element
> ----------------------------------
>
> Key: XFIRE-318
> URL: http://jira.codehaus.org/browse/XFIRE-318
> Project: XFire
> Type: Bug
> Components: Core
> Versions: 1.0
> Environment: Win XP, Java 1.5
> Reporter: Karthikeyan M.
> Assignee: Dan Diephouse
> Priority: Minor
> Fix For: 1.1-beta-1
>
>
> There seems to be an issue with AbstractMessageReader.getValueAsXXX() methods
> when there is an empty element in the request. I am using 1.0 verion of xfire.
> If I have a class like the following is passed to a service method as an
> input parameter
> public class A
> {
> private Long ID;
> private Date createdDate;
> private String name;
> //getter and setter
> }
> Whose schema in wsdl looks like:
> <xsd:complexType name="A">
> <xsd:sequence>
> <xsd:element minOccurs="0" name="ID" nillable="true" type="xsd:long"/>
> <xsd:element minOccurs="0" name="createdDate" type="xsd:dateTime"/>
> <xsd:element minOccurs="0" name="name" nillable="true"
> type="xsd:string"/> </xsd:sequence>
> </xsd:complexType>
> and created a request (using a php client) that could look like
> <SOAP-ENV:Envelope
> xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:ns1="http://mycompany.com"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> <SOAP-ENV:Body>
> <ns1:serviceMethod>
> <ns1:A>
> *<ns1:ID/>*
> <ns1:createdDate>2006-07-01T00:00:00</ns1:createdDate>
> <ns1:name>Chicago Cars</ns1:name>
> </ns1:A>
> </ns1:addCampaign>
> </SOAP-ENV:Body>
> </SOAP-ENV:Envelope>
> I get an exception:
> org.codehaus.xfire.fault.XFireFault: Illegal argument. For input string:
> "2006-07-01T00:00:00"
> at
> org.codehaus.xfire.aegis.type.basic.BeanType.readObject(BeanType.java:155)
> at
> org.codehaus.xfire.aegis.AegisBindingProvider.readParameter(AegisBindingProvider.java:91)
> at
> org.codehaus.xfire.service.binding.AbstractBinding.read(AbstractBinding.java:175)
> at
> org.codehaus.xfire.service.binding.WrappedBinding.readMessage(WrappedBinding.java:50)
> at
> org.codehaus.xfire.soap.handler.SoapBodyHandler.invoke(SoapBodyHandler.java:42)
> at
> org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:98)
> at
> org.codehaus.xfire.transport.DefaultEndpoint.onReceive(DefaultEndpoint.java:58)
> at
> org.codehaus.xfire.transport.AbstractChannel.receive(AbstractChannel.java:38)
> at
> org.codehaus.xfire.transport.http.XFireServletController.invoke(XFireServletController.java:276)
> at
> org.codehaus.xfire.transport.http.XFireServletController.doService(XFireServletController.java:145)
> at
> org.codehaus.xfire.transport.http.XFireServlet.doPost(XFireServlet.java:100)
> at
> com.mycompany.sm.ws.servlet.MasterXFireServlet.doPost(MasterXFireServlet.java:61)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
> at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
> at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
> at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
> at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
> at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
> at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
> at
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
> at
> org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
> at
> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
> at
> org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
> at
> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
> at java.lang.Thread.run(Thread.java:595)
> *Caused by: java.lang.NumberFormatException: For input string:
> "2006-07-01T00:00:00"*
> at
> java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
> at java.lang.Long.parseLong(Long.java:412)
> at java.lang.Long.parseLong(Long.java:461)
> at
> org.codehaus.xfire.aegis.AbstractMessageReader.getValueAsLong(AbstractMessageReader.java:70)
> at
> org.codehaus.xfire.aegis.type.basic.LongType.readObject(LongType.java:28)
> at
> org.codehaus.xfire.aegis.type.basic.BeanType.readObject(BeanType.java:111)
> I would expect either the request to go through or a NumberFormatException
> because of an empty string. The issue seems to be with
> AbstractMessageReader.getValueAsXXX() methods.
> public long getValueAsLong()
> {
> if (getValue() == null) return 0l;
> return Long.parseLong( *getValue()* );
> }
> The second getValue() is getting the value of the next element in the
> request, in this case the value of the element createdDate.
> The simple fix I can think of is to call getValue() once and use the text.
> It would also be more practical and helpful (especially with interop clients)
> to return null instead of NumberFormatException for empty strings. I am not
> sure if this would violate any specs requirements.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira