Reputation: 1116
I have a very basic webservice using WCF (C#, .NET 4.0), to return an hello message.
The deployment under IIS 7 and running it is ok, but when I do svcutil.exe http://localhost:4569/Service.svc?wsdl
through the CMD to test the webservice I get:
the remote server returned an error: 415 cannot proccess the message because the content type 'aplication/soap+xml charset=utf8' was not the expected type 'text/xml charset=utf8'
When trying to add the service reference (to create a client) I get
An existing connection was forcibly closed by the remote host Metadata contains a reference that cannot be resolved: 'http://localhost:4569/Service.svc'. Content Type application/soap+xml; charset=utf-8 was not supported by service http://localhost:4569/Service.svc. The client and service bindings may be mismatched. The remote server returned an error: (415) Cannot process the message because the content type 'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'..
I'm pretty sure that the problem is under my Web.config file:
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="Service">
<endpoint name="soap"
address="http://localhost:4569/Service.svc"
binding="basicHttpBinding"
contract="IService" />
<endpoint name="mex" address="mex" binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</services>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
Anyway, here's my code:
IService.cs:
[ServiceContract]
public interface IService
{
[OperationContract]
string getMessage();
}
My service.cs has the method
public class Service : IService
{
public string getMessage()
{
return "Ola servico";
}
}
I really don't know what is happening, did some tests after some research but no success.
Service.svc
<%@ ServiceHost Language="C#" Debug="true" Service="Service" CodeBehind="~/App_Code/Service.cs" %>
Upvotes: 0
Views: 3908
Reputation: 6465
You have no service and endpoint defined in your config. Try adding
<services>
<service name="Service"> <!-- name should match the name in your .svc file (if you open it with a text editor) -->
<endpoint name="soap" address="" binding="basicHttpBinding" contract="IService" />
<endpoint name="mex" address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
Upvotes: 1