axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aaron.Kn...@vodafone.co.nz
Subject SOAP Routing and URLMapper
Date Fri, 04 Oct 2002 00:42:50 GMT
I am writing a simple SOAP router that, essentially, does the same as the
ProxyService from the axis samples.  The main difference is that the URL
that the message is to be delivered to is determined from request elements.
Moving forward, the destination will be determined base on info in the SOAP
header (possibly implementing WS routing).  For now I want to simply use
the extra path info in the HTTP request.

I have modified URL mapper to use only the first element of the extra path
info (i.e. the bit between the first and second slashes) to find the
service being requested.  This means I can request
'/services/router/mydestination' to have the request hit my 'router'
service and and be routed to 'mydestination'.  (This is a logical name that
is mapped to another destination in a routing table.)

This imposes the restriction that services identified by HTTP URL cannot
have slashes in their name, but I think that this is acceptable.  It would
probably be useful to have this as part of the standard Axis URLMapper.

Here is the code that I used to do it:  (Note that bit that sets the extra
path info in the message context to what is left after the service name.
Not sure whether to leave this in or not.)

--------------------------------------------

if ( msgContext.getService() == null )
        {
            // Determine the service to map to based on the extra path info
in the
            // HTTP request.
            String path
= (String)msgContext.getProperty(HTTPConstants.MC_HTTP_SERVLETPATHINFO);
            if ((path != null) && (path.length() > 1))
            {
                int secondSlash = path.indexOf('/', 1);
                String serviceName = path.substring(1, (secondSlash > 1) ?
secondSlash : path.length());
                msgContext.setTargetService( serviceName );

                // If there is additional extra path info, set the extra
path info
                // to the remainder
                String remainingPath = "";
                if (secondSlash > 1)
                {
                    remainingPath = path.substring(secondSlash);
                }

msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLETPATHINFO,
remainingPath);
            }
        }

--------------------------------------------

There is no magic.


-----------------------------------------------------------------------------------------------
Have you seen our website?.... http://www.vodafone.co.nz

CAUTION: This correspondence is confidential and intended for the named recipient(s) only.
If you are not the named recipient and receive this correspondence in error, you must not
copy,
distribute or take any action in reliance on it and you should delete it from your system
and
notify the sender immediately.  Thank you.

Unless otherwise stated, any views or opinions expressed are solely those of the author and
do
not represent those of Vodafone New Zealand Limited.

Vodafone New Zealand Limited
21 Pitt Street, Private Bag 92161, Auckland, 1020, New Zealand
Telephone + 64 9 357 5100
Facsimile + 64 9 377 0962

Mime
View raw message