Add WFS as a layer into ArcMap Document

2527
2
03-14-2014 08:17 AM
AndrewMcMenamin
New Contributor
I am trying to find the correct approach or interfaces to adding a WFS services ie one created using the interoperability extension.
I need to add this via code.

Does anyone have any ideas. There appeared to be an FMEWorkspace interface back in 9.

Thanks for any help.
0 Kudos
2 Replies
nancyvonmeyer
New Contributor III
I am having a similar problem - it appears that the Esri Open connection to WFS does not send the spatial reference system information.  It's almost as if that has been disabled.  the connection appears to read the service, I can select the features, and when I try to preview the service it seems to be indexing, but then there is no geometry and nothing in the tables. 

Is there a way to force Arc to send the SRS information to a WFS Service?
0 Kudos
by Anonymous User
Not applicable
I am trying to find the correct approach or interfaces to adding a WFS services ie one created using the interoperability extension.
I need to add this via code.

Does anyone have any ideas. There appeared to be an FMEWorkspace interface back in 9.

Thanks for any help.



FMEWorkspace interface does not exist from ArcGIS 10.0. So WFS cannot be added directly to ArcMap using ArcObjects. One of the following two approaches can be used instead:

1. Use the "WFS to FeatureClass" Tool in ArcToolbox. Convert the WFS Service layer to the File Geodatabase Feature class, which could be used in ArcObjects.

2.  a. Add .fdl to ArcMap from ArcCatalog. Right click the layer in Table of Contents and 'Save as Layer'. In this case, the data type of the layer will remain Interoperability Feature Class.
    b. Add this layer to ArcMap with the following code:
IApplication m_application = Hook as IApplication;
IMxDocument pMxDoc = m_application.Document as IMxDocument;

//Create a GxLayer.
IGxLayer gxLayerCls = new GxLayer();
IGxFile gxFile = (IGxFile)gxLayerCls;    //Explicit Cast.

//Set the path where the layer file is located on disk.
gxFile.Path = layerFilePathString;
            
//Test if you have a valid layer and add it to the map.
if (!(gxLayerCls.Layer == null))
{
      IMap map = pMxDoc.FocusMap;
      map.AddLayer(gxLayerCls.Layer);
}


Hope this helps!
0 Kudos