Code example for URLConnection

Methods: getContentType, getInputStream, setConnectTimeout, setReadTimeout, setRequestProperty

0
                } 
                return null; 
            } 
 
            BufferedInputStream newInputStream = new BufferedInputStream(
                    newConnection.getInputStream());
 
            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";
            log.error(msg);
            throw new CGException(msg);
        } else { 
            try { 
                connection = url.openConnection();
            } catch (IOException e) {
                throw new CGException("Could not open the URL connection", e);
            } 
        } 
        connection.setReadTimeout(getReadTimeout());
        connection.setConnectTimeout(getConnectTimeout());
        connection.setRequestProperty("Connection", "close"); // if http is being used
        return connection;
    } 
     
    public static OMElement getWSDLElement(String wsdlLocation) throws CGException {
        OMNode wsdNode = getOMElementFromURI(wsdlLocation);