I would like connect to ArcGIS server, but I have an error message "la référence d'un objet n'est pas définie à une instance a une objet". I have many examples:
string serverName = "adresse";
string instance = "ArcGIS/services";
// Using the ADF Common API data source implementation of the ArcGIS Server Web Service API
string serviceNameAndType = "nameservice/MapServer";
ESRI.ArcGIS.ADF.ArcGISServer.MapServerProxy agsSoapMapServerProxy = new
ESRI.ArcGIS.ADF.ArcGISServer.MapServerProxy("http://" + serverName + "/" + instance + "/" + serviceNameAndType);
or
ESRI.ArcGIS.ADF.Identity identity = new ESRI.ArcGIS.ADF.Identity("usernamer", "password", "domain");
ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection agsconnection;
agsconnection = new ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection("nomserver", identity);
agsconnection.Connect();
IServerObjectManager SOM = agsconnection.ServerObjectManager;
or
string mapServiceUrl = "http://servername/ArcGIS/services/servicename/MapServer";
ESRI.ArcGIS.ADF.ArcGISServer.MapServerProxy mapServerProxy = new ESRI.ArcGIS.ADF.ArcGISServer.MapServerProxy(mapServiceUrl);
I hope that someone can help me :)
-
can you translate the error message to english?Kirk Kuykendall– Kirk Kuykendall2011年04月07日 21:08:37 +00:00Commented Apr 7, 2011 at 21:08
-
1Object reference not set to an instance of an object.mwalker– mwalker2011年04月07日 21:43:09 +00:00Commented Apr 7, 2011 at 21:43
-
Did you try running it on the server and connecting to localhost?Kirk Kuykendall– Kirk Kuykendall2011年04月08日 13:47:37 +00:00Commented Apr 8, 2011 at 13:47
-
Can you tell us which lines are giving you the error? I use your second method all the time, but when I put any invalid strings in, I get different (descriptive) errors - but never an object reference error.brenth– brenth2011年04月11日 13:44:09 +00:00Commented Apr 11, 2011 at 13:44
1 Answer 1
Your issue is most likely related to user permissions. There are several things you need to make sure in order to connect to ArcGIS Server:
- The user name you are trying to use must be a member of the agsadmin group
- If this is a desktop application, the user you are currently logged in as (if different from above user) must also be a member of agsadmin.
- If this is a web application, the ArcGISWebServices user must be a member of agsadmin. In addition, the user the web application is running under (Vista, 7, and server 2003+ use NETWORK SERVICE) needs to be a member of agsadmin. Alternately, you can set up a new application pool, and set it to run under the user you are trying to connect as, making sure that user is a member of agsadmin.
The bottom two points are required because DCOM actually doesn't impersonate the user you supply, it still continues to use the user information of the underlying process. There is a somewhat convoluted method of properly impersonating a user for DCOM use, however I can't remember if I ever got it running properly.
-
thx for ur help but i thik that that user name is a member of the agsadminhana hana– hana hana2011年04月11日 09:43:14 +00:00Commented Apr 11, 2011 at 9:43