com.predic8.wsdl.WSDLParser Java Examples

The following examples show how to use com.predic8.wsdl.WSDLParser. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WSDLResource.java    From irontest with Apache License 2.0 6 votes vote down vote up
@GET @Path("/{wsdlUrl}/bindings")
public List<WSDLBinding> getWSDLBindings(@PathParam("wsdlUrl") String wsdlUrl) throws UnsupportedEncodingException {
    List<WSDLBinding> result = new ArrayList<WSDLBinding>();
    WSDLParser parser = new WSDLParser();
    parser.setResourceResolver(new SSLTrustedExternalResolver());
    Definitions definition = parser.parse(wsdlUrl);
    for (Binding binding: definition.getBindings()) {
        List<String> operationNames = new ArrayList<String>();
        for (BindingOperation operation: binding.getOperations()) {
            operationNames.add(operation.getName());
        }
        result.add(new WSDLBinding(binding.getName(), operationNames));
    }

    return result;
}
 
Example #2
Source File: WSDLCustomParser.java    From zap-extensions with Apache License 2.0 6 votes vote down vote up
public boolean canBeWSDLparsed(String content) {
    if (content == null || content.trim().length() <= 0) {
        return false;
    } else {
        // WSDL parsing.
        WSDLParser parser = new WSDLParser();
        try {
            InputStream contentI = new ByteArrayInputStream(content.getBytes("UTF-8"));
            parser.parse(contentI);
            contentI.close();
            return true;
        } catch (Exception e) {
            return false;
        }
    }
}
 
Example #3
Source File: WSDLCustomParser.java    From zap-extensions with Apache License 2.0 6 votes vote down vote up
private void parseWSDLFile(File file) {
    if (file == null) return;
    try {
        if (View.isInitialised()) {
            // Switch to the output panel, if in GUI mode
            View.getSingleton().getOutputPanel().setTabFocus();
        }

        // WSDL file parsing.
        WSDLParser parser = new WSDLParser();
        final String path = file.getAbsolutePath();
        Definitions wsdl = parser.parse(path);
        parseWSDL(wsdl, true);

    } catch (ResourceDownloadException rde) {
        String exMsg =
                Constant.messages.getString(
                        "soap.topmenu.tools.importWSDL.fail", file.getAbsolutePath());
        LOG.warn(exMsg);
        if (View.isInitialised()) {
            View.getSingleton().showWarningDialog(exMsg);
        }
    } catch (Exception e) {
        LOG.error(e.getMessage(), e);
    }
}
 
Example #4
Source File: WSDLCustomParser.java    From zap-extensions with Apache License 2.0 6 votes vote down vote up
private boolean parseWSDLContent(String content, boolean sendMessages) {
    if (content == null || content.trim().length() <= 0) {
        return false;
    } else {
        // WSDL parsing.
        WSDLParser parser = new WSDLParser();
        try {
            InputStream contentI = new ByteArrayInputStream(content.getBytes("UTF-8"));
            Definitions wsdl = parser.parse(contentI);
            contentI.close();
            parseWSDL(wsdl, sendMessages);
            return true;
        } catch (Exception e) {
            LOG.error("There was an error while parsing WSDL content. ", e);
            return false;
        }
    }
}
 
Example #5
Source File: WSDLResource.java    From irontest with Apache License 2.0 5 votes vote down vote up
@GET @Path("/{wsdlUrl}/bindings/{bindingName}/operations/{operationName}")
public SOAPOperationInfo getOperationInfo(@PathParam("wsdlUrl") String wsdlUrl, @PathParam("bindingName") String bindingName,
                                          @PathParam("operationName") String operationName) {
    SOAPOperationInfo info = new SOAPOperationInfo();
    WSDLParser parser = new WSDLParser();
    Definitions definition = parser.parse(wsdlUrl);
    StringWriter writer = new StringWriter();
    SOARequestCreator creator = new SOARequestCreator(definition, new RequestTemplateCreator(), new MarkupBuilder(writer));
    creator.createRequest(null, operationName, bindingName);
    info.setSampleRequest(writer.toString());

    return info;
}