exception of HRESULT:  0X80004002 (E_NOINTERFACE))

1403
1
08-09-2011 03:23 AM
MaheshManda
New Contributor
The COM object of the type ???System.__ComObject" cannot be transformed into the interface type ???ESRI.ArcGIS.esriSystem.IRequestHandler???.  This process could not be carried out, not carried out become could there the QueryInterface proclamation at the COM component for the interface with the IID ???{46A0E2EA-3B64-4A46-BD78-88A1660F35BB}??? based on the following mistake:  Interface does not support (exception of HRESULT:  0X80004002 (E_NOINTERFACE)). 



Here is the sample code..

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.EnterpriseServices;
using ESRI.ArcGIS.Server;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.SOESupport;
using System.Collections.Specialized;

namespace SimpleRESTSOE
{
    [ComVisible(true)]
    [Guid("4446A422-DDA1-4b17-B8E5-73E5D49D7444")]
    [ClassInterface(ClassInterfaceType.None)]
    public class SimpleRESTSOE : ServicedComponent, IServerObjectExtension, IObjectConstruct, IRESTRequestHandler, ILog
    {
       
        private IRESTRequestHandler _reqHandler;

        public SimpleRESTSOE()
        {
           
            RestResource rootResource = CreateRestSchema();
           
            SoeRestImpl restImpl = new SoeRestImpl("SimpleRESTSOE", rootResource);
          
            _reqHandler = (IRESTRequestHandler)restImpl;
        }
      
        public void Init(IServerObjectHelper pSOH) {
           
        }

        public void Shutdown() { }

        public void Construct(IPropertySet props) { }

        private RestResource CreateRestSchema()
        {
           
            RestResource soeResource = new RestResource("SimpleRESTSOE", false, RootSOE);

          
            RestOperation findNearFeatsOp = new RestOperation("echo",

                                                      new string[] { "text" },
                                                      new string[] { "json" },
                                                      EchoInput);

            soeResource.operations.Add(findNearFeatsOp);
           
            return soeResource;
        }

        public string GetSchema()
        {
            return _reqHandler.GetSchema();
        }

        byte[] IRESTRequestHandler.HandleRESTRequest(string Capabilities,
            string resourceName,
            string operationName,
            string operationInput,
            string outputFormat,
            string requestProperties,
            out string responseProperties)
        {
            return _reqHandler.HandleRESTRequest(Capabilities, resourceName, operationName, operationInput, outputFormat, requestProperties, out responseProperties);
        }

        private byte[] RootSOE(System.Collections.Specialized.NameValueCollection boundVariables,
            string outputFormat,
            string requestProperties,
            out string responseProperties)
        {
            responseProperties = null;
            JsonObject jObject = new JsonObject();
            return Encoding.UTF8.GetBytes(jObject.ToJson());
        }

        private byte[] EchoInput(System.Collections.Specialized.NameValueCollection boundVariables,
            ESRI.ArcGIS.SOESupport.JsonObject operationInput,
            string outputFormat,
            string requestProperties,
            out string responseProperties)
        {
            responseProperties = null;

             string inputText;
           bool found = operationInput.TryGetString("text", out inputText);
            JsonObject result = new JsonObject();
            result.AddString("text", inputText);
            string json = result.ToJson();

            return Encoding.UTF8.GetBytes(json);


            if (!found || !operationInput.TryGetString("text", out inputText))
                throw new ArgumentNullException("text");
            JsonObject jObject = new JsonObject();
            jObject.AddString("text", inputText);
            return Encoding.UTF8.GetBytes(jObject.ToJson());
        }

        #region ILog Members

        public void AddMessage(int msgType, int msgCode, string msg)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}

I am not able to solve this..Anybody can help in this..please

I am not able to see the json request and also the map server is not visible with this message with the SOE extension.
1 Reply
RichardWatson
Frequent Contributor
My suggestion is to write a trivial program which creates an instance of your class and casts it to IRequestHandler.  Does it work?
0 Kudos