How to use arcgis server from winForms application?

3969
8
09-11-2015 02:54 AM
AnatoliiTerentiev
Occasional Contributor III

Dear Gurus!

How to use arcgis server from the winForms application?

May be as follows ArcObjects API Reference for ArcGIS Engine  or there exist other way?

0 Kudos
8 Replies
AnatoliiTerentiev
Occasional Contributor III

It's easy to use mapControl in arcObjects and map control in "http://schemas.esri.com/arcgis/client/2009" namespace (wpf, silverlight)

<esri:Map x:Name="myMap" Background="White" WrapAround="true"
      Extent="3200000,8500000,4250000,10130000" MouseClick="Map_MouseClick" >
      <esri:OpenStreetMapLayer ID="OSMLayer" Style="Mapnik" />
</esri:Map>

Can't anybody show how to solve simililar problems (with code example) in winForms or some reference would be nice?

0 Kudos
FreddieGibson
Occasional Contributor III

Could you explain in more detail what you're needing to accomplish? What is it that you're needing to do with the server.

0 Kudos
AnatoliiTerentiev
Occasional Contributor III

I have the project , which I wrote 5 yeas ago. The program are on the server and clients run it after enter the server via tsclient. Now I I have arcgis for server and use it from wpf and silverlight project. I want to rewrite my winForms project. In xaml of silverlight project

  <esri:Map x:Name="myMap" Background="White" WrapAround="true" 
                  Extent="3200000,8500000,4250000,10130000" MouseClick="Map_MouseClick" >
               <esri:OpenStreetMapLayer ID="OSMLayer" Style="Mapnik" />
               <esri:ArcGISDynamicMapServiceLayer ID="Karelia" 
                            Url="http://myserver:6080/ArcGIS/rest/services/karelia/MapServer" />
               <esri:FeatureLayer    ID="routes_osm" 
                            Url="http://myserver:6080/ArcGIS/rest/services/karelia/MapServer/1" 
                                  MouseEnter="FeatureLayer_MouseEnter_1">
                                        </esri:FeatureLayer>
               <esri:FeatureLayer    ID="bridges"         Visible="False"                         
                            Url="http://myserver:6080/ArcGIS/rest/services/karelia/MapServer/2" 
                                  MouseEnter="FeatureLayer_MouseEnter" >
                                        </esri:FeatureLayer>
 </esri:Map>

So it's needed to to use some feature layers, to draw some objects , to solve geometry tasks  and so on. Also need to use OSM layer.

Now I try to use connection factory  

            IAGSServerConnectionFactory AGSConnectionFactory = new AGSServerConnectionFactory();

but  get an error message -

"The required class is missing in ClassFactory".

0 Kudos
AnatoliiTerentiev
Occasional Contributor III

Sorry, I forgot

   ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.EngineOrDesktop);

An error has disappeared

0 Kudos
AnatoliiTerentiev
Occasional Contributor III

I successfully connected through the Internet connection with next code:

            IAGSServerConnectionFactory AGSConnectionFactory = new AGSServerConnectionFactory();
            IPropertySet connectionProps = new PropertySet();
            connectionProps.SetProperty("URL", "http://serverIP:6080/arcgis/admin");
            IAGSServerConnection AGSConnection = AGSConnectionFactory.Open(connectionProps, 0);
            IAGSEnumServerObjectName enumSOName = null;
            enumSOName = AGSConnection.ServerObjectNames;
            IAGSServerObjectName SOName = null;
            SOName = enumSOName.Next();


            while (SOName != null)
            {
                Debug.Print(SOName.Name + ": " + SOName.Type);
                SOName = enumSOName.Next();
            }

But I can't to connect through local connection in the LAN with next code:

            IAGSServerConnectionFactory AGSConnectionFactory = new AGSServerConnectionFactory();
            IAGSServerConnection AGSConnection = null;
            IPropertySet connectionProps = new PropertySet();
            connectionProps.SetProperty("machine", "MONITOR");


            AGSConnection = AGSConnectionFactory.Open(connectionProps, 0);

where "MONITOR" -    the name of the computer in LAN. How to specify the name of the server arcgis in this expression, and whether it is required to be connected with an setting of user (the member of agsusers group) and password?

0 Kudos
AnatoliiTerentiev
Occasional Contributor III

I tried to do so

IGISServerConnection connection = new GISServerConnection();
connection.Connect("http://serverIP:6080/arcgis/admin");

but I get an error

"Server RPC  is not available"

0 Kudos
AnatoliiTerentiev
Occasional Contributor III

1. Here ArcObjects Help for .NET developers  I read

"

  • Local connections to the SOM are made as a local user (using an operating system login that must be in the agsusers or agsadmin group).

"

but on server I don't see agsusers or agsadmin. (I work with arcgis server 10.1)

2. How do I specify a username and password from which the reques  to the server is?

3. Is there are any code examples?

4. How to specify the server name and the name of the machine, on which the server is running (whether it is necessary to specify the port)?

5. In Connect2 method only I can set userInfo

connection.jpg

0 Kudos
AnatoliiTerentiev
Occasional Contributor III

Hear ArcObjects Help for .NET developers  I read

"

Remote use of ArcObjects (via DCOM)

At 10.1, you can no longer use ArcObjects remotely (via DCOM); this way of interacting with ArcGIS for Server is no longer supported. If you are using GISServerConnection in the Server library or AGSServerConnection in the GISClient library in your code, these need to be removed if you are working with ArcGIS 10.1 for Server.

"

Is there a solution to my problem or it is  better to work from wpf?

0 Kudos