Many recommend not to use sun
packages for various reasons. Detailed answers are provided here .
However I am using jaxws-rt.jar
which uses sun library.
I am wondering if I should jaxws-rt.jar
or not. I am running in tomcat container and I do not want to include jaxws implementations of Jboss,GlassFish or any other application servers.
Here is what I am trying to do (setting connection and request timeouts)
import com.sun.xml.internal.ws.client.BindingProviderProperties;
import javax.xml.ws.BindingProvider;
((BindingProvider)soapService).getRequestContext()
.put(BindingProviderProperties.REQUEST_TIMEOUT,REQUEST_TIMEOUT_MILLI);
((BindingProvider)soapService).getRequestContext()
.put(BindingProviderProperties.CONNECT_TIMEOUT,CONNECT_TIMEOUT_MILLI);
Thanks
As you've found, certain behaviors (such as connection timeouts) are controlled through implementation-specific means.
If you're not keen on compiling against (importing) the com.sun
packages, one way to remove the compile-time dependencies yet set these properties to control the JAX-WS reference implementation the way you need, you can try just setting the BindingProvider
request context properties for the reference implementation by their string values . You can set these properties even when running with other JAX-WS runtimes than the RI - it won't fail (it just may have no effect).
import javax.xml.ws.BindingProvider;
((BindingProvider)soapService).getRequestContext()
.put("com.sun.xml.ws.request.timeout", 5000L);
((BindingProvider)soapService).getRequestContext()
.put("com.sun.xml.ws.connect.timeout", 5000L);
Here are the two values for both constants in your question. JAXWSProperties.CONNECT_TIMEOUT and BindingProviderProperties.REQUEST_TIMEOUT .
This is a misunderstanding.
even though it includes
sun
libraries?
It doesn't 'include sun
libraries'. It refers to a com.sun
library. That's a completely different thing. Two completely different things.
Many recommend not to [use]
sun
packages for various reasons.
There is only one recommendation that counts, and it is the Note about sun.* packages . The operative sentence in that is:
Programs that contain direct calls to the sun.* packages are not 100% Pure Java.
The sun.*
packages are there for a reason of course, and that is to provide implementations for various things in the JDK . If that's the only use your program makes of these classes, and specifically if your code doesn't contain 'direct calls to the sun.*
packages', you don't have anything to worry about.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.