當前位置: 首頁>>代碼示例>>Java>>正文


Java WSDLFactory類代碼示例

本文整理匯總了Java中javax.wsdl.factory.WSDLFactory的典型用法代碼示例。如果您正苦於以下問題:Java WSDLFactory類的具體用法?Java WSDLFactory怎麽用?Java WSDLFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


WSDLFactory類屬於javax.wsdl.factory包,在下文中一共展示了WSDLFactory類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: validateVersion

import javax.wsdl.factory.WSDLFactory; //導入依賴的package包/類
void validateVersion(String wsdlUrl) {
    WSDLLocator locator = new BasicAuthWSDLLocator(wsdlUrl, null, null);
    WSDLFactory wsdlFactory;
    Definition serviceDefinition;
    try {
        wsdlFactory = WSDLFactory.newInstance();
        WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
        // avoid importing external documents
        wsdlReader.setExtensionRegistry(new WSVersionExtensionRegistry());
        serviceDefinition = wsdlReader.readWSDL(locator);
        Element versionElement = serviceDefinition
                .getDocumentationElement();
        if (!CTMGApiVersion.version.equals(versionElement.getTextContent())) {
            LOGGER.warn("Web service mismatches and the version value, expected: "
                    + CTMGApiVersion.version
                    + " and the one got from wsdl: "
                    + versionElement.getTextContent());
        }
    } catch (WSDLException e) {
        LOGGER.warn("Remote wsdl cannot be retrieved from CT_MG. [Cause: "
                + e.getMessage() + "]", e);
    }

}
 
開發者ID:servicecatalog,項目名稱:development,代碼行數:25,代碼來源:BesDAO.java

示例2: testWsdl

import javax.wsdl.factory.WSDLFactory; //導入依賴的package包/類
@Test
@RunAsClient
public void testWsdl() throws Exception
{
   URL wsdlURL = new URL(baseURL + "/jaxws-jbws2183/TestServiceImpl?wsdl");
   WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
   Definition wsdlDefinition = wsdlReader.readWSDL(wsdlURL.toString());
   assertNotNull(wsdlDefinition);
   for (Iterator<?> it = wsdlDefinition.getAllBindings().values().iterator(); it.hasNext(); )
   {
      List<?> extElements = ((Binding)it.next()).getExtensibilityElements();
      boolean found = false;
      for (int i = 0; i < extElements.size(); i++)
      {
         ExtensibilityElement extElement = (ExtensibilityElement)extElements.get(i);
         if (extElement instanceof SOAP12Binding)
            found = true;
         else if (extElement instanceof SOAPBinding)
            fail("SOAP 1.1 Binding found!");
      }
      assertTrue("SOAP 1.2 Binding not found!",found);
   }
}
 
開發者ID:jbossws,項目名稱:jbossws-cxf,代碼行數:24,代碼來源:JBWS2183TestCase.java

示例3: test

import javax.wsdl.factory.WSDLFactory; //導入依賴的package包/類
@Test
@RunAsClient
public void test() throws Exception
{
   File destDir = new File(TEST_DIR, "wsprovide" + FS + "java");
   String absOutput = destDir.getAbsolutePath();
   String command = JBOSS_HOME + FS + "bin" + FS + "wsprovide" + EXT + " -k -w -o " + absOutput + " --classpath " + CLASSES_DIR + " " + ENDPOINT_CLASS;
   Map<String, String> env = new HashMap<>();
   env.put("JAVA_OPTS", System.getProperty("additionalJvmArgs"));
   executeCommand(command, null, "wsprovide", env);

   URL wsdlURL = new File(destDir, "JBWS2528EndpointService.wsdl").toURI().toURL();
   WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
   Definition wsdlDefinition = wsdlReader.readWSDL(wsdlURL.toString());
   PortType portType = wsdlDefinition.getPortType(new QName("http://jbws2528.jaxws.ws.test.jboss.org/", "JBWS2528Endpoint"));
   Operation op = (Operation)portType.getOperations().get(0);
   @SuppressWarnings("unchecked")
   List<String> parOrder = op.getParameterOrdering();
   assertEquals("id", parOrder.get(0));
   assertEquals("Name", parOrder.get(1));
   assertEquals("Employee", parOrder.get(2));
}
 
開發者ID:jbossws,項目名稱:jbossws-cxf,代碼行數:23,代碼來源:JBWS2528TestCase.java

示例4: getWSDL11Parser

