Catalog service GetTokenServiceURL method

Gets the URL to an ArcGIS Server token service used to generate tokens for clients.

GetTokenServiceURL()

Return Value

A string representing the URL to the token service. If empty, the token service has not been enabled and is not available.

Remarks

If authentication has been enabled on an ArcGIS Server site, a complimentary token service can be used to manage transactions. Note that authentication may be enabled on an ArcGIS Server site without using the token service. Use the RequiresTokens method to determine if the token service is being used.

Examples

C#

Catalog catalog = new Catalog();

catalog.Url = "http://localhost:6080/arcgis/services";

 

MapService_MapServer mapservice = new MapService_MapServer();

mapservice.Url = "http://localhost:6080/arcgis/services/MapService/MapServer";

 

string tokenurl = catalog.GetTokenServiceURL();

string tokenrequesturl = tokenurl + "?request=getToken&username=myuser&password=secret";

 

System.Net.WebRequest request = System.Net.WebRequest.Create(tokenrequesturl);

System.Net.WebResponse response = request.GetResponse();

 

System.IO.Stream responseStream = response.GetResponseStream();

System.IO.StreamReader readStream = new System.IO.StreamReader(responseStream);

 

string myToken = readStream.ReadToEnd();

mapservice.Url = mapservice.Url + "?token=" + myToken;

 

string mapname = mapservice.GetDefaultMapName();

VB.NET

Dim url As String = "http://localhost:6080/arcgis/services"

Dim catalog As Catalog = New Catalog(url)

 

Dim mapservice As MapService_MapServer = New MapService_MapServer()

mapservice.Url = "http://localhost:6080/arcgis/services/MapService/MapServer"

 

Dim tokenurl As String = catalog.GetTokenServiceURL()

Dim tokenrequesturl As String = tokenurl + "?request=getToken&username=myuser&password=secret"

Dim request As System.Net.WebRequest = System.Net.WebRequest.Create(tokenrequesturl)

Dim response As System.Net.WebResponse = request.GetResponse()

Dim responseStream As System.IO.Stream = response.GetResponseStream()

Dim readStream As System.IO.StreamReader = New System.IO.StreamReader(responseStream)

Dim myToken As String = readStream.ReadToEnd()

 

mapservice.Url = mapservice.Url + "token=" + myToken

Dim mapname As String = mapservice.GetDefaultMapName()

Java

String serviceURL = "http://localhost:6080/arcgis/services";

ServiceCatalogBindingStub serviceCatalog = new ServiceCatalogBindingStub(serviceURL);

if(serviceCatalog.requiresTokens()){

      System.out.println ("TokenServiceURL: " + serviceCatalog.getTokenServiceURL());

}

11/8/2016