none
Unrecognized message version. error RRS feed

  • Question

  • Hi Folks,

    Please allow me to request to ask and Please help me to sort out error, Thanks a lot in advace..

    I have one WCF Service reference which is i am redirecting via IHttpHandler on request of some page. for example if we will some page like wcfref.aspx when We will hit this page then it will redirect to http://local/WcfBaseServices/CalculatorService.svc?wsdl.

    Now I making proxy via Service Refrence with

    EndpointAddress epa = new EndpointAddress("http://localhost/SingleService/wcfref.aspx");

    BasicHttpBinding objBinding = new BasicHttpBinding();

    ApplicationService.CalculatorClient objCalculatorClient = new ApplicationService.CalculatorClient(objBinding, epa)

    objCalculatorClient.Add(35, 45)

    it throw error like below 

    System.ApplicationException was unhandled
      Message=Unrecognized message version.
      Source=ClientApplication
      StackTrace:
           at ClientApplication.Program.Main(String[] args) in D:\WCFHost\ClientApplication\Program.cs:line 94
           at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
           at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ThreadHelper.ThreadStart()
      InnerException: System.ServiceModel.CommunicationException
           Message=Unrecognized message version.
           Source=mscorlib
           StackTrace:
             Server stack trace: 
                at System.ServiceModel.Channels.ReceivedMessage.ReadStartEnvelope(XmlDictionaryReader reader)
                at System.ServiceModel.Channels.BufferedMessage..ctor(IBufferedMessageData messageData, RecycledMessageState recycledMessageState, Boolean[] understoodHeaders, Boolean understoodHeadersModified)
                at System.ServiceModel.Channels.TextMessageEncoderFactory.TextMessageEncoder.ReadMessage(ArraySegment`1 buffer, BufferManager bufferManager, String contentType)
                at System.ServiceModel.Channels.HttpInput.DecodeBufferedMessage(ArraySegment`1 buffer, Stream inputStream)
                at System.ServiceModel.Channels.HttpInput.ReadBufferedMessage(Stream inputStream)
                at System.ServiceModel.Channels.HttpInput.ParseIncomingMessage(Exception& requestException)
                at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
                at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
                at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
                at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
                at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
                at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
             Exception rethrown at [0]: 
                at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
                at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
                at ClientApplication.ApplicationService.ICalculator.Add(Double firstNumber, Double secondNumber)
                at ClientApplication.ApplicationService.CalculatorClient.Add(Double firstNumber, Double secondNumber) in D:\WCFHost\ClientApplication\Service References\ApplicationService\Reference.cs:line 62
                at ClientApplication.Program.Main(String[] args) in D:\WCFHost\ClientApplication\Program.cs:line 69
           InnerException: 

    Wednesday, April 3, 2013 6:41 AM

Answers

  • Hey,

    Actually i have written

            // Override the ProcessRequest method.
            public void ProcessRequest(HttpContext context)
            {
                context.Response.Redirect("http://local/WcfBaseServices/CalculatorService.svc")
            }
       it will redirect to our base serviceson accessing of *.aspx page.
          


    Hi,

    In wcf restful service you can implement it by creating a RESTful service using an IHttpHandler-derived class, and we can Extract any variables found within the URI and map them to variables or Authenticate and authorize the user responsible for the request as the following code.

    publicclass BookmarkService : IHttpHandler {     publicbool IsReusable { get { returntrue;  } }     publicvoid ProcessRequest(HttpContext context)     {         Uri uri = context.Request.Url;         // compare URI to resource templates and find matchif (Matches(uri, "{username}?tag={tag}"))         {             // extract variables from URI             Dictionary<string, string> vars =                 ExtractVariables(uri, "{username}?tag={tag} ");             string username = vars["username"];             string tag = vars["tag"];

    .............

    }

           

    For re-direction, you can have a try to see if you meet some error.

    This article can help you to well understand it:

    http://msdn.microsoft.com/en-us/library/dd203052.aspx .

    If you have any problem, please let me know.




    • Edited by dns jinung Thursday, April 4, 2013 5:58 AM
    • Marked as answer by ny_rajiv Thursday, April 4, 2013 10:16 AM
    • Unmarked as answer by ny_rajiv Thursday, April 4, 2013 11:16 AM
    • Marked as answer by Haixia_XieModerator Monday, April 15, 2013 1:19 AM
    Thursday, April 4, 2013 5:56 AM

All replies

  • Once you hit your aspx page from there in order to access the WCF service, the endpointaddress should be

    http://local/WcfBaseServices/CalculatorService.svc. In your code it seems you have set it to aspx.


    ViBi

    Wednesday, April 3, 2013 9:28 AM
  • Hey,

    Actually i have written

            // Override the ProcessRequest method.
            public void ProcessRequest(HttpContext context)
            {
                context.Response.Redirect("http://local/WcfBaseServices/CalculatorService.svc")
            }
       it will redirect to our base serviceson accessing of *.aspx page.
          


    • Edited by ny_rajiv Wednesday, April 3, 2013 9:42 AM
    Wednesday, April 3, 2013 9:40 AM
  • I don't think this type of re-direction is possible. Even if it is possible, your WCF service should be RestFul service so that you can pass the function name as parameter in it. Otherwise how you will call the function in your service.

    ViBi

    Wednesday, April 3, 2013 10:20 AM
  • Hi Vkbishnoi,

    Thanks a lot but how we can achieve with  RestFul service.

    Please let me know with some code example.

    Wednesday, April 3, 2013 12:08 PM
  • Hey,

    Actually i have written

            // Override the ProcessRequest method.
            public void ProcessRequest(HttpContext context)
            {
                context.Response.Redirect("http://local/WcfBaseServices/CalculatorService.svc")
            }
       it will redirect to our base serviceson accessing of *.aspx page.
          


    Hi,

    In wcf restful service you can implement it by creating a RESTful service using an IHttpHandler-derived class, and we can Extract any variables found within the URI and map them to variables or Authenticate and authorize the user responsible for the request as the following code.

    publicclass BookmarkService : IHttpHandler {     publicbool IsReusable { get { returntrue;  } }     publicvoid ProcessRequest(HttpContext context)     {         Uri uri = context.Request.Url;         // compare URI to resource templates and find matchif (Matches(uri, "{username}?tag={tag}"))         {             // extract variables from URI             Dictionary<string, string> vars =                 ExtractVariables(uri, "{username}?tag={tag} ");             string username = vars["username"];             string tag = vars["tag"];

    .............

    }

           

    For re-direction, you can have a try to see if you meet some error.

    This article can help you to well understand it:

    http://msdn.microsoft.com/en-us/library/dd203052.aspx .

    If you have any problem, please let me know.




    • Edited by dns jinung Thursday, April 4, 2013 5:58 AM
    • Marked as answer by ny_rajiv Thursday, April 4, 2013 10:16 AM
    • Unmarked as answer by ny_rajiv Thursday, April 4, 2013 11:16 AM
    • Marked as answer by Haixia_XieModerator Monday, April 15, 2013 1:19 AM
    Thursday, April 4, 2013 5:56 AM