public static IStatus isWSDLAccessible(URL contextURL) {
    Properties props = System.getProperties();
    String oldPropValue = props.getProperty(DEF_FACTORY_PROPERTY_NAME);

    props.setProperty(DEF_FACTORY_PROPERTY_NAME, PRIVATE_DEF_FACTORY_CLASS);

    WSDLFactory factory;
    try {
      factory = WSDLFactory.newInstance();
      WSDLReader wsdlReader = factory.newWSDLReader();
      wsdlReader.setFeature(Constants.FEATURE_VERBOSE, false);
      wsdlReader.setFeature("javax.wsdl.importDocuments", true); // $NON-NLS-1$
      String context = null;
      if (contextURL != null) context = contextURL.toString();
      wsdlReader.readWSDL(context);
    } catch (WSDLException e) {
      if (contextURL.getProtocol().equalsIgnoreCase("https")) { // $NON-NLS-1$
        return StatusUtils.warningStatus(
            JBossWSUIMessages.TesterWSDLUtils_WSDL_HTTPS_Secured_Inaccessible);
      } else {
        return StatusUtils.errorStatus(JBossWSUIMessages.TesterWSDLUtils_WSDL_Inaccessible, e);
      }
    }

    if (oldPropValue != null) {
      props.setProperty(DEF_FACTORY_PROPERTY_NAME, oldPropValue);
    } else {
      props.remove(DEF_FACTORY_PROPERTY_NAME);
    }
    return Status.OK_STATUS;
  }
Esempio n. 2
0
 public synchronized Definition get(String url) throws WSDLException {
   Definition definition = cache.get(url);
   if (definition == null) {
     WSDLReader reader = factory.newWSDLReader();
     definition = reader.readWSDL(url);
     cache.put(url, definition);
   }
   return definition;
 }
Esempio n. 3
0
  @Test
  public void testWSDLLocatorWithDefaultCatalog() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/catalog/hello_world_services.wsdl");
    assertNotNull(wsdl);

    WSDLFactory wsdlFactory = WSDLFactory.newInstance();
    WSDLReader wsdlReader = wsdlFactory.newWSDLReader();

    CatalogWSDLLocator wsdlLocator =
        new CatalogWSDLLocator(wsdl.toString(), OASISCatalogManager.getCatalogManager(null));
    wsdlReader.setFeature("javax.wsdl.verbose", false);
    wsdlReader.readWSDL(wsdlLocator);
  }
Esempio n. 4
0
  /**
   * Create the WSDL definition <javax.wsdl.Definition> from the baseURI of the WSDL
   *
   * @return {@link Definition} - WSDL4j definition constructed form the wsdl original baseuri
   * @throws APIManagementException
   * @throws WSDLException
   */
  private Definition readWSDLFile() throws APIManagementException, WSDLException {
    WSDLReader reader = getWsdlFactoryInstance().newWSDLReader();
    // switch off the verbose mode
    reader.setFeature(JAVAX_WSDL_VERBOSE_MODE, false);
    reader.setFeature("javax.wsdl.importDocuments", false);

    Definition wsdlDefinition;
    if (log.isDebugEnabled()) {
      log.debug("Reading  the WSDL. Base uri is " + baseURI);
    }
    wsdlDefinition = reader.readWSDL(baseURI);
    return wsdlDefinition;
  }
