ArcEngine10.1 如何发布地图服务
public void Publish(string host, string username, string password, string service)
{
IPropertySet propertySet = new PropertySetClass();
propertySet.SetProperty(url, "http://localhost:6080/arcgis/admin");
propertySet.SetProperty(ConnectionMode, esriAGSConnectionMode.esriAGSConnectionModeAdmin);
propertySet.SetProperty(ServerType, esriAGSServerType.esriAGSServerTypeDiscovery);
propertySet.SetProperty(user, username);
propertySet.SetProperty(password, password);
propertySet.SetProperty(ALLOWINSECURETOKENURL, true); //设置为false会弹出一个警告对话框
IAGSServerConnectionName3 pConnectName = new AGSServerConnectionNameClass() as IAGSServerConnectionName3;//10.1新增接口
pConnectName.ConnectionProperties = propertySet;
IAGSServerConnectionAdmin pAGSAdmin = ((IName)pConnectName).Open() as IAGSServerConnectionAdmin; IAGSServerConnectionAdmin pAGSServerConnectionAdmin = pAGSAdmin as IAGSServerConnectionAdmin;
IServerObjectAdmin pServerObjectAdmin = pAGSServerConnectionAdmin.ServerObjectAdmin;
IServerObjectConfiguration5 pConfiguration =(IServerObjectConfiguration5)pServerObjectAdmin.CreateConfiguration();
//Set the general configuration settings
pConfiguration.Name = service;
pConfiguration.TypeName = MapServer;
pConfiguration.TargetCluster = default;
pConfiguration.StartupType = esriStartupType.esriSTAutomatic;
pConfiguration.IsolationLevel = esriServerIsolationLevel.esriServerIsolationHigh;
pConfiguration.IsPooled = true;
pConfiguration.Description = Modsim Map Output;
// pConfiguration.LoadBalancing = esriLoadBalancing.esriLoadBalancingNone;//没有集群的话可以不用设置 pConfiguration.MinInstances = 1;
pConfiguration.MaxInstances = 15;
pConfiguration.WaitTimeout = 60;
pConfiguration.UsageTimeout = 600;
pConfiguration.IdleTimeout = 1800;
//Set the configuration properties of the MapServer
IPropertySet pProps = pConfiguration.Properties;
pProps.SetProperty(FilePath, "C:\Users\Administrator\Desktop\Sample\DataMap.msd");
pProps.SetProperty(OutputDir, "@C:\arcgisserver\directories\arcgisoutput");
pProps.SetProperty(MaxImageHeight, 2048);
pProps.SetProperty(MaxRecordCount, 1000);
pProps.SetProperty(MaxBufferCount, 100);
pProps.SetProperty(MaxImageWidth, 2048);
pConfiguration.Properties = pProps;
//MIME+URL (virtual directory)
IEnumServerDirectory dirs = pServerObjectAdmin.GetServerDirectories();
dirs.Reset();
IServerDirectory serverDir = dirs.Next();
while (serverDir != null)
{
if (((IServerDirectory2)serverDir).Type == esriServerDirectoryType.esriSDTypeOutput)
{
pProps.SetProperty(OutputDir, serverDir.Path);
pProps.SetProperty(VirtualOutputDir, serverDir.URL);
break;
}
serverDir = dirs.Next();
}
//Set the info segment properties
IPropertySet info = pConfiguration.Info;
info.SetProperty(WebEnabled, true);
info.SetProperty(WebCapabilities, Map,Query,Data);
pConfiguration.Info = info;
//Set the recycle properties of the MapServer object
IPropertySet recycle = pConfiguration.RecycleProperties;
recycle.SetProperty(StartTime, 1:00 AM);
recycle.SetProperty(Interval, 86400);
pConfiguration.RecycleProperties = recycle;
//Add the configuration to the server
pServerObjectAdmin.[b]AddConfiguration[/b](pConfiguration);
pServerObjectAdmin.StartConfiguration(service, MapServer);
}
为何在pServerObjectAdmin.AddConfiguration(pConfiguration)报错?
2 个回复
石羽
赞同来自: 陈於立 、gischen 、jiaxibei 、吉阿诺
可行的办法是借助ArcPy中的一些函数,实现msd,sd等文件的创建和Upload操作。
如果需要与Engine结合,则要直接调用Py脚本或建立脚本工具。有网友总结了方法,可以搜索一下。
总之表面上看比以前要复杂不少,但实际上内在的逻辑是简化了,因为是基于Server Admin API来实现的,比以前开放得多。
supercl
赞同来自:
要回复问题请先登录或注册
发起人
90后IT女
相关问题
问题状态