[JBossWS] - Best Practices for Dates
by awhitford
I have a web service that returns Dates. Imagine something simple like:
| @WebMethod
| Date getCurrentBusinessDate()
|
In this case, I am only interested in a Date (not a Time or Date Time). This is by design because otherwise one might go down the road of considering Time Zones, etc. -- and that is not necessary for this case.
When running something like this, we see a full date/time appear in the SOAP result. Sure, the time is zero/midnight, but it also mentions a time zone (which really shouldn't be there, but seems to be impossible to get rid of).
By rights, I really only want to see a Date transmitted (like YYYY-MM-DD). In JPA, for example, I use a Date type but qualify it with a @Temporal annotation to clarify the TemporalType (Date, Time, DateTime). I see that JAXB has similar distinctions (xsd:date, xsd:time, xsd:dateTime).
Is there a way to annotate the web method so the return value is clarified to be an xsd:date?
Secondly... Is there a material difference between using java.util.Date vs. java.util.Calendar? (Is one really preferred over the other?) If I am writing Java-first Web Services, should I be using Date or Calendar to represent dates?
Thanks for your help!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4191502#4191502
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4191502
16 years, 1 month
[JBossWS] - A SOAPMessageFactory1_1Impl Classcast exception that only ha
by theraser88
Hi,
I successfully deployed my web service onto jboss application server. But it seems I can only successfully sent requests to my Windows server, and not the UNIX machine(RED HAT 9)
I deployed my Web service using .ear, so I may include SUN metro libraries v1.3
hellometro.ear
--HelloMetro.ear
--WEB-INF/web.xml
--WEB-INF/jboss-web.xml
--WEB-INF/sun-jaxws.xml
--META-INF
--jboss-app.xml
--application.xml
--lib
--webservices-api.jar
--webservices-extra-api.jar
--webservices-rt.jar
--webservices-extra.jar
I got the following exception; I am not sure what to make out of the exception but the soap version # might be wrong. I am using Jboss 4.2.2 GA and Jbossws 3.0.4. The web service code is compile using java 1.5.
Any help is appropriated.
Thank you!
java.lang.ClassCastException: com.sun.xml.messaging.saaj.soap.ver1_1.Envelope1_1Impl
at org.jboss.ws.core.soap.SOAPEnvelopeImpl.(SOAPEnvelopeImpl.java:57)
at org.jboss.ws.core.soap.EnvelopeBuilderDOM.build(EnvelopeBuilderDOM.java:136)
at org.jboss.ws.core.soap.EnvelopeBuilderDOM.build(EnvelopeBuilderDOM.java:96)
at org.jboss.ws.core.soap.MessageFactoryImpl.createMessage(MessageFactoryImpl.java:283)
at org.jboss.ws.core.soap.MessageFactoryImpl.createMessage(MessageFactoryImpl.java:193)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHandlerImpl.java:479)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHandlerImpl.java:295)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl.java:205)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:131)
at org.jboss.wsf.common.servlet.AbstractEndpointServlet.service(AbstractEndpointServlet.java:109)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
at java.lang.Thread.run(Thread.java:595)
16:52:01,754 ERROR [RequestHandlerImpl] Error processing web service request
org.jboss.ws.WSException: java.lang.ClassCastException: com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl
at org.jboss.ws.WSException.rethrow(WSException.java:68)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHandlerImpl.java:336)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl.java:205)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:131)
at org.jboss.wsf.common.servlet.AbstractEndpointServlet.service(AbstractEndpointServlet.java:109)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.ClassCastException: com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl
at org.jboss.ws.core.jaxws.SOAPFaultHelperJAXWS.createSOAPMessage(SOAPFaultHelperJAXWS.java:288)
at org.jboss.ws.core.jaxws.SOAPFaultHelperJAXWS.toSOAPMessage(SOAPFaultHelperJAXWS.java:256)
at org.jboss.ws.core.jaxws.SOAPFaultHelperJAXWS.exceptionToFaultMessage(SOAPFaultHelperJAXWS.java:187)
at org.jboss.ws.core.jaxws.binding.SOAP11BindingJAXWS.createFaultMessageFromException(SOAP11BindingJAXWS.java:102)
at org.jboss.ws.core.CommonSOAPBinding.bindFaultMessage(CommonSOAPBinding.java:669)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHandlerImpl.java:520)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHandlerImpl.java:295)
... 22 more
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4191437#4191437
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4191437
16 years, 1 month
[JBossWS] - webservice/client not functioning correctly after move from
by jamicide
I have deployed an .ear file that runs stably on 4.0.3SP1 to 4.2.2GA.
Following the deployment, most of my webservices operate correctly (using the same client I used with v4.0.3SP1). However when I try to call a webservice which uses a complex type (in this case, arrayType) Jboss throws the following exception:
2008-11-19 14:44:11,912 ERROR [org.jboss.ws.core.jaxrpc.SOAPFaultHelperJAXRPC] SOAP request exception
org.jboss.ws.WSException: Cannot obtain attribute: {http://schemas.xmlsoap.org/soap/encoding/}arrayType
at org.jboss.ws.core.jaxrpc.binding.SOAPArrayDeserializer.getComponentTypeFromAttribute(SOAPArrayDeserializer.java:172)
at org.jboss.ws.core.jaxrpc.binding.SOAPArrayDeserializer.deserialize(SOAPArrayDeserializer.java:70)
at org.jboss.ws.core.binding.DeserializerSupport.deserialize(DeserializerSupport.java:60)
at org.jboss.ws.core.soap.XMLContent.unmarshallObjectContents(XMLContent.java:180)
at org.jboss.ws.core.soap.XMLContent.transitionTo(XMLContent.java:97)
at org.jboss.ws.core.soap.SOAPContentElement.transitionTo(SOAPContentElement.java:140)
at org.jboss.ws.core.soap.SOAPContentElement.getObjectValue(SOAPContentElement.java:171)
at org.jboss.ws.core.EndpointInvocation.transformPayloadValue(EndpointInvocation.java:263)
at org.jboss.ws.core.EndpointInvocation.getRequestParamValue(EndpointInvocation.java:115)
at org.jboss.ws.core.EndpointInvocation.getRequestPayload(EndpointInvocation.java:135)
at org.jboss.ws.core.server.DelegatingInvocation.getArgs(DelegatingInvocation.java:82)
at org.jboss.wsf.container.jboss42.DefaultInvocationHandler.invoke(DefaultInvocationHandler.java:102)
at org.jboss.wsf.container.jboss42.DefaultInvocationHandlerJAXRPC.invoke(DefaultInvocationHandlerJAXRPC.java:57)
at org.jboss.ws.core.server.ServiceEndpointInvoker.invoke(ServiceEndpointInvoker.java:220)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHandlerImpl.java:408)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHandlerImpl.java:272)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl.java:189)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:122)
at org.jboss.wsf.stack.jbws.EndpointServlet.service(EndpointServlet.java:84)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
at java.lang.Thread.run(Thread.java:595)
Any suggestions on what might be going on here are most appreciated.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4191324#4191324
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4191324
16 years, 1 month
[JBossWS] - Unsupported content type: text/html on WS call
by chrissy
Hi there. I am getting the following error in my WS client:
Caused by: org.jboss.remoting.CannotConnectException: Can not connect http client invoker. javax.xml.soap.SOAPException: Unsupported content type: text/html. Response: OK/200.
| at org.jboss.remoting.transport.http.HTTPClientInvoker.useHttpURLConnection(HTTPClientInvoker.java:348)
| at org.jboss.remoting.transport.http.HTTPClientInvoker.transport(HTTPClientInvoker.java:137)
I turned on RequestDumperValve to see the header details and I first see my client requesting the WSDL:
12:23:34,084 INFO [[localhost]] ===============================================================
| 12:23:34,092 INFO [[localhost]] REQUEST URI =/MyServer/MyService
| 12:23:34,092 INFO [[localhost]] authType=null
| 12:23:34,092 INFO [[localhost]] characterEncoding=null
| 12:23:34,092 INFO [[localhost]] contentLength=-1
| 12:23:34,092 INFO [[localhost]] contentType=null
| 12:23:34,093 INFO [[localhost]] contextPath=/MyServer
| 12:23:34,093 INFO [[localhost]] header=user-agent=Java/1.5.0_16
| 12:23:34,093 INFO [[localhost]] header=host=localhost:8080
| 12:23:34,093 INFO [[localhost]] header=accept=text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
| 12:23:34,093 INFO [[localhost]] header=connection=keep-alive
| 12:23:34,094 INFO [[localhost]] locale=en_US
| 12:23:34,094 INFO [[localhost]] method=GET
| 12:23:34,094 INFO [[localhost]] parameter=wsdl=
| 12:23:34,095 INFO [[localhost]] pathInfo=null
| 12:23:34,095 INFO [[localhost]] protocol=HTTP/1.1
| 12:23:34,095 INFO [[localhost]] queryString=wsdl
| 12:23:34,095 INFO [[localhost]] remoteAddr=127.0.0.1
| 12:23:34,095 INFO [[localhost]] remoteHost=127.0.0.1
| 12:23:34,095 INFO [[localhost]] remoteUser=null
| 12:23:34,096 INFO [[localhost]] requestedSessionId=null
| 12:23:34,096 INFO [[localhost]] scheme=http
| 12:23:34,096 INFO [[localhost]] serverName=localhost
| 12:23:34,096 INFO [[localhost]] serverPort=8080
| 12:23:34,096 INFO [[localhost]] servletPath=/MyService
| 12:23:34,096 INFO [[localhost]] isSecure=false
| 12:23:34,096 INFO [[localhost]] ---------------------------------------------------------------
| 12:23:34,642 INFO [[localhost]] ---------------------------------------------------------------
| 12:23:34,642 INFO [[localhost]] authType=null
| 12:23:34,648 INFO [[localhost]] contentLength=-1
| 12:23:34,659 INFO [[localhost]] contentType=text/xml
| 12:23:34,694 INFO [[localhost]] header=X-Powered-By=Servlet 2.4; JBoss-4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181417)/JBossWeb-2.0
| 12:23:34,695 INFO [[localhost]] header=Content-Type=text/xml
| 12:23:34,702 INFO [[localhost]] header=Transfer-Encoding=chunked
| 12:23:34,702 INFO [[localhost]] header=Date=Thu, 20 Nov 2008 20:23:34 GMT
| 12:23:34,702 INFO [[localhost]] message=null
| 12:23:34,703 INFO [[localhost]] remoteUser=null
| 12:23:34,703 INFO [[localhost]] status=200
| 12:23:34,703 INFO [[localhost]] ===============================================================
and then I see the Soap Request:
12:23:38,228 INFO [[localhost]] ===============================================================
| 12:23:39,076 INFO [[localhost]] REQUEST URI =/
| 12:23:39,076 INFO [[localhost]] authType=null
| 12:23:39,076 INFO [[localhost]] characterEncoding=UTF-8
| 12:23:39,076 INFO [[localhost]] contentLength=-1
| 12:23:39,076 INFO [[localhost]] contentType=text/xml; charset=UTF-8
| 12:23:39,077 INFO [[localhost]] contextPath=
| 12:23:39,077 INFO [[localhost]] header=authorization=Basic Y2hyaXNzeTpwYXNzd29yZA==
| 12:23:39,077 INFO [[localhost]] header=soapaction="http://schemas.mydomain.net/10/myservice/doLogin"
| 12:23:39,077 INFO [[localhost]] header=content-type=text/xml; charset=UTF-8
| 12:23:39,077 INFO [[localhost]] header=jboss-remoting-version=22
| 12:23:39,077 INFO [[localhost]] header=user-agent=JBossRemoting - 2.2.2.SP8
| 12:23:39,078 INFO [[localhost]] header=host=localhost:8080
| 12:23:39,078 INFO [[localhost]] header=accept=text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
| 12:23:39,078 INFO [[localhost]] header=connection=keep-alive
| 12:23:39,078 INFO [[localhost]] header=transfer-encoding=chunked
| 12:23:39,078 INFO [[localhost]] locale=en_US
| 12:23:39,082 INFO [[localhost]] method=POST
| 12:23:39,083 INFO [[localhost]] pathInfo=null
| 12:23:39,083 INFO [[localhost]] protocol=HTTP/1.1
| 12:23:39,084 INFO [[localhost]] queryString=null
| 12:23:39,084 INFO [[localhost]] remoteAddr=127.0.0.1
| 12:23:39,084 INFO [[localhost]] remoteHost=127.0.0.1
| 12:23:39,084 INFO [[localhost]] remoteUser=null
| 12:23:39,084 INFO [[localhost]] requestedSessionId=null
| 12:23:39,084 INFO [[localhost]] scheme=http
| 12:23:39,084 INFO [[localhost]] serverName=localhost
| 12:23:39,085 INFO [[localhost]] serverPort=8080
| 12:23:39,085 INFO [[localhost]] servletPath=/index.html
| 12:23:39,085 INFO [[localhost]] isSecure=false
| 12:23:39,086 INFO [[localhost]] ---------------------------------------------------------------
| 12:23:39,087 INFO [[localhost]] ---------------------------------------------------------------
| 12:23:39,087 INFO [[localhost]] authType=null
| 12:23:39,087 INFO [[localhost]] contentLength=2919
| 12:23:39,088 INFO [[localhost]] contentType=text/html
| 12:23:39,089 INFO [[localhost]] header=X-Powered-By=Servlet 2.4; JBoss-4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181417)/JBossWeb-2.0
| 12:23:39,090 INFO [[localhost]] header=ETag=W/"2919-1227047690000"
| 12:23:39,091 INFO [[localhost]] header=Last-Modified=Tue, 18 Nov 2008 22:34:50 GMT
| 12:23:39,091 INFO [[localhost]] message=null
| 12:23:39,091 INFO [[localhost]] remoteUser=null
| 12:23:39,091 INFO [[localhost]] status=200
| 12:23:39,091 INFO [[localhost]] ===============================================================
|
If you look closely the Request URI in the second request is / and the servlet Path is /index.html. Which might explain why I am getting text/html returned from the server. I would assume that the Request URI should be /MyServer/MyService as it is in the WSDL service. Is my thinking correct? Can anyone point me in the right direction? I can provide more details but wanted to keep the original post simple.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4191047#4191047
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4191047
16 years, 1 month