2 Replies Latest reply on Jul 24, 2006 4:26 PM by wconroy

    Dates in Web Services

      I am having trouble using dates in web services. I have the following

      @WebService(name = "EndpointInterface",
       targetNamespace = "http://test.com/test",
       serviceName = "TestWebservice")
      @SOAPBinding(style = SOAPBinding.Style.RPC)
      @Stateless
      public class TestWebservice implements TestWebserviceRemote {
      
       @WebMethod
       public void getData(Date theDate) {
       Logger.getLogger(TestWebservice.class).info("Got Date: " + theDate);
       }
      }
      


      It produces this as the wsdl when I deploy it on 4.0.4.GA with JbossWS 1.0.1

      <?xml version="1.0" encoding="UTF-8"?>
      <definitions name="TestWebservice" targetNamespace="http://skyroad.com/securitiesservice" xmlns:tns="http://skyroad.com/securitiesservice" xmlns:xsd="http:/
      /www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns="http://schemas.xmlsoap.org/wsdl/">
       <types>
       </types>
       <message name="EndpointInterface_getDataResponse">
       </message>
       <message name="EndpointInterface_getData">
       <part name="Date_1" type="xsd:dateTime"/>
       </message>
       <portType name="EndpointInterface">
       <operation name="getData" parameterOrder="Date_1">
       <input message="tns:EndpointInterface_getData"/>
       <output message="tns:EndpointInterface_getDataResponse"/>
       </operation>
       </portType>
       <binding name="EndpointInterfaceBinding" type="tns:EndpointInterface">
       <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
       <operation name="getData">
       <soap:operation soapAction=""/>
       <input>
       <soap:body use="literal" namespace="http://skyroad.com/securitiesservice"/>
       </input>
       <output>
       <soap:body use="literal" namespace="http://skyroad.com/securitiesservice"/>
       </output>
       </operation>
       </binding>
       <service name="TestWebservice">
       <port name="EndpointInterfacePort" binding="tns:EndpointInterfaceBinding">
       <soap:address location="http://dlnx07.skyroadtech.com:8080/securitiesServiceWS/TestWebservice"/>
       </port>
       </service>
      </definitions>
      


      When I try to consume the service, the server throws the following exception

      12:29:47,089 ERROR [SOAPFaultExceptionHelper] SOAP request exception
      org.jboss.ws.WSException: Java type 'class java.util.Date' is not assignable from: java.util.GregorianCalendar
       at org.jboss.ws.soap.SOAPContentElement.getObjectValue(SOAPContentElement.java:277)
       at org.jboss.ws.binding.EndpointInvocation.transformPayloadValue(EndpointInvocation.java:233)
       at org.jboss.ws.binding.EndpointInvocation.getRequestParamValue(EndpointInvocation.java:103)
       at org.jboss.ws.binding.EndpointInvocation.getRequestPayload(EndpointInvocation.java:117)
       at org.jboss.ws.integration.jboss.ServiceEndpointInvokerEJB3.invokeServiceEndpoint(ServiceEndpointInvokerEJB3.java:115)
       at org.jboss.ws.server.ServiceEndpointInvoker.invoke(ServiceEndpointInvoker.java:115)
       at org.jboss.ws.server.ServiceEndpoint.handleRequest(ServiceEndpoint.java:219)
       at org.jboss.ws.server.ServiceEndpointManager.processSOAPRequest(ServiceEndpointManager.java:355)
       at org.jboss.ws.server.StandardEndpointServlet.doPost(StandardEndpointServlet.java:109)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
       at org.jboss.ws.server.StandardEndpointServlet.service(StandardEndpointServlet.java:75)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       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.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
       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:869)
       at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
       at java.lang.Thread.run(Thread.java:595)
      


      Is there something that I need to do in order for the dates in my request to get parsed correctly? I have looked through the samples, but they are very trivial and dont seem to have dates.

        • 1. Re: Dates in Web Services

          Hi,
          I solved the same problem using Calendar instead of Date for each parameters in SEI's methods; Calendar and Date are both mapped to xsd:dateTime.
          Alessio Soldano

          • 2. Re: Dates in Web Services

            I was thinking about doing that, but I have the issue that I have some complex objects that I want to be part of my request that have dates in them. I have existing non- web service apis that take dates and I dont want to have to do the calendar/date translation myself. Is there no way to specify that I want to use a date instead of calendar?