Examples of JavaToWSDL


Examples of org.jboss.ws.tools.JavaToWSDL

    * @throws IOException
    */
   public void handleJavaToWSDLGeneration(Configuration config, String outDir) throws IOException
   {
      JavaToWSDLConfig j2wc = config.getJavaToWSDLConfig(false);
      JavaToWSDL jwsdl = new JavaToWSDL(Constants.NS_WSDL11);
      jwsdl.setServiceName(j2wc.serviceName);
      jwsdl.setTargetNamespace(j2wc.targetNamespace);
      jwsdl.setTypeNamespace(j2wc.typeNamespace);
      jwsdl.setOperationMap(j2wc.operations);

      if ("document".equals(j2wc.wsdlStyle))
         jwsdl.setStyle(Style.DOCUMENT);
      else if ("rpc".equals(j2wc.wsdlStyle))
         jwsdl.setStyle(Style.RPC);
      else throw new WSException("Unrecognized Style:" + j2wc.wsdlStyle);

      if ("wrapped".equals(j2wc.parameterStyle))
         jwsdl.setParameterStyle(ParameterStyle.WRAPPED);
      else if ("bare".equals(j2wc.parameterStyle))
         jwsdl.setParameterStyle(ParameterStyle.BARE);
      else throw new WSException("Unrecognized Parameter Style:" + j2wc.parameterStyle);

      Class endpointClass = loadClass(j2wc.endpointName);

      if (endpointClass == null)
         throw new WSException("Endpoint " + j2wc.endpointName + " cannot be loaded");

      //Take care of passing global config details
      GlobalConfig gcfg = config.getGlobalConfig(false);
      if (gcfg != null)
      {
         if (gcfg.packageNamespaceMap != null)
            jwsdl.setPackageNamespaceMap(gcfg.packageNamespaceMap);
      }
      WSDLDefinitions wsdl = jwsdl.generate(endpointClass);
      //Create the WSDL Directory
      createDir(outDir + "/wsdl");
      String wsdlPath = outDir + "/wsdl/" + j2wc.serviceName + ".wsdl";
      //Generate the WSDL
      Writer fw = IOUtils.getCharsetFileWriter(new File(wsdlPath), Constants.DEFAULT_XML_CHARSET);
      new WSDLWriter(wsdl).write(fw, Constants.DEFAULT_XML_CHARSET);
      fw.close();

      //Generate the Mapping File
      if (j2wc.mappingFileNeeded)
      {
         UnifiedMetaData unifiedMetaData = jwsdl.getUnifiedMetaData();
         JavaWsdlMapping mapping = jwsdl.getJavaWsdlMapping();

         createWrapperTypes(j2wc, outDir, unifiedMetaData, mapping, endpointClass);
         Writer writer = IOUtils.getCharsetFileWriter(new File(outDir + "/" + j2wc.mappingFileName), Constants.DEFAULT_XML_CHARSET);
         writer.write(Constants.XML_HEADER);
         writer.write(DOMWriter.printNode(DOMUtils.parse(mapping.serialize()), true));
View Full Code Here

Examples of org.jboss.ws.tools.JavaToWSDL

    * @throws IOException
    */
   public void handleJavaToWSDLGeneration(Configuration config, String outDir) throws IOException
   {
      JavaToWSDLConfig j2wc = config.getJavaToWSDLConfig(false);
      JavaToWSDL jwsdl = new JavaToWSDL(Constants.NS_WSDL11);
      jwsdl.setServiceName(j2wc.serviceName);
      jwsdl.setTargetNamespace(j2wc.targetNamespace);
      jwsdl.setTypeNamespace(j2wc.typeNamespace);
      jwsdl.setOperationMap(j2wc.operations);

      if ("document".equals(j2wc.wsdlStyle))
         jwsdl.setStyle(Style.DOCUMENT);
      else if ("rpc".equals(j2wc.wsdlStyle))
         jwsdl.setStyle(Style.RPC);
      else throw new WSException("Unrecognized Style:" + j2wc.wsdlStyle);

      if ("wrapped".equals(j2wc.parameterStyle))
         jwsdl.setParameterStyle(ParameterStyle.WRAPPED);
      else if ("bare".equals(j2wc.parameterStyle))
         jwsdl.setParameterStyle(ParameterStyle.BARE);
      else throw new WSException("Unrecognized Parameter Style:" + j2wc.parameterStyle);

      Class endpointClass = loadClass(j2wc.endpointName);

      if (endpointClass == null)
         throw new WSException("Endpoint " + j2wc.endpointName + " cannot be loaded");

      //Take care of passing global config details
      GlobalConfig gcfg = config.getGlobalConfig(false);
      if (gcfg != null)
      {
         if (gcfg.packageNamespaceMap != null)
            jwsdl.setPackageNamespaceMap(gcfg.packageNamespaceMap);
      }
      WSDLDefinitions wsdl = jwsdl.generate(endpointClass);
      //Create the WSDL Directory
      createDir(outDir + "/wsdl");
      String wsdlPath = outDir + "/wsdl/" + j2wc.serviceName + ".wsdl";
      //Generate the WSDL
      Writer fw = IOUtils.getCharsetFileWriter(new File(wsdlPath), Constants.DEFAULT_XML_CHARSET);
      new WSDLWriter(wsdl).write(fw, Constants.DEFAULT_XML_CHARSET);
      fw.close();

      //Generate the Mapping File
      if (j2wc.mappingFileNeeded)
      {
         UnifiedMetaData unifiedMetaData = jwsdl.getUnifiedMetaData();
         JavaWsdlMapping mapping = jwsdl.getJavaWsdlMapping();

         createWrapperTypes(j2wc, outDir, unifiedMetaData, mapping, endpointClass);
         Writer writer = IOUtils.getCharsetFileWriter(new File(outDir + "/" + j2wc.mappingFileName), Constants.DEFAULT_XML_CHARSET);
         writer.write(Constants.XML_HEADER);
         writer.write(DOMWriter.printNode(DOMUtils.parse(mapping.serialize()), true));
View Full Code Here

Examples of org.jboss.ws.tools.JavaToWSDL

   }

   protected WSDLDefinitions generateWSDL(Class seiClass, String serviceName, String wsdlPath, String targetNamespace, String typeNamespace, Style style, Map featureMap)
         throws IOException
   {
      JavaToWSDL jwsdl = new JavaToWSDL(Constants.NS_WSDL11);
      jwsdl.setServiceName(serviceName);
      jwsdl.setTargetNamespace(targetNamespace);
      jwsdl.setTypeNamespace(typeNamespace);
      jwsdl.setStyle(style);
      //Add the features
      Iterator keys = featureMap.keySet().iterator();
      while (keys.hasNext())
      {
         String key = (String)keys.next();
         Boolean value = (Boolean)featureMap.get(key);
         jwsdl.addFeature(key, value.booleanValue());
      }
      WSDLDefinitions wsdl = jwsdl.generate(seiClass);
      typeMapping = jwsdl.getTypeMapping();
      return wsdl;
   }
View Full Code Here

Examples of org.jboss.ws.tools.JavaToWSDL

      File wsdlDir = new File("./tools/wsdl-out");
      wsdlDir.mkdirs();
     
      String sname = WSDLUtils.getInstance().getJustClassName(seiClass) + "Service";
      String wsdlPath = wsdlDir + "/" + sname + ".wsdl";
      JavaToWSDL jwsdl = new JavaToWSDL(Constants.NS_WSDL11);
      jwsdl.setServiceName(sname);
      jwsdl.setTargetNamespace("http://org.jboss.ws");
      jwsdl.addFeature(WSToolsConstants.WSTOOLS_FEATURE_RESTRICT_TO_TARGET_NS, true);
      jwsdl.setStyle(Style.RPC);
      WSDLDefinitions wsdl = jwsdl.generate(seiClass);

      Writer fw = IOUtils.getCharsetFileWriter(new File(wsdlPath), Constants.DEFAULT_XML_CHARSET);
      new WSDLWriter(wsdl).write(fw, Constants.DEFAULT_XML_CHARSET);
      fw.close();
View Full Code Here

Examples of org.jboss.ws.tools.JavaToWSDL

     
      String sname = WSDLUtils.getJustClassName(seiClass) + "Service";
      String wsdlPath = wsdlDir + "/" + sname + "JBWS1645.wsdl";
      String targetNamespace = "http://org.jboss.ws";
      Style style = Style.DOCUMENT;
      JavaToWSDL jwsdl = new JavaToWSDL(Constants.NS_WSDL11);
      jwsdl.setServiceName(sname);
      jwsdl.setTargetNamespace(targetNamespace);
      jwsdl.addFeature(WSToolsConstants.WSTOOLS_FEATURE_RESTRICT_TO_TARGET_NS, true);
      jwsdl.setStyle(style);
     
      //manually generate the umd using tools
      UnifiedMetaData umd = new ToolsUnifiedMetaDataBuilder(seiClass, targetNamespace,
            null, sname, style, null, null).getUnifiedMetaData();
      jwsdl.setUmd(umd);
     
      //manually add policies to the umd
      ServiceMetaData serviceMetaData = umd.getServices().get(0);
      EndpointMetaData epMetaData = serviceMetaData.getEndpoints().get(0);
      addPolicy(new File("resources/tools/jbws1645/PortPolicy.txt"), PolicyScopeLevel.WSDL_PORT, epMetaData);
      addPolicy(new File("resources/tools/jbws1645/PortTypePolicy.txt"), PolicyScopeLevel.WSDL_PORT_TYPE, epMetaData);
      addPolicy(new File("resources/tools/jbws1645/BindingPolicy.txt"), PolicyScopeLevel.WSDL_BINDING, epMetaData);
     
      //generate the wsdl definitions and write the wsdl file
      WSDLDefinitions wsdl = jwsdl.generate(seiClass);
     
      //performe some trivial checks on wsdl definitions
      assertEquals(1, wsdl.getServices()[0].getEndpoints()[0].getExtensibilityElements(
            Constants.WSDL_ELEMENT_POLICYREFERENCE).size());
      assertNotNull(wsdl.getInterfaces()[0].getProperty(Constants.WSDL_PROPERTY_POLICYURIS));
View Full Code Here

Examples of org.jboss.ws.tools.JavaToWSDL

     
      String sname = WSDLUtils.getJustClassName(seiClass) + "Service-Multiple";
      String wsdlPath = wsdlDir + "/" + sname + "JBWS1645-Multiple.wsdl";
      String targetNamespace = "http://org.jboss.ws";
      Style style = Style.DOCUMENT;
      JavaToWSDL jwsdl = new JavaToWSDL(Constants.NS_WSDL11);
      jwsdl.setServiceName(sname);
      jwsdl.setTargetNamespace(targetNamespace);
      jwsdl.addFeature(WSToolsConstants.WSTOOLS_FEATURE_RESTRICT_TO_TARGET_NS, true);
      jwsdl.setStyle(style);
     
      //manually generate the umd using tools
      UnifiedMetaData umd = new ToolsUnifiedMetaDataBuilder(seiClass, targetNamespace,
            null, sname, style, null, null).getUnifiedMetaData();
      jwsdl.setUmd(umd);
     
      //manually add policies to the umd
      ServiceMetaData serviceMetaData = umd.getServices().get(0);
      EndpointMetaData epMetaData = serviceMetaData.getEndpoints().get(0);
      addPolicy(new File("resources/tools/jbws1645/PortPolicy.txt"), PolicyScopeLevel.WSDL_PORT, epMetaData);
      addPolicy(new File("resources/tools/jbws1645/PortPolicy2.txt"), PolicyScopeLevel.WSDL_PORT, epMetaData);
      addPolicy(new File("resources/tools/jbws1645/PortTypePolicy2.txt"), PolicyScopeLevel.WSDL_PORT_TYPE, epMetaData);
      addPolicy(new File("resources/tools/jbws1645/PortTypePolicy.txt"), PolicyScopeLevel.WSDL_PORT_TYPE, epMetaData);
      addPolicy(new File("resources/tools/jbws1645/BindingPolicy.txt"), PolicyScopeLevel.WSDL_BINDING, epMetaData);
      addPolicy(new File("resources/tools/jbws1645/BindingPolicy2.txt"), PolicyScopeLevel.WSDL_BINDING, epMetaData);
     
      //generate the wsdl definitions and write the wsdl file
      WSDLDefinitions wsdl = jwsdl.generate(seiClass);
     
      //performe some trivial checks on wsdl definitions
      assertEquals(2, wsdl.getServices()[0].getEndpoints()[0].getExtensibilityElements(
            Constants.WSDL_ELEMENT_POLICYREFERENCE).size());
      assertNotNull(wsdl.getInterfaces()[0].getProperty(Constants.WSDL_PROPERTY_POLICYURIS));
View Full Code Here

Examples of org.jboss.ws.tools.JavaToWSDL

   {
      Class seiClass = TrivialService.class;
      String wsdlDir = "tools/";
      String sname = "SampleService";
      String wsdlPath = wsdlDir+ "/" + sname + ".wsdl";
      JavaToWSDL jwsdl = new JavaToWSDL(Constants.NS_WSDL11);
      jwsdl.setServiceName(sname);
      jwsdl.setTargetNamespace("http://org.jboss.ws/samples");
      jwsdl.setTypeNamespace("http://org.jboss.ws/samples/types");
      jwsdl.setStyle(Style.DOCUMENT);
      jwsdl.addFeature(WSToolsConstants.WSTOOLS_FEATURE_RESTRICT_TO_TARGET_NS, true);
      WSDLDefinitions wsdl = jwsdl.generate(seiClass);

      Writer fw = IOUtils.getCharsetFileWriter(new File(wsdlPath), Constants.DEFAULT_XML_CHARSET);
      new WSDLWriter(wsdl).write(fw, Constants.DEFAULT_XML_CHARSET);
      fw.close();
View Full Code Here

Examples of org.jboss.ws.tools.JavaToWSDL

      }
   }

   public void testStandardHoldersJavaToWsdl() throws Exception
   {
      JavaToWSDL jwsdl = new JavaToWSDL(Constants.NS_WSDL11);
      jwsdl.setServiceName("HolderService");
      jwsdl.setTargetNamespace("http://jboss.org/test");
      jwsdl.addFeature(WSToolsConstants.WSTOOLS_FEATURE_RESTRICT_TO_TARGET_NS, true);
      jwsdl.setStyle(Style.RPC);
      WSDLDefinitions wsdl = jwsdl.generate(HoldersServiceInterface.class);

      //Generate the wsdl
      String wsdlDir = "tools/";
      String wsdlPath = wsdlDir+ "/HolderService.wsdl";
      Writer fw = IOUtils.getCharsetFileWriter(new File(wsdlPath), Constants.DEFAULT_XML_CHARSET);
View Full Code Here

Examples of org.jboss.ws.tools.JavaToWSDL

    */
   public void testMultiXSD() throws Exception
   {
      String seiName = "org.jboss.test.ws.tools.assertions.sei.MultiXSDInvalidInterface";
      Class seiClass = loadClass(seiName);
      JavaToWSDL jwsdl = new JavaToWSDL(Constants.NS_WSDL11);
      jwsdl.setTargetNamespace("http://org.jboss.ws/types");
      jwsdl.setServiceName(WSDLUtils.getInstance().getJustClassName(seiClass) + "Service");
      try
      {
         jwsdl.generate(loadClass(seiName));
         fail("Test should have failed");
      }
      catch (WSException is)
      {
         //pass
View Full Code Here

Examples of org.jboss.ws.tools.JavaToWSDL

    * @throws Exception
    */
   private void assertWSDL11Test(Class seiClass) throws Exception
   {
      String seiName = seiClass.getName();
      JavaToWSDL jwsdl = new JavaToWSDL(Constants.NS_WSDL11);
      jwsdl.setTargetNamespace("http://org.jboss.ws/types");
      jwsdl.setServiceName(WSDLUtils.getInstance().getJustClassName(seiClass) + "Service");
      try
      {
         jwsdl.generate(loadClass(seiName));
         fail("Test should have failed");
      }
      catch (IllegalArgumentException iae)
      {
         //pass
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.