Esempio n. 5
0
  protected ServiceCatalog createDelegate() {
    DefinitionCatalog catalog = new DefinitionCatalog();
    WSDLReader reader = WsdlUtil.getFactory().newWSDLReader();

    for (int i = 0, n = locations.size(); i < n; i++) {
      String location = (String) locations.get(i);
      try {
        catalog.addDefinition(reader.readWSDL(contextURL, location));
      } catch (WSDLException e) {
        log.debug("skipping wsdl document at '" + location + "' due to '" + e.getMessage() + "'");
      }
    }
    return catalog;
  }
  /**
   * This method is used to get wsdl difference comparison.
   *
   * @param WSDLOne wsdl one.
   * @param WSDLTwo wsdl two.
   * @return Comparison object which includes the difference parameters.
   * @throws ComparisonException
   * @throws WSDLException
   * @throws RegistryException
   * @throws UnsupportedEncodingException
   */
  private Comparison getWSDLComparison(Resource WSDLOne, Resource WSDLTwo)
      throws ComparisonException, WSDLException, RegistryException, UnsupportedEncodingException {
    GovernanceDiffGeneratorFactory diffGeneratorFactory = new GovernanceDiffGeneratorFactory();
    DiffGenerator flow = diffGeneratorFactory.getDiffGenerator();
    WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();

    InputSource inputSourceOne =
        new InputSource(new ByteArrayInputStream((byte[]) WSDLOne.getContent()));
    Definition originalWSDL = wsdlReader.readWSDL(null, inputSourceOne);

    InputSource inputSourceTwo =
        new InputSource(new ByteArrayInputStream((byte[]) WSDLTwo.getContent()));
    Definition changedWSDL = wsdlReader.readWSDL(null, inputSourceTwo);

    return flow.compare(originalWSDL, changedWSDL, ComparatorConstants.WSDL_MEDIA_TYPE);
  }
Esempio n. 7
0
 public File writeDefinition(File targetDir, File defnFile) throws Exception {
   File bkFile = new File(targetDir, "bk_" + defnFile.getName());
   FileWriter writer = new FileWriter(bkFile);
   WSDLFactory factory =
       WSDLFactory.newInstance("org.apache.cxf.tools.corba.utils.TestWSDLCorbaFactoryImpl");
   WSDLReader reader = factory.newWSDLReader();
   reader.setFeature("javax.wsdl.importDocuments", false);
   ExtensionRegistry extReg = new ExtensionRegistry();
   addExtensions(extReg);
   reader.setExtensionRegistry(extReg);
   Definition wsdlDefn = reader.readWSDL(defnFile.toString());
   WSDLWriter wsdlWriter = factory.newWSDLWriter();
   wsdlWriter.writeWSDL(wsdlDefn, writer);
   writer.close();
   writer = null;
   reader = null;
   return bkFile;
 }
Esempio n. 8
0
  @Test
  public void testWSDLLocatorWithoutCatalog() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/catalog/hello_world_services.wsdl");
    assertNotNull(wsdl);

    WSDLFactory wsdlFactory = WSDLFactory.newInstance();
    WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
    wsdlReader.setFeature("javax.wsdl.verbose", false);

    OASISCatalogManager catalog = new OASISCatalogManager();
    CatalogWSDLLocator wsdlLocator = new CatalogWSDLLocator(wsdl.toString(), catalog);
    try {
      wsdlReader.readWSDL(wsdlLocator);
      fail("Test did not fail as expected");
    } catch (WSDLException e) {
      // ignore
    }
  }
  public static Definition readWSDLURL(URL contextURL, String wsdlLoc) throws WSDLException {
    Properties props = System.getProperties();
    String oldPropValue = props.getProperty(DEF_FACTORY_PROPERTY_NAME);

    props.setProperty(DEF_FACTORY_PROPERTY_NAME, PRIVATE_DEF_FACTORY_CLASS);

    WSDLFactory factory = WSDLFactory.newInstance();
    WSDLReader wsdlReader = factory.newWSDLReader();
    wsdlReader.setFeature(Constants.FEATURE_VERBOSE, false);
    wsdlReader.setFeature("javax.wsdl.importDocuments", true); // $NON-NLS-1$
    String context = null;
    if (contextURL != null) context = contextURL.toString();
    Definition def = wsdlReader.readWSDL(context, wsdlLoc);

    if (oldPropValue != null) {
      props.setProperty(DEF_FACTORY_PROPERTY_NAME, oldPropValue);
    } else {
      props.remove(DEF_FACTORY_PROPERTY_NAME);
    }
    return def;
  }
