Arcengine dynamic publishing WMS

Source: Internet
Author: User
If (this. textbox1.text = "")
{
MessageBox. Show ("enter the host name! ");
Return;
}
If (this. textbox2.text = "")
{
MessageBox. Show ("enter the name of the published service! ");
Return;
}
If (this. textbox3.text = "")
{
MessageBox. Show ("select the path to publish the mxd file! ");
Return;
}

// Obtain the published host name, service name, and file address.
String hostname = This. textbox1.text;
String servername = This. textbox2.text;
String filepath = This. textbox3.text;

Igisserverconnection pgisserverconnection = new gisserverconnectionclass ();
// Note: the host name entered by connect indicates the server to be connected.
Pgisserverconnection. Connect (hostname );

Iserverobjectadmin pserverobjectadmin;
Pserverobjectadmin = pgisserverconnection. serverobjectadmin;
Iserverobjectconfiguration2 configuration = (iserverobjectconfiguration2) pserverobjectadmin. createconfiguration ();

// Obtain the server list and determine whether the published service exists.
Ienumserverobjectconfiguration Ss = pserverobjectadmin. getconfigurations ();
Iserverobjectconfiguration2 pp;
For (INT I = 0; I <ss. Count; I ++)
{
Pp = (iserverobjectconfiguration2) ss. Next ();
String name = pp. Name;
If (name = servername)
{
MessageBox. Show ("the published service name already exists! ");
Return;
}
}

Configuration. Name = servername; // name of the published service, required
Configuration. typename = "mapserver"; // type of the published service, such as mapserver and geocodeserver
Ipropertyset props = configuration. properties;
// Props. setproperty ("filepath", @ "E: \ Program Files \ ArcGIS \ Development Kit \ samplesnet \ data \ world. mxd"); // set the mxd path
Props. setproperty ("filepath", filepath); // you can specify the mxd path.
// The following property is not required. Only one filepath can be released.

Props. setproperty ("outputdir", "C: \ arcgisserver \ arcgisoutput"); // output directory of the image
String virtualoutputdir = "http: //" + hostname + "/arcgisoutput ";
Props. setproperty ("virtualoutputdir", virtualoutputdir); // virtual path of image output
Props. setproperty ("supportedimagereturntypes", "url"); // supported image types
Props. setproperty ("maximageheight", "2048"); // maximum Image Height
Props. setproperty ("maxrecordcount", "500"); // maximum number of returned records
Props. setproperty ("maxbuffercount", "100"); // maximum number of buffer zone Analyses
Props. setproperty ("maximagewidth", "2048"); // maximum Image Width
Props. setproperty ("iscached", "false"); // whether to slice
Props. setproperty ("cacheondemand", "false"); // whether to actively slice
Props. setproperty ("ignorecache", "false"); // ignore slice
Props. setproperty ("clientcachingallowed", "true"); // whether to allow client Buffering
String cachedir = "C :\\ arcgisserver \ arcgiscache \" + servername;
Props. setproperty ("cachedir", cachedir); // The output path of the slice.
Props. setproperty ("somcachedir", "C: \ arcgisserver \ arcgiscache"); // The Slice output path of SOM

// Set WMS
Configuration. set_extensionenabled ("wmsserver", true );
Ipropertyset wmsprops = configuration. get_extensionproperties ("wmsserver ");
Wmsprops. setproperty ("customgetcapabilities", "false ");
Wmsprops. setproperty ("pathtocustomgetcapabilitiesfiles ","");
Wmsprops. setproperty ("name", "WMS ");
Wmsprops. setproperty ("title", servername );
Wmsprops. setproperty ("abstract ","");
Wmsprops. setproperty ("keyword ","");
String onlineresource = hostname + "/ArcGIS/services/" + servername + "/mapserver/wmsserver ";
Wmsprops. setproperty ("onlineresource", onlineresource );
Wmsprops. setproperty ("contactperson ","");
Wmsprops. setproperty ("contactposition ","");
Wmsprops. setproperty ("contactorganization ","");
Wmsprops. setproperty ("addresstype ","");
Wmsprops. setproperty ("city ","");
Wmsprops. setproperty ("stateorprovince ","");
Wmsprops. setproperty ("postcode ","");
Wmsprops. setproperty ("country ","");
Wmsprops. setproperty ("contactvoicetelephone ","");
Wmsprops. setproperty ("contactfacsimiletelephone ","");
Wmsprops. setproperty ("contactelectronicmailaddress ","");
Wmsprops. setproperty ("fees ","");
Wmsprops. setproperty ("accessconstraints ","");
Configuration. set_extensionproperties ("wmsserver", wmsprops );
Ipropertyset wmsinfo = configuration. get_extensioninfo ("wmsserver ");
Wmsinfo. setproperty ("webenabled", "true ");
Wmsinfo. setproperty ("webcapabilities ","");
Configuration. set_extensioninfo ("wmsserver", wmsinfo );

Configuration. Description = servername; // service description
Configuration. isolationlevel = esriserverisolationlevel. esriserverisolationhigh; // or esriserverisolationlow, esriserverisolationany
Configuration. ispooled = true; // whether to pool
Configuration. maxinstances = 1; // maximum number of instances
Configuration. mininstances = 1; // minimum number of instances

// Set refresh
Ipropertyset recycleprop = configuration. recycleproperties;
Recycleprop. setproperty ("starttime", "00:00"); // refresh Start Time
Recycleprop. setproperty ("interval", "3600"); // Refresh Interval
// Set whether to enable the rest Service
Ipropertyset infoprop = configuration. Info;
Infoprop. setproperty ("webenabled", "true"); // whether the rest service is provided
Infoprop. setproperty ("webcapabilities", "map, query, data"); // What kind of service is provided
Configuration. startuptype = esristartuptype. esristautomatic; // or esristmanual
Configuration. usagetimeout = 120; // The maximum time the client occupies a service
Configuration. waittimeout = 120; // The maximum waiting time for the client to apply for a service

configuration. set_extensionenabled ("wmsserver", true);
// Add service to server
pserverobjectadmin. addconfiguration (configuration);
// delete a service
// pserverobjectadmin. deleteconfiguration ("newservice", "mapserver");
// start the service
pserverobjectadmin. startconfiguration (servername, "mapserver");
MessageBox. show ("published successfully! ");

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.