Esempio n. 1
0
  public SOAPMessage get(Object endPoint) throws SOAPException {
    if (closed) {
      log.severe("SAAJ0011.p2p.get.already.closed.conn");
      throw new SOAPExceptionImpl("Connection is closed");
    }
    Class urlEndpointClass = null;

    try {
      urlEndpointClass = Class.forName("javax.xml.messaging.URLEndpoint");
    } catch (Exception ex) {
      // Do nothing. URLEndpoint is available only when JAXM is there.
    }

    if (urlEndpointClass != null) {
      if (urlEndpointClass.isInstance(endPoint)) {
        String url = null;

        try {
          Method m = urlEndpointClass.getMethod("getURL", (Class[]) null);
          url = (String) m.invoke(endPoint, (Object[]) null);
        } catch (Exception ex) {
          log.severe("SAAJ0004.p2p.internal.err");
          throw new SOAPExceptionImpl("Internal error: " + ex.getMessage());
        }
        try {
          endPoint = new URL(url);
        } catch (MalformedURLException mex) {
          log.severe("SAAJ0005.p2p.");
          throw new SOAPExceptionImpl("Bad URL: " + mex.getMessage());
        }
      }
    }

    if (endPoint instanceof java.lang.String) {
      try {
        endPoint = new URL((String) endPoint);
      } catch (MalformedURLException mex) {
        log.severe("SAAJ0006.p2p.bad.URL");
        throw new SOAPExceptionImpl("Bad URL: " + mex.getMessage());
      }
    }

    if (endPoint instanceof URL)
      try {
        SOAPMessage response = doGet((URL) endPoint);
        return response;
      } catch (Exception ex) {
        throw new SOAPExceptionImpl(ex);
      }
    else throw new SOAPExceptionImpl("Bad endPoint type " + endPoint);
  }
Esempio n. 2
0
 private static boolean checkType(
     String what, Object object, Class wrongClass, boolean isException) {
   final String type = isException ? "exception" : "object";
   final String rendered = isException ? "thrown" : "returned";
   System.out.println("For " + type + " " + rendered + " by " + what + ":");
   if (wrongClass.isInstance(object)) {
     System.out.println("TEST FAILS: " + type + " loaded by test " + "classloader");
     return false;
   }
   String className = object.getClass().getName();
   if (!className.equals(wrongClass.getName())) {
     System.out.println(
         "TEST FAILS: " + rendered + " " + type + " has wrong class name: " + className);
     return false;
   }
   System.out.println(
       "Test passes: " + rendered + " " + type + " has same class name but is not same class");
   return true;
 }
Esempio n. 3
0
  public SOAPMessage call(SOAPMessage message, Object endPoint) throws SOAPException {
    if (closed) {
      log.severe("SAAJ0003.p2p.call.already.closed.conn");
      throw new SOAPExceptionImpl("Connection is closed");
    }

    Class urlEndpointClass = null;
    ClassLoader loader = Thread.currentThread().getContextClassLoader();
    try {
      if (loader != null) {
        urlEndpointClass = loader.loadClass(JAXM_URLENDPOINT);
      } else {
        urlEndpointClass = Class.forName(JAXM_URLENDPOINT);
      }
    } catch (ClassNotFoundException ex) {
      // Do nothing. URLEndpoint is available only when JAXM is there.
      log.finest("SAAJ0090.p2p.endpoint.available.only.for.JAXM");
    }

    if (urlEndpointClass != null) {
      if (urlEndpointClass.isInstance(endPoint)) {
        String url = null;

        try {
          Method m = urlEndpointClass.getMethod("getURL", (Class[]) null);
          url = (String) m.invoke(endPoint, (Object[]) null);
        } catch (Exception ex) {
          // TBD -- exception chaining
          log.log(Level.SEVERE, "SAAJ0004.p2p.internal.err", ex);
          throw new SOAPExceptionImpl("Internal error: " + ex.getMessage());
        }
        try {
          endPoint = new URL(url);
        } catch (MalformedURLException mex) {
          log.log(Level.SEVERE, "SAAJ0005.p2p.", mex);
          throw new SOAPExceptionImpl("Bad URL: " + mex.getMessage());
        }
      }
    }

    if (endPoint instanceof java.lang.String) {
      try {
        endPoint = new URL((String) endPoint);
      } catch (MalformedURLException mex) {
        log.log(Level.SEVERE, "SAAJ0006.p2p.bad.URL", mex);
        throw new SOAPExceptionImpl("Bad URL: " + mex.getMessage());
      }
    }

    if (endPoint instanceof URL)
      try {
        SOAPMessage response = post(message, (URL) endPoint);
        return response;
      } catch (Exception ex) {
        // TBD -- chaining?
        throw new SOAPExceptionImpl(ex);
      }
    else {
      log.severe("SAAJ0007.p2p.bad.endPoint.type");
      throw new SOAPExceptionImpl("Bad endPoint type " + endPoint);
    }
  }