Httpg protocol

Although httpg protocol is now obsolete, there are still some services which use it. It is possible to access such a service from Vine Toolkit modules, however one should not forget about some tricks. To see the complete and working example, look at srm project, paying special attention to class, implementing file system plugin for gLite Storage Resource Management.

All hints, presented below, are snippets of codes taken from class.

1) First problem, which can be encountered is class loading and jar conflicts. To avoid this problem, store current classloader and switch to the one appropriate for the current class.

    ClassLoader savedClassLoader = Thread.currentThread().getContextClassLoader();

2) Register types of communication transport, especially the one for the httpg protocol.

        SimpleProvider provider = new SimpleProvider();
                "httpg", new SimpleTargetedChain(new GSIHTTPSender()));
                "https", new SimpleTargetedChain(new HTTPSSender()));
                "http", new SimpleTargetedChain(new HTTPSender()));
        AxisClient ac = new AxisClient(provider);
        SRMServiceLocator locator = new SRMServiceLocator(ac.getClientEngine().getConfig());

3) Create an httpg url.

        HttpgURLStreamHandlerFactory httpgfac = new HttpgURLStreamHandlerFactory();
        ISRM isrm = null;
        URL serviceURL = null;
        try {
            SrmResource rs = (SrmResource) getResource();        	
        	String rootContext = rs.getRootContext();
            serviceURL = new URL("httpg", fileResourceLocation.getHost(), fileResourceLocation.getPort(), fileResourceLocation.getPath() + rootContext, httpgfac.createURLStreamHandler("httpg"));
            isrm = locator.getsrm(serviceURL);
            log.debug("isrm" + isrm);
        } catch (Exception e) {
            log.error(e.getMessage(), e);

4) HttpgURLStreamHandlerFactory is a custom Vine Toolkit class.

public class HttpgURLStreamHandlerFactory implements URLStreamHandlerFactory {
    public URLStreamHandler createURLStreamHandler(String protocol) {
            return new Handler();
        return null;

5) Register and initialize transport for httpg protocol.


        if (MessageContext.getCurrentContext()!= null)
        if (MessageContext.getCurrentContext()!= null)

        Call.setTransportForProtocol("httpg", org.globus.axis.transport.GSIHTTPTransport.class);

6) Switch the classloader to the previously stored one.


7) Axis class 'HTTPSender' was reimplemented a little, recompiled and served instead of original one by Vine classloader engine:

org.apache.axis.transport.http.HTTPSender of the axis 1.4 distribution.

Method invoke was changed:

public void invoke(MessageContext msgContext) throws AxisFault;

after the line:

String someUrl = msgContext.getStrProp(MessageContext.TRANS_URL);

the block of code was added to reflect any 'httpg' urls:

          log.debug("HTTPSender::httpg url retrieved: "+someUrl);
            if (someUrl.startsWith("httpg")) {
                boolean isPort = false;
                int indexA = someUrl.indexOf("://");
                indexA +=3;
                int indexB = someUrl.indexOf(":",indexA);
                if (indexB==-1)
                    indexB = someUrl.indexOf("/",indexA);
                    isPort = true;
                String host = someUrl.substring(indexA,indexB);
                String port = null;
                String path = null;
                if (isPort) {
                    int indexNext = someUrl.indexOf("/",indexB);
                    if (indexNext>0) {
                        port = someUrl.substring(indexB+1,indexNext);
                        path = someUrl.substring(indexNext);
                    } else {
                        port = someUrl.substring(indexB+1);
                        path = "/";
                } else {
                    path = someUrl.substring(indexB);
                log.debug("HTTPSender::httpg url host: "+host);
                log.debug("HTTPSender::httpg url port: "+port);
                log.debug("HTTPSender::httpg url path: "+path);
                int portVal;
                if (port!=null)
                    portVal = Integer.valueOf(port);
                    portVal = 0;
                HttpgURLStreamHandlerFactory httpgfac = new HttpgURLStreamHandlerFactory();
                targetURL = new URL("httpg",host,portVal,path,httpgfac.createURLStreamHandler("httpg"));
                targetURL = new URL(msgContext.getStrProp(MessageContext.TRANS_URL));

The class source could be located here.