Esempio n. 10
0
 private org.apache.woden.wsdl20.Description readWSDL2File()
     throws APIManagementException, WSDLException {
   WSDLReader reader = getWsdlFactoryInstance().newWSDLReader();
   reader.setFeature(JAVAX_WSDL_VERBOSE_MODE, false);
   reader.setFeature("javax.wsdl.importDocuments", false);
   try {
     org.apache.woden.WSDLFactory wFactory = org.apache.woden.WSDLFactory.newInstance();
     org.apache.woden.WSDLReader wReader = wFactory.newWSDLReader();
     wReader.setFeature(org.apache.woden.WSDLReader.FEATURE_VALIDATION, true);
     //            wReader.setFeature(JAVAX_WSDL_VERBOSE_MODE, false);
     //            wReader.setFeature("javax.wsdl.importDocuments", false);
     return wReader.readWSDL(baseURI);
   } catch (org.apache.woden.WSDLException e) {
     String error = "Error occurred reading wsdl document.";
     log.error(error);
   }
   if (log.isDebugEnabled()) {
     log.debug("Reading  the WSDL. Base uri is " + baseURI);
   }
   return null;
 }
Esempio n. 11
0
  public void executeActivity(ProcessInstance instance) throws Exception {

    try {
      Thread.currentThread().setContextClassLoader(GlobalContext.getComponentClassLoader());

      if (getStublessInvocation()) {

        ServiceDefinition sd = getService();
        String wsdlUrl = sd.getWsdlLocation();
        WSDLReader reader = (new WSDLFactoryImpl()).newWSDLReader();
        reader.readWSDL(wsdlUrl);

        Object[] actualParameters = getActualParameters(instance);

        String endpoint = "";
        try {
          endpoint = role.getMapping(instance, getTracingTag()).getEndpoint();
        } catch (Exception e) {
          throw new UEngineException("Couldn't get the endpoint to invoke WS", e);
        }

        WSIFServiceFactory factory = WSIFServiceFactory.newInstance();

        WSIFService service = factory.getService(wsdlUrl, null, null, endpoint, null);

        WSIFPort port = service.getPort();

        WSIFOperation operation = port.createOperation(getOperationName());

        WSIFMessage input = operation.createInputMessage();
        WSIFMessage output = operation.createOutputMessage();
        WSIFMessage fault = operation.createFaultMessage();

        Message me = input.getMessageDefinition();
        Map partList = me.getParts();
        Set set = partList.keySet();

        int i = 0;
        for (Iterator iter = set.iterator(); iter.hasNext(); i++) {
          String partName = (String) iter.next();
          input.setObjectPart(partName, actualParameters[i]);
        }

        if (operation.executeRequestResponseOperation(input, output, fault)) {

          String partName = (String) output.getPartNames().next();
          Object result = output.getObjectPart(partName);

          ProcessVariable outputVar = getOutput();
          outputVar.set(instance, "", (Serializable) result);

          System.out.println("result=" + result);

        } else {
          throw new UEngineException(fault.toString());
        }
      } else {

        ServiceProvider sp = GlobalContext.getServiceProvider(getService(), getPortType());
        System.out.println(
            "role is null? "
                + role
                + " rolemapping is null?"
                + role.getMapping(instance, getTracingTag()));
        String endpoint = role.getMapping(instance, getTracingTag()).getEndpoint();
        System.out.println("invoking endpoint? " + endpoint);
        Object[] actualParameters = getActualParameters(instance);

        Object res = sp.invokeService(endpoint, operationName, actualParameters);

        if (res != null && getOutput() != null)
          instance.set("" /* getTracingTag() */, getOutput().getName(), (java.io.Serializable) res);
      }

      fireComplete(instance);

    } catch (Exception e) {
      throw new UEngineException("WebServiceActivity:: fail to replace the classloader", e);
    }
  }