0

I have a WCF service using basicHttpBinding hosted in Apache 2.2.15, using mod_mono in CentOS. I added the following directives to the end of /etc/httpd/conf/httpd.conf to enable WCF services:

MonoServerPath default /usr/bin/mod-mono-server4
AddType application/x-asp-net .svc

When I try to call an operation in the service from a client in windows:

        BasicHttpBinding binding = new BasicHttpBinding();

    IService1 service1 = ChannelFactory<IService1>.CreateChannel(binding, new EndpointAddress(new Uri(`"http://ipaddress/svctest/Service1.svc"`)));

    string test= service1.GetData(1);

The following Exception is thrown:

ProtocolException was unhandled: The content type application/x-asp-net of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 109 bytes of the response were: '<%@ ServiceHost Language="C#" Debug="true" Service="svcfiletest.Service1" CodeBehind="Service1.svc.cs"% >

When I access the service through the browser it downloads the file instead of showing the service description.

When I use svcutilhttp://ipaddress/svcutil/Service1.svc?wsdl I get the following message:

The document at the url http://ipaddress/svctest/Service1.svc was not recognized as a known document type. The error message from each known type may help you fix the problem: -Report from 'XML Schema' is 'Name cannot begin with the '%' character, hecadecimal value 0x25. Line 1, position 2.'. -Report from 'WSDL Document' is 'There is an error in XML document (1,2).'. -Name cannot begin with the '%' character, hexadecimal value 0x25. Line 1,position 2.

It seems that its getting the text from Service1.svc:

<%@ ServiceHost Language="C#" Debug="true" Service="svcfiletest.Service1" CodeBehind="Service1.svc.cs" %>

Any help?

Thanks

Miguel Marques
  • 2,386
  • 1
  • 20
  • 31

1 Answers1

0

Did you also actually load the module somewhere in your /etc/httpd/conf/httpd.conf ?

You need both the Include /etc/apache2/mod_mono.conf (or put it into a config directory that's included by your http.conf) and the LoadModule mono_module /usr/lib/httpd/modules/mod_mono.so

See http://www.mono-project.com/Mod_mono.

My setup - manually starting mod-mono

I manually compiled mod-mono, this is my mod_mono.conf: http://pastebin.com/qp8vxHQ7. You need to manually start mod-mono-server with this setup.

I checked out this module in ~/Sites/, apache picks that up as http://localhost/~Martin/.

Then, I started mod-mono-server4 in the ~/Sites directory like this:

    mod-mono-server4 --port 9000 --applications /~martin/Service:Service --verbose

This is working fine.

My setup - automatically starting mod-mono

Also tested an alternative setup: http://pastebin.com/tYWk3tC9. This lets apache start mod-mono.

Martin Baulig
  • 3,010
  • 1
  • 17
  • 22
  • I have "Include conf.d/*.conf" and inside /etc/httpd/conf.d I have mod-mono.conf. Inside mono.conf I have " LoadModule mono_module /usr/lib64/httpd/modules/mod_mono.so ". I was able to open the test project that comes with mod_mono in my windows browser with mod-mono-server2. But for a WCF service with mod-mono-server4 its not working. – Miguel Marques Nov 21 '12 at 17:59
  • 1
    Hmm, I just tried and I had to add that `AddType application/x-asp-net .svc` to `mod-mono.conf`. – Martin Baulig Nov 21 '12 at 19:44