import javax.wsdl.factory.WSDLFactory; //導入依賴的package包/類
public static synchronized WSDL11Parser getWSDL11Parser(String wsdlLocation) throws WSDLException, IOException {
    WSDL11Parser parser = null;
    
    if (parsers == null) {
        parsers = new TreeMap<String, WSDL11Parser>();
    } else {
        parser = parsers.get(wsdlLocation);
    }
    
    if (parser == null) {
        WSDLFactory factory = WSDLFactory.newInstance();
        WSDLReader reader = factory.newWSDLReader();
        reader.setFeature("javax.wsdl.verbose", false);
        Definition definition = reader.readWSDL(wsdlLocation);

        parser = new WSDL11Parser(definition);
        
        parsers.put(wsdlLocation, parser);
    }
    
    return parser;
}
 
開發者ID:apache,項目名稱:incubator-taverna-common-activities,代碼行數:23,代碼來源:WSDL11Parser.java

示例5: readWSDL

import javax.wsdl.factory.WSDLFactory; //導入依賴的package包/類
/**
 * Read the WSDL document and create a WSDL Definition.
 *
 * @param wsdlLocation location pointing to a WSDL XML definition.
 * @return the Definition.
 * @throws WSDLException If unable to read the WSDL
 */
public static Definition readWSDL(final String wsdlLocation) throws WSDLException {
    InputStream inputStream = null;
    try {
        URL url = getURL(wsdlLocation);
        inputStream = url.openStream();
        InputSource source = new InputSource(inputStream);
        source.setSystemId(url.toString());
        Document wsdlDoc = XMLHelper.getDocument(source);
        WSDLFactory wsdlFactory = WSDLFactory.newInstance();
        WSDLReader reader = wsdlFactory.newWSDLReader();
        reader.setFeature("javax.wsdl.verbose", false);
        return reader.readWSDL(url.toString(), wsdlDoc);
    } catch (Exception e) {
        throw new WSDLException(WSDLException.OTHER_ERROR,
                SOAPMessages.MESSAGES.unableToReadWSDL(wsdlLocation), e);
    } finally {
        if (inputStream != null) {
            try {
                inputStream.close();
            } catch (IOException ioe) {
                LOGGER.error(ioe);
            }
        }
    }
}
 
開發者ID:jboss-switchyard,項目名稱:switchyard,代碼行數:33,代碼來源:WSDLUtil.java

示例6: toWSDL

import javax.wsdl.factory.WSDLFactory; //導入依賴的package包/類
/**
 * Generates WSDL-document from this web service model
 * @param dispatchContext dispatch context where nested service models
 *        can be found
 * @param locationURI SOAP location URI
 * @return WSDL-document object model
 * @throws GenericServiceException if exception encountered when
 *         getting nested service model
 * @throws SAXException if XML-schema could not be parsed
 * @throws WSDLException if XML-schema type could not be found
 */
public Document toWSDL(DispatchContext dispatchContext, String locationURI)  throws GenericServiceException, ParserConfigurationException,
           SAXException, TransformerException, WSDLException {
    if (this.wsdl != null) {
        return this.wsdl;
    }
    WSDLFactory factory = WSDLFactory.newInstance();
    Definition definition = factory.newDefinition();
    definition.setTargetNamespace(namespace);
    definition.addNamespace("tns", namespace);
    definition.addNamespace("xsd", ModelService.XSD);
    definition.addNamespace("soap", SOAP);
    definition.addNamespace("wsse", WSSE);
    
    this.wsdl = modelService.generateWSDL(dispatchContext.getDelegator(), locationURI);
    SchemaImpl schemaImpl = makeSchemaImpl(wsdl, namespace);
    
    Element schema = schemaImpl.getElement();
    wsdlSchema = makeValidationSchema(schema);
    return this.wsdl;
}
 
開發者ID:gildaslemoal,項目名稱:elpi,代碼行數:32,代碼來源:SoapService.java

示例7: compressAndEncode

import javax.wsdl.factory.WSDLFactory; //導入依賴的package包/類
/**
    * Gets WSDL as ZLIB-compressed and Base64-encoded String.
    * Use ZipStream -> InflaterStream -> Base64Stream to read.
    * @return WSDL as String object. Or null in case errors/not possible to create object.
    * @throws WSDLException 
    * @throws IOException 
    */
