Creating WCF services in mono 2.8.2

2019-05-17 19:26发布

问题:

I had mono-2.6.7 installed and and a WCF service:

<system.serviceModel>
    <behaviors>
        <endpointBehaviors>
             <behavior name="RestB"><webHttp/></behavior>
        </endpointBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
    <services>
      <service name="Rest">
        <endpoint address="" behaviorConfiguration="RestB" binding="webHttpBinding" contract="Rest" />
      </service>
    </services>
</system.serviceModel>

It worked.

I wanted to use multiple endpoints and I kept getting errors as soon as I specified the address, so I decided to try mono 2.8.2. After installing 2.8.2 (after adding serviceBehavior which mono complained about) I started getting:


"HttpListenerContext does not match any of the registered channels"
System.InvalidOperationException: HttpListenerContext does not match any of the registered channels
  at System.ServiceModel.Channels.Http.HttpListenerManager.ProcessNewContext (System.ServiceModel.Channels.Http.HttpContextInfo ctxi) [0x00000] in :0 
  at System.ServiceModel.Channels.SvcHttpHandler.ProcessRequest (System.Web.HttpContext context) [0x00000] in :0 
  at System.Web.HttpApplication+c__Iterator2.MoveNext () [0x00000] in :0 
  at System.Web.HttpApplication.Tick () [0x00000] in :0 

when trying to access urls which worked in mono-2.6.7.

I tried with both mod-mono-server2 and mod-mono-server4.

I tried to look up this problem but I couldn't find anything.

Could someone show me a working example of a WCF service in mono-2.8.2 or mono-2.6.7 configuration with multiple endpoints?

UPDATE: After reverting to mono-2.6.7 the my service 'Rest' shown above works again.

Thanks in advance gurus

Thanks Tymek

回答1:

The problem (affecting 2.10 as well) is that UriTemplate/{var1}/{var2} don't work in 2.8 and 2.10.1. I substituted them with UriTemplate?x={var1}&y={var2}. Not ideal, but will do for me for now.



回答2:

The last question was really old and the issue still happening in mono 2.10. Fortunately, there is a new project to bring WCF to Linux.

The new libraries are located here

https://github.com/dotnet/wcf

I'm going to try them in Ubuntu and I will post an update about it.

https://github.com/dotnet/wcf/blob/master/Documentation/building/unix-instructions.md



标签: wcf mono