Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm currently building an add-in for ArcMap - ArcView using the .Net framework.

The user of ArcMap and the Add-in should access data published from WFS services.

I am aware that it is possible to manually add WFS services via the Interoperability Connections interface.

But, is it possible to add these WFS services programatically? (chances are - my users will find it difficult to add these manually)

And if it is, how could it be done?

I can't seem to find any info on this subject.

Best regards

share|improve this question
1  
Do you have a url to a public WFS site? If so, go ahead and post it. That way people can test their code before including it in an answer. –  Kirk Kuykendall Jun 6 '11 at 13:56
    
Hi, I can't post a public url - sry mate. –  user2847 Jun 7 '11 at 5:53
    
Hi @user2847, did you ever find a solution for this? Thanks –  lcoursey Jul 22 at 11:40

1 Answer 1

Unfortunately there is no way to dynamically make requests by a class. You have to program it via the fdl-file. To add a service (like WFS) you could use the code below.

IWorkspaceFactory factory = (IWorkspaceFactory)new FMEWorkspaceFactoryClass();
IFeatureWorkspace workspace = (IFeatureWorkspace)factory.OpenFromFile("d:\test", 0);
IFeatureDataset fds = workspace.OpenFeatureDataset("name.fdl");  

Cheers!

PS: Did you try using the IWFSServer interface? I used DI functionality in one of my previous projects to export data to GML format using QuickExport. You can try using the QuickImport and selecting WFS as the source. I am atatching the QuickExport code for your reference...

    Friend Sub Export2GML()
    Dim pGPMessages As IGPMessages
    'Dim pGPMessage As IGPMessage
    Dim pGPEnvMgr As IGPEnvironmentManager
    Dim pGPEnv_CoordSys As IGPEnvironment
    Dim pGPEnv_Extent As IGPEnvironment
    Dim pGPCOMHelper As IGPComHelper
    Dim pGPToolbox As IGPToolbox
    Dim pGPTool As IGPTool
    Dim pParameter As IGPParameter
    Dim pParameterEdit As IGPParameterEdit
    Dim pDataType As IGPDataType

    Dim pToolboxWorkspaceFactory As IWorkspaceFactory
    Dim pToolboxWorkspace As IToolboxWorkspace
    Dim pParamArray As IArray = New ArrayClass
    Dim pProgressTracker As ITrackCancel
    Dim pDSNames As IEnumDatasetName
    Dim pDSN As IDatasetName

    Dim TempWSPath As String = String.Empty
    Dim Inv_Layer_Names As String = String.Empty

    Try
        OS_Layer_Names = String.Empty

        'Get all layer names from the scratch PGDB
        TempWSPath = pTempWS.PathName

        pDSNames = pTempWS.DatasetNames(esriDatasetType.esriDTFeatureClass)
        pDSNames.Reset()

        pDSN = pDSNames.Next
        While Not pDSN Is Nothing
            If pDSN.Name.Contains("X") Or pDSN.Name.Contains("Y") Then
                'If pDSN.Name.Contains("_OS") Then
                ' OS Layers present, export them seperately
                OS_Layer_Names &= TempWSPath & "\" & pDSN.Name & "; "
            Else
                ' Inventory layer
                Inv_Layer_Names &= TempWSPath & "\" & pDSN.Name & "; "
            End If

            pDSN = pDSNames.Next
        End While

        'gputils = New GPUtilities
        pProgressTracker = New TrackCancel

        'Get the environment manager
        pGPCOMHelper = New GpDispatch
        pGPEnvMgr = pGPCOMHelper.EnvironmentManager

        'Set output coordinate system
        pGPEnv_CoordSys = pGPEnvMgr.FindEnvironment("outputCoordinateSystem")
        pGPEnv_CoordSys.Value = pGPEnv_CoordSys.DataType.CreateValue(ArcMap_INSTALL_DIR & "Coordinate Systems\Projected Coordinate Systems\National Grids\Your National Grid.prj")

        'Set extents
        pGPEnv_Extent = pGPEnvMgr.FindEnvironment("extent")
        pGPEnv_Extent.Value = pGPEnv_Extent.DataType.CreateValue("sameAsInput")

        'Create a toolbox workspace factory
        pToolboxWorkspaceFactory = New ToolboxWorkspaceFactory

        'Open toolbox workspace
        pToolboxWorkspace = pToolboxWorkspaceFactory.OpenFromFile(ArcMap_INSTALL_DIR & "ArcToolbox\Toolboxes", 0)

        'Open toolbox by name
        pGPToolbox = pToolboxWorkspace.OpenToolbox("Data Interoperability Tools.tbx")

        'If DI Toolbox is not found, means extensions were not installed
        If pGPToolbox Is Nothing Then
            MsgBox("Data Interoperability Toolbox not found!" & vbCrLf & "Please contact helpdesk.", MsgBoxStyle.Critical)
            Throw New CustomException
        End If

        'Open tool by name
        pGPTool = pGPToolbox.OpenTool("QuickExport")    'You need to use QuickImport

        'Get parameters required for the tool
        pParamArray = pGPTool.ParameterInfo

        If Not (Inv_Layer_Names Is Nothing Or String.IsNullOrEmpty(Inv_Layer_Names) Or Inv_Layer_Names = "") Then
            'Remove trailing ";"
            Inv_Layer_Names = Inv_Layer_Names.Remove(Inv_Layer_Names.LastIndexOf(";"))

            'Set input parameters
            pParameter = pParamArray.Element(0)
            pParameterEdit = pParameter
            pDataType = pParameter.DataType
            pParameterEdit.Value = pDataType.CreateValue(Inv_Layer_Names)

            'Set output parameters
            pParameter = pParamArray.Element(1)
            pParameterEdit = pParameter
            pDataType = pParameter.DataType
            pParameterEdit.Value = pDataType.CreateValue("GMLSF, " & FILE_STORAGE_PATH.Substring(0, FILE_STORAGE_PATH.LastIndexOf(".")) & ".gml")

            'Validate input parameters
            pGPMessages = pGPTool.Validate(pParamArray, True, Nothing)

            'Execute tool for at least inventory layers
            pGPTool.Execute(pParamArray, pProgressTracker, pGPEnvMgr, pGPMessages)
        End If           

    Catch ex As Exception
        Throw New CustomException(ex.Message, ex)
    Finally
        'Release resources           
        pGPMessages = Nothing
        pParameterEdit = Nothing
        pDataType = Nothing
        pParameterEdit = Nothing
        pParameter = Nothing
        pParamArray = Nothing
        pGPTool = Nothing
        pGPToolbox = Nothing
        pToolboxWorkspace = Nothing
        pToolboxWorkspaceFactory = Nothing
        pGPEnv_Extent = Nothing
        pGPEnv_CoordSys = Nothing
        pGPEnvMgr = Nothing
        pGPCOMHelper = Nothing
        pProgressTracker = Nothing
    End Try
End Sub
share|improve this answer
    
Hi, thanks for your answer :) I should probably have specified that I'm using arcMap 10. From this resource help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/… It would seem that the FMEWorkspaceFactory has been removed going from 9.3 -> 10.0. Do you know if there are any alternatives to using the FMEWorkspaceFactoryClass you specified in your example? Best regards /larssj –  user2847 Jun 6 '11 at 13:26
    
Ohh...I did not know that it has been removed. If I'm not wrong, then the DI toolbox wouldn't be available either... –  ujjwalesri Jun 7 '11 at 4:23
    
Ok, no problem mate. Thanks for your help. If I find a solution, I post it here. The only thing I can think of now is going 'behind the scenes' and add the fdl files required for adding the services to ArcView (If put in the correct ArcView directory, these should be loaded into the interoperability connections interface automatically). This would still be much easier for my users. –  user2847 Jun 7 '11 at 5:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.