If the username does not exist in the MyAlerts database you will need to call the SetUserLayerGroup method to add the user.
SetUserLayerGroup
Input Parameters
The SetUserLayerGroup method needs the following parameters:
ClientId
This is the id for the client that was returned by the CreateSessionKey method.
SessionKey
This is the SessionKey for the client that was returned by the CreateSessionKey method.
Returned Parameters
The following parameters will be returned:
<CreateUserResult> <Error> <Code>string</Code> <Description>string</Description> </Error> <UserId>int</UserId> <Success>boolean</Success </CreateUserResult>
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
This is the UserId that has been generated for the supplied Username in the MyAlerts database and will only be returned if the Success is True.
Success
This will be either True or False. If False an error message will be provided in the Error result, if True the UserId will be provided.
Code Examples
C#
Add a web reference to the usermanager.asmx webservice using the Visual Studio IDE.
Layer Groups and Map Sources can be listed by running the following SQL against the MyAlerts database.
select * from tbl_layergroupnames; "layergroupid"|"layergroupname"|"updated" "36d252ee-222f-4d84-8378-0cfdb62b04f1"|"Property Details"|t "3b730333-de4c-40ca-b1b7-bfa980fae531"|"Elected Members"|t "f4f242e3-4ef5-486b-948e-1decbc68feb6"|"Aerial Overview"|t "e86f6e58-e3c4-4127-8268-991185e4e57d"|"Local Government"|t "fff2bf67-526f-4e0a-acf7-79e5524e84be"|"Feeds"|t "b23524bf-4255-42cb-bcf0-a691fcc27aa7"|"Members of Parliament"|t "d09fbe4b-f590-45a5-8bff-8f326dd1a2aa"|"Transport"|t "385112de-bd32-465a-9391-fc35c2a137d2"|"Parishes"|t "4582862c-8a53-464d-832b-facaead9b524"|"Housing"|t "15dbaa0d-ecf5-48b1-927d-a3a2344c648b"|"Education and Learning"|t "e66ab4ae-f409-47ef-a446-7a5f509725f7"|"Transport"|t "e0382cf2-1239-4032-a29a-5090ea7c0c40"|"Police.uk"|t select * from tbl_mapsourcenames; "mapsourceid"|"mapsourcename"|"updated" "9209617d-a21b-4945-b45d-424a026417bd"|"My House"|t "5fd4b2e2-1fb6-48cc-9087-7a406c6c7616"|"My Nearest"|t select * from myalert.tbl_locations where locationname like '%HAMILTON PLACE%'; "userid"|"typeid"|"geography"|"distance"|"active"|"locationname"|"locationid"|"uniqueid" 7|1|"POINT( 485966.16261636 150149.77144220)"|500|1|"4, HAMILTON PLACE, ALDERSHOT, HAMPSHIRE, GU11 3HT"|"3802a7ef-0afc-4127-aaf8-660e49444c01"|"354021" 1015|1|"POINT( 524753.69110043 155979.08202718)"|500|1|"6 HAMILTON PLACE, KINGSWOOD, TADWORTH, SURREY, KT20 6PU"|"39b040a1-78cf-4692-8a81-0606adf87f11"|"48936" 1948|1|"POINT( 485948.90450241 150145.90827126)"|500|1|"11, HAMILTON PLACE, ALDERSHOT, HAMPSHIRE, GU11 3HT"|"558fc0e9-8866-4ac0-a744-4f2dbff5ca4e"|"68592" 2307|1|"POINT( 510588.77243534 170101.25986192)"|500|1|"17 HAMILTON PLACE, SUNBURY ON THAMES, SURREY, TW16 5BP"|"2b0be684-6c8d-42e0-a475-73e0755190f2"|"294415" 7911|1|"POINT( 485973.11673133 150133.43355484)"|500|1|"13, HAMILTON PLACE, ALDERSHOT, HAMPSHIRE, GU11 3HT"|"e3d92406-0c13-476b-8e8a-c9acb02621c0"|"56561" 8240|1|"POINT( 510608.18250183 170096.93179925)"|500|1|"11, HAMILTON PLACE, SUNBURY-ON-THAMES, SURREY, TW16 5BP"|"d3a4051c-6205-4e9f-af9b-1e3cd612e3b8"|"59964" 8268|1|"POINT( 485965.13936804 150143.30344919)"|500|1|"20, HAMILTON PLACE, ALDERSHOT, HAMPSHIRE, GU11 3HT"|"37e29e22-474c-4ce6-865d-49d4ce352608"|"56552"
Add the code below to subscribe the user to a Layer Group
UserManager.UserManager umws = new UserManager.UserManager(); // [Client Id] and [Session Key] are returned using the 'Create client Session Key' method // Possible layergroups to subscribe to can be derived using the getlayers method UserManager.DatabaseWriteResult result = umws.SetUserLayerGroup( [ClientId], "[SessionKey]", [UserId], "[LayerGroupGUID]", "[MapSourceGUID]", "[LocationGUID]"); return result.Success;
Using the data from the SQL Example above, a possible call would be:
UserManager.UserManager umws = new UserManager.UserManager(); // [Client Id] and [Session Key] are returned using the 'Create client Session Key' method // Possible layergroups to subscribe to can be derived using the getlayers method UserManager.DatabaseWriteResult result = umws.SetUserLayerGroup( 2, "f3abb2f2-ce86-4971-b6ae-d72661191670", 1, "4582862c-8a53-464d-832b-facaead9b524", "9209617d-a21b-4945-b45d-424a026417bd", "3802a7ef-0afc-4127-aaf8-660e49444c01"); return result.Success;
Thus subscribing userid = 1 to the "Housing" layer group in the "My House" map source at "4 Hamilton Place"
Python
import suds url = "http://[PATH TO WEBSERVICE]/usermanager.asmx?wsdl" client = suds.client.Client(url) result = client.service.SetUserLayerGroup( [ClientId], "[SessionKey]", [UserId], "[LayerGroupGUID]", "[MapSourceGUID]", "[LocationGUID]") if result.Success: print "Success" else: print "Fail"