53 * @author Manveen Kaur (manveen.kaur@sun.com) |
53 * @author Manveen Kaur (manveen.kaur@sun.com) |
54 * |
54 * |
55 */ |
55 */ |
56 public class HttpSOAPConnection extends SOAPConnection { |
56 public class HttpSOAPConnection extends SOAPConnection { |
57 |
57 |
58 protected static Logger log = |
58 public static final String vmVendor = System.getProperty("java.vendor.url"); |
|
59 private static final String sunVmVendor = "http://java.sun.com/"; |
|
60 private static final String ibmVmVendor = "http://www.ibm.com/"; |
|
61 private static final boolean isSunVM = sunVmVendor.equals(vmVendor) ? true: false; |
|
62 private static final boolean isIBMVM = ibmVmVendor.equals(vmVendor) ? true : false; |
|
63 private static final String JAXM_URLENDPOINT="javax.xml.messaging.URLEndpoint"; |
|
64 |
|
65 protected static final Logger log = |
59 Logger.getLogger(LogDomainConstants.HTTP_CONN_DOMAIN, |
66 Logger.getLogger(LogDomainConstants.HTTP_CONN_DOMAIN, |
60 "com.sun.xml.internal.messaging.saaj.client.p2p.LocalStrings"); |
67 "com.sun.xml.internal.messaging.saaj.client.p2p.LocalStrings"); |
61 |
68 |
62 public static String defaultProxyHost = null; |
69 public static final String defaultProxyHost = null; |
63 public static int defaultProxyPort = -1; |
70 public static final int defaultProxyPort = -1; |
64 |
71 |
65 MessageFactory messageFactory = null; |
72 MessageFactory messageFactory = null; |
66 |
73 |
67 boolean closed = false; |
74 boolean closed = false; |
68 |
75 |
70 proxyHost = defaultProxyHost; |
77 proxyHost = defaultProxyHost; |
71 proxyPort = defaultProxyPort; |
78 proxyPort = defaultProxyPort; |
72 |
79 |
73 try { |
80 try { |
74 messageFactory = MessageFactory.newInstance(SOAPConstants.DYNAMIC_SOAP_PROTOCOL); |
81 messageFactory = MessageFactory.newInstance(SOAPConstants.DYNAMIC_SOAP_PROTOCOL); |
|
82 } catch (NoSuchMethodError ex) { |
|
83 //fallback to default SOAP 1.1 in this case for backward compatibility |
|
84 messageFactory = MessageFactory.newInstance(); |
75 } catch (Exception ex) { |
85 } catch (Exception ex) { |
76 log.log(Level.SEVERE, "SAAJ0001.p2p.cannot.create.msg.factory", ex); |
86 log.log(Level.SEVERE, "SAAJ0001.p2p.cannot.create.msg.factory", ex); |
77 throw new SOAPExceptionImpl("Unable to create message factory", ex); |
87 throw new SOAPExceptionImpl("Unable to create message factory", ex); |
78 } |
88 } |
79 } |
89 } |
94 log.severe("SAAJ0003.p2p.call.already.closed.conn"); |
104 log.severe("SAAJ0003.p2p.call.already.closed.conn"); |
95 throw new SOAPExceptionImpl("Connection is closed"); |
105 throw new SOAPExceptionImpl("Connection is closed"); |
96 } |
106 } |
97 |
107 |
98 Class urlEndpointClass = null; |
108 Class urlEndpointClass = null; |
|
109 ClassLoader loader = Thread.currentThread().getContextClassLoader(); |
99 |
110 |
100 try { |
111 try { |
101 urlEndpointClass = Class.forName("javax.xml.messaging.URLEndpoint"); |
112 if (loader != null) { |
102 } catch (Exception ex) { |
113 urlEndpointClass = loader.loadClass(JAXM_URLENDPOINT); |
103 //Do nothing. URLEndpoint is available only when JAXM is there. |
114 } else { |
104 log.finest("SAAJ0090.p2p.endpoint.available.only.for.JAXM"); |
115 urlEndpointClass = Class.forName(JAXM_URLENDPOINT); |
105 } |
116 } |
|
117 } catch (ClassNotFoundException ex) { |
|
118 //Do nothing. URLEndpoint is available only when JAXM is there. |
|
119 log.finest("SAAJ0090.p2p.endpoint.available.only.for.JAXM"); |
|
120 } |
106 |
121 |
107 if (urlEndpointClass != null) { |
122 if (urlEndpointClass != null) { |
108 if (urlEndpointClass.isInstance(endPoint)) { |
123 if (urlEndpointClass.isInstance(endPoint)) { |
109 String url = null; |
124 String url = null; |
110 |
125 |
637 |
652 |
638 byte[] ret = bout.toByteArray(); |
653 byte[] ret = bout.toByteArray(); |
639 |
654 |
640 return ret; |
655 return ret; |
641 } |
656 } |
642 |
657 //private static String SSL_PKG = "com.sun.net.ssl.internal.www.protocol"; |
643 private static String SSL_PKG = "com.sun.net.ssl.internal.www.protocol"; |
658 //private static String SSL_PROVIDER = |
644 private static String SSL_PROVIDER = |
659 // "com.sun.net.ssl.internal.ssl.Provider"; |
645 "com.sun.net.ssl.internal.ssl.Provider"; |
660 private static final String SSL_PKG; |
|
661 private static final String SSL_PROVIDER; |
|
662 |
|
663 |
|
664 static { |
|
665 if (isIBMVM) { |
|
666 SSL_PKG ="com.ibm.net.ssl.internal.www.protocol"; |
|
667 SSL_PROVIDER ="com.ibm.net.ssl.internal.ssl.Provider"; |
|
668 } else { |
|
669 //if not IBM VM default to Sun. |
|
670 SSL_PKG = "com.sun.net.ssl.internal.www.protocol"; |
|
671 SSL_PROVIDER ="com.sun.net.ssl.internal.ssl.Provider"; |
|
672 } |
|
673 } |
646 private void initHttps() { |
674 private void initHttps() { |
647 //if(!setHttps) { |
675 //if(!setHttps) { |
648 String pkgs = System.getProperty("java.protocol.handler.pkgs"); |
676 String pkgs = System.getProperty("java.protocol.handler.pkgs"); |
649 log.log(Level.FINE, |
677 log.log(Level.FINE, |
650 "SAAJ0053.p2p.providers", |
678 "SAAJ0053.p2p.providers", |