I'm trying to create a wcf service inside a c# mvc web project. I've added a new item of type "WCF Service" and added a test method in the provided Interface:
[ServiceContract]
public interface ITest
{
[OperationContract]
void DoWork();
bool testWorking();
}
And the provided service:
public class Test : ITest
{
public void DoWork()
{
}
public bool testWorking()
{
return true;
}
}
And I've then gone over to the web.config file and added the following to the system.ServiceModel tag:
<services>
<service name="Test" behaviorConfiguration="MyServiceTypeBehaviors">
<endpoint address="" binding="wsHttpBinding" contract="ITest">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceTypeBehaviors" >
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
At this point, as I understand it, I should be able to view this in a browser and get a test message telling me that it's about time I implemented a client to use this service. However what actually happens is that my browser downloads the .svc file!
Two questions:
1) What the hell am I doing wrong? Why am I not seeing the expected message?
2) Is there any way I can automatically start the WCF testing tool to run on this service? The only guidelines I can find are for starting from a WCF project.
Update: (content of svc file - grabbed from comment)
<%@ ServiceHost Language="C#" Debug="true"
Service="myemployersaddress.com.Test" CodeBehind="Test.svc.cs" %>
From what you've described you should be fine, but since you're not:
To start the test tool from inside visual studio, right click on the .svc file and 'set as start page' and then hit f5. That should open the test tool and allow you to inspect your service. That should give you some clues as to what the problem is.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With