Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

If the username does not exist in you wish to add a Location for a user to the MyAlerts database you will need to call the AddLocation method to add the user.

AddLocation

Input Parameters

The AddLocation method needs the following parameters:

CreateUser Input parametersImage Removed

ClientIdThis method is available to developers from the UserManager.asmx Web Service

Parameters


Name

Requirement

Description

ClientId

mandatory

This is the id for the client that was returned by the CreateSessionKey method.

SessionKey

mandatory

This is the SessionKey for the client that was returned by the CreateSessionKey method.

UserId

mandatory

This is the unique user id for the user as stored in the My Alerts database.

TypeId

mandatory

This is always set to 1.

Geography

Returned Parameters

The following parameters will be returned:

...

mandatory

This is the X & Y coordinates for the location - These can be derived from the AstunLocationLookup table and take the form "POINT( 502582.58412372 159186.49997736)" Note: Must include leading space before X coordinate.

UniqueId

mandatory

This corresponds with the UniqueId on the AstunLocationLookup table.


Returns

Code Block
languagexml
titleSyntax
      <AddLocationResult>
        <Error>
          <Code>string</Code>
          <Description>string</Description>
        </Error>
        <UserId>int<<Success>boolean</UserId>Success>
        <Success>boolean</Success<LocationId>string</LocationId>
      </CreateUserResult>AddLocationResult>

Error- Code / Description

An error code and description if the call to the web service is unsuccessful and the Success if False.

1001 – Invalid Session key provided

1005 – Email address already exists

1006 – Username already exists

1007 – Error creating user

1023 – Required fields incomplete

UserId

...

Success

This will be either True or False. If False an error message will be provided in the Error result, if True the UserId LocationId will be provided.

LocationId

This is the Location ID that has been generated in the MyAlerts database and will only be returned if the Success is True. This is useful for subsequent calls such as SetLocationValues and SetUserLayerGroup

Code Examples

C#

Add a web reference to the usermanager.asmx web service using the Visual Studio IDE.

Code Block
languagec#
titleC# Example
linenumberstrue
 
// Explanation of webservice parameters
// [ClientId] and [SessionKey] are returned from the GetSessionKeyCreateSessionKey method (see above)
// [TypeId] - This is always set to 1
// [Geography] - X,Y points - These can be derived from the AstunLocationLookup table and 
//    take the form "POINT( 502582.58412372, 159186.49997736)"
// [UniqueId] - This corresponds with the UniqueId on the AstunLocationLookup table
UserManager.LocationAddResult res = umws.AddLocation(	[ClientId],
														"[SessionKey]",
														[UserId], 
														[TypeId], 
														"[Geography],
														[UniqueId]);
// LocationId is useful for subsequent calls such as SetLocationValues and SetUserLayerGroup
string loc = res.LocationId;
            
if (res.Success)
    Response.Write("Success");
else
    Response.Write("Fail");

Python

Code Block
languagepy
titlePython Example
linenumberstrue
# Requires SUDS library to be installed
import suds
url = "http://[PATH TO WEBSERVICE]/usermanager.asmx?wsdl"
client = suds.client.Client(url)
result = client.service.AddLocation(, 
							[ClientId],
							"[SessionKey]" ,
							[UserId],
							[TypeId],
							[Geography],
							[UniqueId])
loc = result.LocationId

if result.Success:
  print "Success"
else:
  print "Fail"

...