Code example for URLConnection

Methods: getContentTypegetInputStreamsetConnectTimeoutsetReadTimeoutsetRequestProperty

                return null; 
            BufferedInputStream newInputStream = new BufferedInputStream(
            OMFactory omFactory = OMAbstractFactory.getOMFactory();
            return omFactory.createOMText(
                    new DataHandler(new SynapseBinaryDataSource(newInputStream,
                            newConnection.getContentType())), true);
        } catch (IOException e) {
            throw new CGException("Error when getting a stream from resource's content", e);
    private static URLConnection getURLConnection(URL url) throws CGException {
        URLConnection connection;
        if (url.getProtocol().equalsIgnoreCase("https")) {
            String msg = "Connecting through doesn't support";
            throw new CGException(msg);
        } else { 
            try { 
                connection = url.openConnection();
            } catch (IOException e) {
                throw new CGException("Could not open the URL connection", e);
        connection.setRequestProperty("Connection", "close"); // if http is being used
        return connection;
    public static OMElement getWSDLElement(String wsdlLocation) throws CGException {
        OMNode wsdNode = getOMElementFromURI(wsdlLocation);
Stop searching for code, let great code find you!  Add Codota to your java IDE