HiveBrain v1.2.0
Get Started
← Back to all entries
patterncsharpMinor

IMapDocument in a 10.1 SOE

Submitted by: @import:stackexchange-codereview··
0
Viewed 0 times
soeimapdocumentstackoverflow

Problem

I am wondering if this code will work in 10.1.

This video at 1:02 says not to create mxd based services. I think that just means not using IMapServerObjects3, but seems like IMapDocument should be OK.

#region IServerObjectExtension Members

private IPageLayout m_Layout = null;
public void Init(IServerObjectHelper pSOH)
{
    serverObjectHelper = pSOH;
    // open an mxd and grab the layout
    IMapDocument mapDoc = new MapDocumentClass();
    mapDoc.Open(@"\\sharedFolder\Mymapdocument.mxd");
    m_Layout = mapDoc.PageLayout;
    mapDoc.Close();
}

public void Shutdown()
{
    System.Runtime.InteropServices.Marshal.FinalReleaseComObject(m_Layout);
}

#endregion


Edit: Here's a related question on GIS.stackexchange.

Solution

The reason why the video states that you should not create SOEs on top of MXD based map services is because in 10.1 you will not be able to start a service from an mxd. You will need to convert your map document into a service definition.

One of the issues you will find with MXD-based SOEs in 10 when you upgrade to 10.1, is that your code most likely will be accessing layers or layouts in the map service. This is pretty common in MXD-based SOEs because it is through layers that you get to the datasets you want to use in your code etc. At 10.1, your SOE code will break, because layers, layouts etc are only available in MXD-based SOE map services. If you create an MSD-based map service and build an SOE on top of it, you will notice the same. With MSD-based SOEs you need to use IMapServerDataAccess to get to the data sources in your map. And that code will just work in 10.1. So writting SOE's on top of MSD is a good way to understand what will be possible in 10.1

I suggest you look at this and this.

As for using IMapDocument... go for it. It will work fine in 10.1

Context

StackExchange Code Review Q#2355, answer score: 4

Revisions (0)

No revisions yet.