public static String compressAndEncode(Definition definition) throws IOException, WSDLException {
   	ByteArrayOutputStream wsdlOs = new ByteArrayOutputStream();
       OutputStream os = compressAndEncodeStream(wsdlOs);
       ZipOutputStream zipOs = new ZipOutputStream(os);
       try {
       	ZipEntry zipEntry = new ZipEntry("main.wsdl");
		zipOs.putNextEntry(zipEntry);
           WSDLFactory.newInstance().newWSDLWriter().writeWSDL(definition, zipOs);
           appendImportDifinitions(definition, zipOs);
	} finally {
           if (null != zipOs) {
               zipOs.close();
           }
       }
       return wsdlOs.toString();
   }
 
開發者ID:Talend,項目名稱:tesb-studio-se,代碼行數:24,代碼來源:CompressAndEncodeTool.java

示例8: generateWSDL

import javax.wsdl.factory.WSDLFactory; //導入依賴的package包/類
/**
 * generates the wsdl for this service
 *
 * @throws SchemaGenerationException
 */
public Definition generateWSDL() throws SchemaGenerationException {
    try {
        this.wsdlDefinition = WSDLFactory.newInstance().newDefinition();
        //TODO: keep the namespace prefix map if needed
        this.wsdlDefinition.addNamespace(Util.getNextNamespacePrefix(), this.service.getNamespace());
        this.wsdlDefinition.addNamespace(Util.getNextNamespacePrefix(), "http://schemas.xmlsoap.org/wsdl/soap/");
        this.wsdlDefinition.setTargetNamespace(this.service.getNamespace());
        // first generate the schemas
        generateTypes();
        generatePortType();
        generateBindings();
        generateService();
        generateOperationsAndMessages();
        return this.wsdlDefinition;
    } catch (WSDLException e) {
        throw new SchemaGenerationException("Error in creating a new wsdl definition", e);
    }
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:24,代碼來源:WSDL11DefinitionBuilder.java

示例9: generateBindings

import javax.wsdl.factory.WSDLFactory; //導入依賴的package包/類
private void generateBindings() throws SchemaGenerationException {
    this.httpSoapBinding = this.wsdlDefinition.createBinding();
    this.httpSoapBinding.setUndefined(false);
    this.httpSoapBinding.setQName(new QName(this.service.getNamespace(),
            this.service.getName() + "HttpSoapBinding"));
    this.httpSoapBinding.setPortType(this.portType);
    // add soap transport parts
    ExtensionRegistry extensionRegistry = null;
    try {
        extensionRegistry = WSDLFactory.newInstance().newPopulatedExtensionRegistry();
        SOAPBinding soapBinding = (SOAPBinding) extensionRegistry.createExtension(
                Binding.class, new QName("http://schemas.xmlsoap.org/wsdl/soap/", "binding"));
        soapBinding.setTransportURI("http://schemas.xmlsoap.org/soap/http");
        soapBinding.setStyle("document");
        this.httpSoapBinding.addExtensibilityElement(soapBinding);
    } catch (WSDLException e) {
        throw new SchemaGenerationException("Can not crete a wsdl factory");
    }
    this.wsdlDefinition.addBinding(this.httpSoapBinding);
    this.wsdlDefinition.getBindings().put(this.httpSoapBinding.getQName(),
            this.httpSoapBinding);
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:23,代碼來源:WSDL11DefinitionBuilder.java

示例10: generateService

import javax.wsdl.factory.WSDLFactory; //導入依賴的package包/類
private void generateService()
        throws SchemaGenerationException {
    // now add the binding portType and messages corresponding to every operation
    javax.wsdl.Service service = this.wsdlDefinition.createService();
    service.setQName(new QName(this.service.getNamespace(), this.service.getName()));

    Port port = this.wsdlDefinition.createPort();
    port.setName(this.service.getName() + "HttpSoapPort");
    port.setBinding(this.httpSoapBinding);
    ExtensionRegistry extensionRegistry = null;
    try {
        extensionRegistry = WSDLFactory.newInstance().newPopulatedExtensionRegistry();
        SOAPAddress soapAddress = (SOAPAddress) extensionRegistry.createExtension(
                Port.class, new QName("http://schemas.xmlsoap.org/wsdl/soap/", "address"));
        soapAddress.setLocationURI("http://localhost:8080/axis2/services/" + this.service.getName());
        port.addExtensibilityElement(soapAddress);
    } catch (WSDLException e) {
        throw new SchemaGenerationException("Can not crete a wsdl factory");
    }
    service.addPort(port);
    this.wsdlDefinition.addService(service);
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:23,代碼來源:WSDL11DefinitionBuilder.java

示例11: createWSDLDefinition

import javax.wsdl.factory.WSDLFactory; //導入依賴的package包/類
static Definition createWSDLDefinition(URL wsdlURL) {
    Definition wsdlDefinition = null;
    try {
        WSDLFactory factory = WSDLFactory.newInstance();
        WSDLReader reader = factory.newWSDLReader();
        wsdlDefinition = reader.readWSDL(wsdlURL.toString());
    }
    catch (Exception e) {
        TestLogger.logger
                .debug("*** ERROR ***: Caught exception trying to create WSDL Definition: " +
                        e);
        e.printStackTrace();
    }

    return wsdlDefinition;
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:17,代碼來源:DescriptionTestUtils2.java

示例12: printDefinitionObject

import javax.wsdl.factory.WSDLFactory; //導入依賴的package包/類
/**
 * Prints the given definition object.
 * @param definition The definition.
 * @param out The output stream the data to be written to. NOTE: the stream is not closed after the operation, 
 *            it is the responsibility of the caller to close the stream after usage.
 * @param requestIP The host IP address.
 * @throws AxisFault
 * @throws WSDLException
 */
private synchronized void printDefinitionObject(Definition definition, OutputStream out,
		String requestIP) throws AxisFault, WSDLException {
       // Synchronized this method to fix the NullPointer exception occurred when load is high.
       // This error happens because wsdl4j is not thread safe and we are using same WSDL Definition for printing the
       // WSDL.
       // Please refer AXIS2-4511,AXIS2-4517,AXIS2-3276.
	if (isModifyUserWSDLPortAddress()) {
		setPortAddress(definition, requestIP);
	}
	if (!wsdlImportLocationAdjusted) {
		changeImportAndIncludeLocations(definition);
		wsdlImportLocationAdjusted = true;
	}
	WSDLWriter writer = WSDLFactory.newInstance().newWSDLWriter();
	writer.writeWSDL(definition, out);
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:26,代碼來源:AxisService.java

示例13: createWSDLDefinition

import javax.wsdl.factory.WSDLFactory; //導入依賴的package包/類
static public Definition createWSDLDefinition(URL wsdlURL) {
    Definition wsdlDefinition = null;
    try {
        WSDLFactory factory = WSDLFactory.newInstance();
        WSDLReader reader = factory.newWSDLReader();
        wsdlDefinition = reader.readWSDL(wsdlURL.toString());
        wsdlDefinition.setDocumentBaseURI(wsdlURL.toString());
    }
    catch (Exception e) {
        System.out.println(
                "*** ERROR ***: Caught exception trying to create WSDL Definition: " + e);
        e.printStackTrace();
    }

    return wsdlDefinition;
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:17,代碼來源:DescriptionTestUtils.java

示例14: readInTheWSDLFile

import javax.wsdl.factory.WSDLFactory; //導入依賴的package包/類
/**
 * Read the WSDL file
 *
 * @param uri
 * @throws WSDLException
 */
public Definition readInTheWSDLFile(final String uri) throws WSDLException {

    WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
    reader.setFeature("javax.wsdl.importDocuments", true);

    ExtensionRegistry extReg = WSDLFactory.newInstance().newPopulatedExtensionRegistry();
    extReg.registerExtensionAttributeType(Input.class,
            new QName(AddressingConstants.Final.WSAW_NAMESPACE, AddressingConstants.WSA_ACTION),
            AttributeExtensible.STRING_TYPE);
    extReg.registerExtensionAttributeType(Output.class,
            new QName(AddressingConstants.Final.WSAW_NAMESPACE, AddressingConstants.WSA_ACTION),
            AttributeExtensible.STRING_TYPE);
    reader.setExtensionRegistry(extReg);

    return reader.readWSDL(uri);
    
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:24,代碼來源:CodeGenerationEngine.java

示例15: getWSDLComparison

import javax.wsdl.factory.WSDLFactory; //導入依賴的package包/類
/**
 * 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();
    if (flow != null) {
        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);
    } else {
        return null;
    }
}
 
開發者ID:wso2,項目名稱:carbon-governance,代碼行數:30,代碼來源:ComparatorUtils.java


注:本文中的javax.wsdl.factory.WSDLFactory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。