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>


SOAP web service remote troubleshooting

Testing the connection

While it is possible to test the web service via a browser it is only possible to do this from the actual server machine.  If you are not able to connect directly to the server you may wish to use this simple app to check if the web service is actually running and that you can authenticate.  You can experiment with authentication and might see an error like this:

WS Error Message

If you connect successfully you will see a response including the connected user name, like this:

Using WS Test

To use this test app simply:

  1. download the test app,
  2. unzip the contained files into a folder on your computer,
  3. run WsTest.exe,
  4. enter the URL for your web service,
  5. either choose Default Credentials or enter your user name, domain and password (domain optional), then
  6. press Go.