< prev index next >

src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/client/p2p/HttpSOAPConnection.java

Print this page




  59                          "com.sun.xml.internal.messaging.saaj.client.p2p.LocalStrings");
  60 
  61 
  62     MessageFactory messageFactory = null;
  63 
  64     boolean closed = false;
  65 
  66     public HttpSOAPConnection() throws SOAPException {
  67 
  68         try {
  69             messageFactory = MessageFactory.newInstance(SOAPConstants.DYNAMIC_SOAP_PROTOCOL);
  70         } catch (NoSuchMethodError ex) {
  71             //fallback to default SOAP 1.1 in this case for backward compatibility
  72             messageFactory = MessageFactory.newInstance();
  73         } catch (Exception ex) {
  74             log.log(Level.SEVERE, "SAAJ0001.p2p.cannot.create.msg.factory", ex);
  75             throw new SOAPExceptionImpl("Unable to create message factory", ex);
  76         }
  77     }
  78 

  79     public void close() throws SOAPException {
  80         if (closed) {
  81             log.severe("SAAJ0002.p2p.close.already.closed.conn");
  82             throw new SOAPExceptionImpl("Connection already closed");
  83         }
  84 
  85         messageFactory = null;
  86         closed = true;
  87     }
  88 

  89    public SOAPMessage call(SOAPMessage message, Object endPoint)
  90         throws SOAPException {
  91         if (closed) {
  92             log.severe("SAAJ0003.p2p.call.already.closed.conn");
  93             throw new SOAPExceptionImpl("Connection is closed");
  94         }
  95 
  96         Class<?> urlEndpointClass = null;
  97         ClassLoader loader = Thread.currentThread().getContextClassLoader();
  98         try {
  99             if (loader != null) {
 100                 urlEndpointClass = loader.loadClass(JAXM_URLENDPOINT);
 101             } else {
 102                 urlEndpointClass = Class.forName(JAXM_URLENDPOINT);
 103             }
 104         } catch (ClassNotFoundException ex) {
 105             //Do nothing. URLEndpoint is available only when JAXM is there.
 106             if (log.isLoggable(Level.FINEST))
 107                 log.finest("SAAJ0090.p2p.endpoint.available.only.for.JAXM");
 108         }


 331                 }
 332 
 333             } catch (SOAPException ex) {
 334                 throw ex;
 335             } catch (Exception ex) {
 336                 log.log(Level.SEVERE,"SAAJ0010.p2p.cannot.read.resp", ex);
 337                 throw new SOAPExceptionImpl(
 338                     "Unable to read response: " + ex.getMessage());
 339             } finally {
 340                if (httpIn != null)
 341                    httpIn.close();
 342                httpConnection.disconnect();
 343             }
 344         }
 345         return response;
 346     }
 347 
 348     // Object identifies where the request should be sent.
 349     // It is required to support objects of type String and java.net.URL.
 350 

 351     public SOAPMessage get(Object endPoint) throws SOAPException {
 352         if (closed) {
 353             log.severe("SAAJ0011.p2p.get.already.closed.conn");
 354             throw new SOAPExceptionImpl("Connection is closed");
 355         }
 356         Class<?> urlEndpointClass = null;
 357 
 358         try {
 359             urlEndpointClass = Class.forName("javax.xml.messaging.URLEndpoint");
 360         } catch (Exception ex) {
 361             //Do nothing. URLEndpoint is available only when JAXM is there.
 362         }
 363 
 364         if (urlEndpointClass != null) {
 365             if (urlEndpointClass.isInstance(endPoint)) {
 366                 String url = null;
 367 
 368                 try {
 369                     Method m = urlEndpointClass.getMethod("getURL", (Class[])null);
 370                     url = (String) m.invoke(endPoint, (Object[])null);




  59                          "com.sun.xml.internal.messaging.saaj.client.p2p.LocalStrings");
  60 
  61 
  62     MessageFactory messageFactory = null;
  63 
  64     boolean closed = false;
  65 
  66     public HttpSOAPConnection() throws SOAPException {
  67 
  68         try {
  69             messageFactory = MessageFactory.newInstance(SOAPConstants.DYNAMIC_SOAP_PROTOCOL);
  70         } catch (NoSuchMethodError ex) {
  71             //fallback to default SOAP 1.1 in this case for backward compatibility
  72             messageFactory = MessageFactory.newInstance();
  73         } catch (Exception ex) {
  74             log.log(Level.SEVERE, "SAAJ0001.p2p.cannot.create.msg.factory", ex);
  75             throw new SOAPExceptionImpl("Unable to create message factory", ex);
  76         }
  77     }
  78 
  79     @Override
  80     public void close() throws SOAPException {
  81         if (closed) {
  82             log.severe("SAAJ0002.p2p.close.already.closed.conn");
  83             throw new SOAPExceptionImpl("Connection already closed");
  84         }
  85 
  86         messageFactory = null;
  87         closed = true;
  88     }
  89 
  90     @Override
  91    public SOAPMessage call(SOAPMessage message, Object endPoint)
  92         throws SOAPException {
  93         if (closed) {
  94             log.severe("SAAJ0003.p2p.call.already.closed.conn");
  95             throw new SOAPExceptionImpl("Connection is closed");
  96         }
  97 
  98         Class<?> urlEndpointClass = null;
  99         ClassLoader loader = Thread.currentThread().getContextClassLoader();
 100         try {
 101             if (loader != null) {
 102                 urlEndpointClass = loader.loadClass(JAXM_URLENDPOINT);
 103             } else {
 104                 urlEndpointClass = Class.forName(JAXM_URLENDPOINT);
 105             }
 106         } catch (ClassNotFoundException ex) {
 107             //Do nothing. URLEndpoint is available only when JAXM is there.
 108             if (log.isLoggable(Level.FINEST))
 109                 log.finest("SAAJ0090.p2p.endpoint.available.only.for.JAXM");
 110         }


 333                 }
 334 
 335             } catch (SOAPException ex) {
 336                 throw ex;
 337             } catch (Exception ex) {
 338                 log.log(Level.SEVERE,"SAAJ0010.p2p.cannot.read.resp", ex);
 339                 throw new SOAPExceptionImpl(
 340                     "Unable to read response: " + ex.getMessage());
 341             } finally {
 342                if (httpIn != null)
 343                    httpIn.close();
 344                httpConnection.disconnect();
 345             }
 346         }
 347         return response;
 348     }
 349 
 350     // Object identifies where the request should be sent.
 351     // It is required to support objects of type String and java.net.URL.
 352 
 353     @Override
 354     public SOAPMessage get(Object endPoint) throws SOAPException {
 355         if (closed) {
 356             log.severe("SAAJ0011.p2p.get.already.closed.conn");
 357             throw new SOAPExceptionImpl("Connection is closed");
 358         }
 359         Class<?> urlEndpointClass = null;
 360 
 361         try {
 362             urlEndpointClass = Class.forName("javax.xml.messaging.URLEndpoint");
 363         } catch (Exception ex) {
 364             //Do nothing. URLEndpoint is available only when JAXM is there.
 365         }
 366 
 367         if (urlEndpointClass != null) {
 368             if (urlEndpointClass.isInstance(endPoint)) {
 369                 String url = null;
 370 
 371                 try {
 372                     Method m = urlEndpointClass.getMethod("getURL", (Class[])null);
 373                     url = (String) m.invoke(endPoint, (Object[])null);


< prev index next >