<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Create an ArcGIS Server Connection file Programmatically in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/create-an-arcgis-server-connection-file/m-p/411436#M11011</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Okay, I got it figured out. I had to go use IAGSServerConnectionName2 to make the connection and then go to the Catalog library to get IGxAGSConnection to save as a file.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Code snippet is below:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;string myfullpath = @"c:\temp\myagsConn.ags";&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IAGSServerConnectionName2&amp;nbsp; myAGSConnName2 =(IAGSServerConnectionName2) new AGSServerConnectionName();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IPropertySet connectionProps = new PropertySet();&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;connectionProps.SetProperty("URL",targetURL);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;connectionProps.SetProperty("HTTPTIMEOUT",targetTimeout);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;connectionProps.SetProperty("ANONYMOUS",true);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;myAGSConnName2.ConnectionProperties = connectionProps;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IGxAGSConnection myAGConn = (IGxAGSConnection) new&amp;nbsp; GxAGSConnection();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;myAGConn.AGSServerConnectionName =&amp;nbsp; (IAGSServerConnectionName2)myAGSConnName2;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;myAGConn.Connect();&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;myAGConn.SaveToFile(myfullpath); &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Console.WriteLine("Created file: "&amp;nbsp;&amp;nbsp; + myfullpath );&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 24 Feb 2011 13:28:30 GMT</pubDate>
    <dc:creator>AllanBenvin</dc:creator>
    <dc:date>2011-02-24T13:28:30Z</dc:date>
    <item>
      <title>Create an ArcGIS Server Connection file Programmatically</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/create-an-arcgis-server-connection-file/m-p/411433#M11008</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm trying to write a batch Python job that will connect to AGServer to geocode some data. I don't want to store a connection file with this I want to connect dynamically. My Python script calls some C# code that I am writing that accepts the server name and creates a connection. This is all good but apparently I am not smart enough to create a connection file once I have made the connection. I'm sure this must be possible but I'm not finding it in the help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;My code to make the connection is below.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;string pServer = "myServer";&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IAGSServerConnectionFactory2 AGSConnectionFactory = (IAGSServerConnectionFactory2)new&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AGSServerConnectionFactory();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IPropertySet2 connectionProps = (IPropertySet2)new PropertySet();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;connectionProps.SetProperty("machine", pServer);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IAGSServerConnection3 myAGSConnection = (IAGSServerConnection3)AGSConnectionFactory.Open&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (connectionProps, 0);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;At this point I have the connection so I know that works but how do I make a connection file that can then be accessed by Python script?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help would be appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-Al&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Feb 2011 20:58:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/create-an-arcgis-server-connection-file/m-p/411433#M11008</guid>
      <dc:creator>AllanBenvin</dc:creator>
      <dc:date>2011-02-18T20:58:50Z</dc:date>
    </item>
    <item>
      <title>Re: Create an ArcGIS Server Connection file Programmatically</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/create-an-arcgis-server-connection-file/m-p/411434#M11009</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Al,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;there is a tool in Data Management Tools -&amp;gt; Workspace that lets you create a sde connection file.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You could create the file directly from within your Python script. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The following code is from the Desktop Help: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# CreateArcSDEConnection.py&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# Description: Simple example showing use of CreateArcSDEConnectionFile tool&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# Author: ESRI&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# Import system modules&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Set variables&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;folderName = r"c:\connectionFiles"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;fileName = "Connection to gpserver.sde"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;serverName = "gpserver"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;serviceName = "5151"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;databaseName = ""&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;authType = "DATABASE_AUTH"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;username = "toolbox"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;password = "toolbox"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;saveUserInfo = "SAVE_USERNAME"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;versionName = "SDE.DEFAULT"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;saveVersionInfo = "SAVE_VERSION"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Process: Use the CreateArcSDEConnectionFile function&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.CreateArcSDEConnectionFile_management (folderName, fileName, serverName, serviceName, databaseName, authType, username, password, saveUserInfo, versionName, saveVersionInfo)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Monika&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Feb 2011 22:44:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/create-an-arcgis-server-connection-file/m-p/411434#M11009</guid>
      <dc:creator>MonikaNientiedt</dc:creator>
      <dc:date>2011-02-18T22:44:24Z</dc:date>
    </item>
    <item>
      <title>Re: Create an ArcGIS Server Connection file Programmatically</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/create-an-arcgis-server-connection-file/m-p/411435#M11010</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;&lt;SPAN&gt;This will create a connection for ArcSDE but I want to create a connection file for ArcGIS Server to access a geocoding service. To do this manually it in Catalog it would be GIS Servers-Add ArcGIS Servers-Use GIS Services--&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://myserver/arcgis/services" rel="nofollow" target="_blank"&gt;http://myserver/arcgis/services&lt;/A&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Feb 2011 15:58:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/create-an-arcgis-server-connection-file/m-p/411435#M11010</guid>
      <dc:creator>AllanBenvin</dc:creator>
      <dc:date>2011-02-22T15:58:30Z</dc:date>
    </item>
    <item>
      <title>Re: Create an ArcGIS Server Connection file Programmatically</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/create-an-arcgis-server-connection-file/m-p/411436#M11011</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Okay, I got it figured out. I had to go use IAGSServerConnectionName2 to make the connection and then go to the Catalog library to get IGxAGSConnection to save as a file.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Code snippet is below:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;string myfullpath = @"c:\temp\myagsConn.ags";&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IAGSServerConnectionName2&amp;nbsp; myAGSConnName2 =(IAGSServerConnectionName2) new AGSServerConnectionName();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IPropertySet connectionProps = new PropertySet();&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;connectionProps.SetProperty("URL",targetURL);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;connectionProps.SetProperty("HTTPTIMEOUT",targetTimeout);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;connectionProps.SetProperty("ANONYMOUS",true);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;myAGSConnName2.ConnectionProperties = connectionProps;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IGxAGSConnection myAGConn = (IGxAGSConnection) new&amp;nbsp; GxAGSConnection();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;myAGConn.AGSServerConnectionName =&amp;nbsp; (IAGSServerConnectionName2)myAGSConnName2;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;myAGConn.Connect();&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;myAGConn.SaveToFile(myfullpath); &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Console.WriteLine("Created file: "&amp;nbsp;&amp;nbsp; + myfullpath );&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Feb 2011 13:28:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/create-an-arcgis-server-connection-file/m-p/411436#M11011</guid>
      <dc:creator>AllanBenvin</dc:creator>
      <dc:date>2011-02-24T13:28:30Z</dc:date>
    </item>
    <item>
      <title>Re: Create an ArcGIS Server Connection file Programmatically</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/create-an-arcgis-server-connection-file/m-p/411437#M11012</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Al,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Great! I clearly misread your original post.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Feb 2011 20:45:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/create-an-arcgis-server-connection-file/m-p/411437#M11012</guid>
      <dc:creator>MonikaNientiedt</dc:creator>
      <dc:date>2011-02-24T20:45:25Z</dc:date>
    </item>
  </channel>
</rss>

