jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/client/p2p/HttpSOAPConnection.java
equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
48 * |
48 * |
49 */ |
49 */ |
50 class HttpSOAPConnection extends SOAPConnection { |
50 class HttpSOAPConnection extends SOAPConnection { |
51 |
51 |
52 public static final String vmVendor = SAAJUtil.getSystemProperty("java.vendor.url"); |
52 public static final String vmVendor = SAAJUtil.getSystemProperty("java.vendor.url"); |
53 private static final String sunVmVendor = "http://java.sun.com/"; |
|
54 private static final String ibmVmVendor = "http://www.ibm.com/"; |
53 private static final String ibmVmVendor = "http://www.ibm.com/"; |
55 private static final boolean isSunVM = sunVmVendor.equals(vmVendor) ? true: false; |
|
56 private static final boolean isIBMVM = ibmVmVendor.equals(vmVendor) ? true : false; |
54 private static final boolean isIBMVM = ibmVmVendor.equals(vmVendor) ? true : false; |
57 private static final String JAXM_URLENDPOINT="javax.xml.messaging.URLEndpoint"; |
55 private static final String JAXM_URLENDPOINT="javax.xml.messaging.URLEndpoint"; |
58 |
56 |
59 protected static final Logger log = |
57 protected static final Logger log = |
60 Logger.getLogger(LogDomainConstants.HTTP_CONN_DOMAIN, |
58 Logger.getLogger(LogDomainConstants.HTTP_CONN_DOMAIN, |
93 if (closed) { |
91 if (closed) { |
94 log.severe("SAAJ0003.p2p.call.already.closed.conn"); |
92 log.severe("SAAJ0003.p2p.call.already.closed.conn"); |
95 throw new SOAPExceptionImpl("Connection is closed"); |
93 throw new SOAPExceptionImpl("Connection is closed"); |
96 } |
94 } |
97 |
95 |
98 Class urlEndpointClass = null; |
96 Class<?> urlEndpointClass = null; |
99 ClassLoader loader = Thread.currentThread().getContextClassLoader(); |
97 ClassLoader loader = Thread.currentThread().getContextClassLoader(); |
100 try { |
98 try { |
101 if (loader != null) { |
99 if (loader != null) { |
102 urlEndpointClass = loader.loadClass(JAXM_URLENDPOINT); |
100 urlEndpointClass = loader.loadClass(JAXM_URLENDPOINT); |
103 } else { |
101 } else { |
196 if (message.saveRequired()) |
194 if (message.saveRequired()) |
197 message.saveChanges(); |
195 message.saveChanges(); |
198 |
196 |
199 MimeHeaders headers = message.getMimeHeaders(); |
197 MimeHeaders headers = message.getMimeHeaders(); |
200 |
198 |
201 Iterator it = headers.getAllHeaders(); |
199 Iterator<?> it = headers.getAllHeaders(); |
202 boolean hasAuth = false; // true if we find explicit Auth header |
200 boolean hasAuth = false; // true if we find explicit Auth header |
203 while (it.hasNext()) { |
201 while (it.hasNext()) { |
204 MimeHeader header = (MimeHeader) it.next(); |
202 MimeHeader header = (MimeHeader) it.next(); |
205 |
203 |
206 String[] values = headers.getHeader(header.getName()); |
204 String[] values = headers.getHeader(header.getName()); |
207 if (values.length == 1) |
205 if (values.length == 1) |
208 httpConnection.setRequestProperty( |
206 httpConnection.setRequestProperty( |
209 header.getName(), |
207 header.getName(), |
210 header.getValue()); |
208 header.getValue()); |
211 else { |
209 else { |
212 StringBuffer concat = new StringBuffer(); |
210 StringBuilder concat = new StringBuilder(); |
213 int i = 0; |
211 int i = 0; |
214 while (i < values.length) { |
212 while (i < values.length) { |
215 if (i != 0) |
213 if (i != 0) |
216 concat.append(','); |
214 concat.append(','); |
217 concat.append(values[i]); |
215 concat.append(values[i]); |
353 public SOAPMessage get(Object endPoint) throws SOAPException { |
351 public SOAPMessage get(Object endPoint) throws SOAPException { |
354 if (closed) { |
352 if (closed) { |
355 log.severe("SAAJ0011.p2p.get.already.closed.conn"); |
353 log.severe("SAAJ0011.p2p.get.already.closed.conn"); |
356 throw new SOAPExceptionImpl("Connection is closed"); |
354 throw new SOAPExceptionImpl("Connection is closed"); |
357 } |
355 } |
358 Class urlEndpointClass = null; |
356 Class<?> urlEndpointClass = null; |
359 |
357 |
360 try { |
358 try { |
361 urlEndpointClass = Class.forName("javax.xml.messaging.URLEndpoint"); |
359 urlEndpointClass = Class.forName("javax.xml.messaging.URLEndpoint"); |
362 } catch (Exception ex) { |
360 } catch (Exception ex) { |
363 //Do nothing. URLEndpoint is available only when JAXM is there. |
361 //Do nothing. URLEndpoint is available only when JAXM is there. |
439 httpConnection.setRequestMethod("GET"); |
437 httpConnection.setRequestMethod("GET"); |
440 |
438 |
441 httpConnection.setDoOutput(true); |
439 httpConnection.setDoOutput(true); |
442 httpConnection.setDoInput(true); |
440 httpConnection.setDoInput(true); |
443 httpConnection.setUseCaches(false); |
441 httpConnection.setUseCaches(false); |
444 httpConnection.setFollowRedirects(true); |
442 httpConnection.setInstanceFollowRedirects(true); |
445 |
443 |
446 httpConnection.connect(); |
444 httpConnection.connect(); |
447 |
445 |
448 try { |
446 try { |
449 |
447 |
589 System.setProperty("java.protocol.handler.pkgs", pkgs); |
587 System.setProperty("java.protocol.handler.pkgs", pkgs); |
590 if (log.isLoggable(Level.FINE)) |
588 if (log.isLoggable(Level.FINE)) |
591 log.log(Level.FINE, "SAAJ0054.p2p.set.providers", |
589 log.log(Level.FINE, "SAAJ0054.p2p.set.providers", |
592 new String[] { pkgs }); |
590 new String[] { pkgs }); |
593 try { |
591 try { |
594 Class c = Class.forName(SSL_PROVIDER); |
592 Class<?> c = Class.forName(SSL_PROVIDER); |
595 Provider p = (Provider) c.newInstance(); |
593 Provider p = (Provider) c.newInstance(); |
596 Security.addProvider(p); |
594 Security.addProvider(p); |
597 if (log.isLoggable(Level.FINE)) |
595 if (log.isLoggable(Level.FINE)) |
598 log.log(Level.FINE, "SAAJ0055.p2p.added.ssl.provider", |
596 log.log(Level.FINE, "SAAJ0055.p2p.added.ssl.provider", |
599 new String[] { SSL_PROVIDER }); |
597 new String[] { SSL_PROVIDER }); |