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
svcutil
http://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