SOAP web service ConnectionInfo

Background

There is an operation in the SOAP web service called ConnectionInfo.  In recent versions this has been deprecated there is, however, an alternative.  The purpose of ConnectionInfo is to return information about the currently connected user, this is now discoverable via the ObjectStringSearchSelect.

How to get the current connection

The C# code below demonstrates using the ObjectStringSearchSelect operation to find the current user and fetch their Uri.  Of course the Fetch could also be used to retrieve any other Location property.

TrimRequest request = new TrimRequest();

ObjectStringSearchSelect stringSearch = new ObjectStringSearchSelect();
stringSearch.TrimObjectType = "location";
stringSearch.Search = "me";

request.Items = new Operation[] { stringSearch, new Fetch() };

Engine engine = new Engine();
engine.UseDefaultCredentials = true;

TrimResponse response = engine.Execute(request);

foreach (Result res in response.Items)
{
    switch (res.GetType().Name)
    {
        case "FetchResult":
            FetchResult fetchResult = res as FetchResult;
            if (fetchResult.Objects.Length > 0)
            {
                Console.WriteLine(fetchResult.Objects.First().Uri);
            }
            break;
        case "ErrorResult":
            ErrorResult errorResult = res as ErrorResult;
            Console.WriteLine(errorResult.Message);
            break;
        }
}

Show me the SOAP

Below is the SOAP request to search for the Location 'me'.  Also required is a Fetch operation to return the Location Uri.

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
        <Execute xmlns="http://www.towersoft.com/schema/webservice/trim2/">
            <req>
                <ObjectStringSearchSelect>
                    <TargetForUpdate>false</TargetForUpdate>
                    <IsForUpdate>false</IsForUpdate>
                    <Limit>0</Limit>
                    <Skip>0</Skip>
                    <TrimObjectType>location</TrimObjectType>
                    <Search>me</Search>
                </ObjectStringSearchSelect>
                <Fetch>
                    <TargetForUpdate>false</TargetForUpdate>
                    <Limit>0</Limit>
                    <Populate>0</Populate>
                    <HideVersion>false</HideVersion>
                </Fetch>
                <HideVersionNumbers>false</HideVersionNumbers>
                <ProvideTimingResults>false</ProvideTimingResults>
                <ForceRealTimeCacheUpdate>false</ForceRealTimeCacheUpdate>
            </req>
        </Execute>
    </soap:Body>
</soap:Envelope>