WCF Endpoint Address in VS 2010 - c#

I have a simple web service. This is consumed in a website using VS 2010. I added the service reference using “Add Service Reference” option in VS 2010. It works fine. It prints the service address as http://localhost:3187/Service1.svc/MyFolder. But when I type this service address in a browser it says HTTP Error 400.
Note: When I replace the address="MyFolder" with address="" in service’s end point, http://localhost:3187/Service1.svc shows the result.
What is the correct address that I should type in the browser to get the service with “MyFolder” in address?
The page:
namespace ClientWebApp
{
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Service1Client myClientService = new Service1Client();
Response.Write(myClientService.Endpoint.Address);
string result = myClientService.GetData(7);
lblName.Text = result;
}
}
}
The contract:
namespace MyWCFServiceApplication
{
[ServiceContract]
public interface IService1
{
[OperationContract]
string GetData(int value);
}
public class MyService : IService1
{
public string GetData(int value)
{
return string.Format("Now entered: {0}", value);
}
}
}
The configuration:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="MyWCFServiceApplication.MyService"
behaviorConfiguration="WeatherServiceBehavior">
<endpoint address="MyFolder"
binding="wsHttpBinding"
contract="MyWCFServiceApplication.IService1" />
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WeatherServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="False"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>

Please take a look at the answer to this question: WCF Endpoints & Binding Configuration Issues
Quote:
When hosting a WCF service in IIS, the base address of the service is formed using the following format:
{protocol}://{host}:{port}/{applicationName}/{svcFileName}. This is
the address you can browse to get the WCF help page and/or the
metadata (on a default configuration).
To form the actual address of the endpoint (the one your client needs
to use), the following format is used:
{serviceBaseAddress}/{endpointAddress}
In your case the {endpointAddress} is MyFolder which explains why you're able to add service reference using http://localhost:3187/Service1.svc/MyFolder address. However this is not the address where your help page and metadata info gets rendered so the fact that you get HTTP Error 400 on http://.../*.svc/MyFolder is no surprise.

try adding "?wsdl" to the end of the url you are trying with.

Related

Call one WCF service application from another by making service reference [duplicate]

I'm just learning how to use WCF and I am trying to write a little HelloWorld program from scratch (both the host and client sides). I've been getting a ProtocolException Unhandled whenever my client tries to use the service, and I can't figure out why. I'm hosting the service using IIS.
Regarding the way I have things set up: I'm doing my best to separate the client, proxy, host, service, and contract as detailed in this video and as outlined in this article. Basically I've got different projects within the solution for each of those.
Here are some different files showing what I'm talking about:
Service
namespace HelloWorld
{
public class HelloWorldService : IHelloWorldService
{
public String GetMessage(String name)
{
return "Hello World from " + name + "!";
}
}
}
Contract
namespace HelloWorld
{
[ServiceContract]
public interface IHelloWorldService
{
[OperationContract]
String GetMessage(String name);
}
}
Proxy
namespace HelloWorld
{
public class Proxy : ClientBase<IHelloWorldService>, IHelloWorldService
{
#region IHelloWorldService Members
public String GetMessage(String name)
{
return Channel.GetMessage(name);
}
#endregion
}
}
Client
namespace Client
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click_1(object sender, EventArgs e)
{
Proxy proxy = new Proxy();
MessageBox.Show(proxy.GetMessage(textBox1.Text));
}
}
}
The client is just a form with a textbox and a button, and it tries to execute GetMessage() using whatever is in the textbox as a parameter. There is another class that actually creates an instance of the form.
Here's my web.config for the website:
Web.config
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceTypeBehaviors">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="HelloWorld.HelloWorldService" behaviorConfiguration="MyServiceTypeBehaviors">
<endpoint address="http://localhost:8002/" binding="basicHttpBinding" contract="HelloWorld.IHelloWorldService"/>
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex"/>
</service>
</services>
</system.serviceModel>
</configuration>
And here's my app.config that goes with the client:
app.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<client>
<endpoint address="http://localhost:8002/" binding="basicHttpBinding" contract="HelloWorld.IHelloWorldService" />
</client>
</system.serviceModel>
</configuration>
My svc file is very short, just:
HelloWorldService.svc
<%#ServiceHost Service="HelloWorld.HelloWorldService"%>
I know the service is running, because when I navigate to http://localhost:8002/HelloWorldService.svc in my browser I get the screen that says
You have created a service.
To test this service, you will need to create a client and use it to
call the service.
So here's where the snag happens: the service is running using IIS, I start an instance of the client, the window with the textbox and the button come up, I type in some letters, hit the button, and then the program crashes and I get the ProtocolException Unhandled, (405) Method not allowed. The error happens on this line of the Proxy class:
return Channel.GetMessage(name);
I've been trying to figure this out for hours and hours, and I haven't made much progress. If someone could at least point me in the right direction, I would be very appreciative.
Last thing: I want to write the client and proxy from scratch, without using svcutil.exe.
The reason it works when you go to the base address (.svc) is that this is an HTTP GET operation to get the metadata for the service. When you call a method on your service contract, you're doing a POST operation and more than likely you just don't have this feature enabled. Depending on the .NET version you're targeting, it will be one of these highlighted in red.
You have to specify full address for your service in the endpoint tag of Client configuration.
Like this:
<endpoint address="http://localhost:8002/HelloWorldService.svc" binding="basicHttpBinding" contract="HelloWorld.IHelloWorldService" />
Do not forget to add '.svc' extension after your service name in address attribute of endpoint tag. It worked for me. Hope you will get the solution now.
Client config will look like this:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IService"/>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:61569/Service1.svc" binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IService" contract="WcfServiceApp.IService1" name="WSHttpBinding_IService"/>
</client>
Ok, found a solution, although I'm not entirely sure why it works. I guess when you are using Cassini or IIS or whatever to host the website, you're not supposed to specify an address in the endpoint in the web.config file. All I had to do was change it to address="" and it started working properly. Be sure to make sure the port your server is hosting the service on matches the code in your app.config file.
You have to specify full address for your service in the endpoint tag of Client configuration
address="http://localhost:8002/HelloWorldService.svc", where you put same endpoint configurations.
It did work for me while I trapped in hell...
Enabling below two components, worked for me.

How to create a web service in c# using web.conf

I am fairly new to the C# world so I don't know much. I can't even find simple step by step documentation on how to set up a simple service without using the built in templates in Visual Studios.
I would prefer to use the following class and web.conf to make my service. I do not want to use anything that is going to depend on visual studios or IIS magic like .asmx files.
I can't seem to get my server to respond to it. When i go to localhost:8152/02/service or localhost:8152/02/service/echo2, I get a 404 error.
I have the following in my web.conf file.
<system.serviceModel>
<services>
<service name ="hessian.test.HessianService" behaviorConfiguration="HttpGetMetadata">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8152/02/service"/>
</baseAddresses>
</host>
<endpoint address="/echo2" contract="hessian.test.HessianService.sayHello" binding="wsHttpBinding"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name ="HttpGetMetadata">
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings />
<client />
</system.serviceModel>
This is in my .cs file
namespace hessian.test{
public class HessianService : WebService, testInterface
{
public void runVoid(int count)
{
}
public string sayHello()
{
return "Hello";
}
public string repeatMe(string s)
{
return s;
}
}
}
Any help would be appreciated.
I suggest taking a look at Getting Started with WCF. WCF operates with .svc files instead of .asmx. Here's a comparison.
In your example you'll need to create contracts like so:
using System.IO;
using System.ServiceModel;
using System.ServiceModel.Web;
namespace WcfService1
{
[ServiceContract]
public interface IService
{
[OperationContract]
[WebGet(UriTemplate = "sayhello")]
Stream SayHello();
}
}
Then an implementation can look like this:
using System.IO;
using System.ServiceModel.Web;
using System.Text;
namespace WcfService1
{
public class Service : IService
{
public Stream SayHello()
{
WebOperationContext.Current.OutgoingResponse.ContentType = "text/plain";
return new MemoryStream(Encoding.UTF8.GetBytes("hello"));
}
}
}
And of course, the all important web.config, notice the serviceHostingEnvironment element, it is required if you don't want to create a .svc file, although a .svc file doesn't require IIS, you can host it anywhere.
<system.serviceModel>
<services>
<service name="WcfService1.Service">
<endpoint address="" binding="webHttpBinding" contract="WcfService1.IService"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior>
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment>
<serviceActivations>
<add factory="System.ServiceModel.Activation.ServiceHostFactory" relativeAddress="./sayhello.svc" service="WcfService1.Service"/>
</serviceActivations>
</serviceHostingEnvironment>
</system.serviceModel>
There are quite a few things you need to get right before the service can even work:
applying ServiceContract and OperationContract to the service and operation declarations respectively
applying WebGet attribute to the operation so that it'll respond to a GET request
configuring service and behaviors so WCF can read them and handle things appropriately
WCF is powerful but it's also quite a bit to take in, which was why I suggested WebApi at first. It has a much more gentle learning curve, assuming you want to use REST as opposed to SOAP. There are also alternatives like NancyFx and ServiceStack

ProtocolException Unhandled/(405) Method not allowed with WCF; Bindings and Endpoints look right though

I'm just learning how to use WCF and I am trying to write a little HelloWorld program from scratch (both the host and client sides). I've been getting a ProtocolException Unhandled whenever my client tries to use the service, and I can't figure out why. I'm hosting the service using IIS.
Regarding the way I have things set up: I'm doing my best to separate the client, proxy, host, service, and contract as detailed in this video and as outlined in this article. Basically I've got different projects within the solution for each of those.
Here are some different files showing what I'm talking about:
Service
namespace HelloWorld
{
public class HelloWorldService : IHelloWorldService
{
public String GetMessage(String name)
{
return "Hello World from " + name + "!";
}
}
}
Contract
namespace HelloWorld
{
[ServiceContract]
public interface IHelloWorldService
{
[OperationContract]
String GetMessage(String name);
}
}
Proxy
namespace HelloWorld
{
public class Proxy : ClientBase<IHelloWorldService>, IHelloWorldService
{
#region IHelloWorldService Members
public String GetMessage(String name)
{
return Channel.GetMessage(name);
}
#endregion
}
}
Client
namespace Client
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click_1(object sender, EventArgs e)
{
Proxy proxy = new Proxy();
MessageBox.Show(proxy.GetMessage(textBox1.Text));
}
}
}
The client is just a form with a textbox and a button, and it tries to execute GetMessage() using whatever is in the textbox as a parameter. There is another class that actually creates an instance of the form.
Here's my web.config for the website:
Web.config
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceTypeBehaviors">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="HelloWorld.HelloWorldService" behaviorConfiguration="MyServiceTypeBehaviors">
<endpoint address="http://localhost:8002/" binding="basicHttpBinding" contract="HelloWorld.IHelloWorldService"/>
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex"/>
</service>
</services>
</system.serviceModel>
</configuration>
And here's my app.config that goes with the client:
app.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<client>
<endpoint address="http://localhost:8002/" binding="basicHttpBinding" contract="HelloWorld.IHelloWorldService" />
</client>
</system.serviceModel>
</configuration>
My svc file is very short, just:
HelloWorldService.svc
<%#ServiceHost Service="HelloWorld.HelloWorldService"%>
I know the service is running, because when I navigate to http://localhost:8002/HelloWorldService.svc in my browser I get the screen that says
You have created a service.
To test this service, you will need to create a client and use it to
call the service.
So here's where the snag happens: the service is running using IIS, I start an instance of the client, the window with the textbox and the button come up, I type in some letters, hit the button, and then the program crashes and I get the ProtocolException Unhandled, (405) Method not allowed. The error happens on this line of the Proxy class:
return Channel.GetMessage(name);
I've been trying to figure this out for hours and hours, and I haven't made much progress. If someone could at least point me in the right direction, I would be very appreciative.
Last thing: I want to write the client and proxy from scratch, without using svcutil.exe.
The reason it works when you go to the base address (.svc) is that this is an HTTP GET operation to get the metadata for the service. When you call a method on your service contract, you're doing a POST operation and more than likely you just don't have this feature enabled. Depending on the .NET version you're targeting, it will be one of these highlighted in red.
You have to specify full address for your service in the endpoint tag of Client configuration.
Like this:
<endpoint address="http://localhost:8002/HelloWorldService.svc" binding="basicHttpBinding" contract="HelloWorld.IHelloWorldService" />
Do not forget to add '.svc' extension after your service name in address attribute of endpoint tag. It worked for me. Hope you will get the solution now.
Client config will look like this:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IService"/>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:61569/Service1.svc" binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IService" contract="WcfServiceApp.IService1" name="WSHttpBinding_IService"/>
</client>
Ok, found a solution, although I'm not entirely sure why it works. I guess when you are using Cassini or IIS or whatever to host the website, you're not supposed to specify an address in the endpoint in the web.config file. All I had to do was change it to address="" and it started working properly. Be sure to make sure the port your server is hosting the service on matches the code in your app.config file.
You have to specify full address for your service in the endpoint tag of Client configuration
address="http://localhost:8002/HelloWorldService.svc", where you put same endpoint configurations.
It did work for me while I trapped in hell...
Enabling below two components, worked for me.

ServiceAuthorizationManager not called

I have a very simple ServiceAuthorizationManager (perhaps the simplest) and have followed various tutorials on the web but for some reason none of my breakpoints are hit and this leads to me thinking that its not being called.
Created a WCF Service Application named it WcfTest
Kept the default classes Service1.svc, IService.cs but changed method to return a string
Added a new class that inherits from ServiceAuthorizationManager
Overridden the method CheckAccessCore()
Adjusted web.config so that it uses this manager class
Run the WCF Service Application
Assembly is called WcfTest
All classes live in root of the project no folders or anything
Invoke the method and at this point I am expecting my ServiceAuthorizationManager to be called or am I wrong here? I thought the whole purpose of it was to hit the custom ServiceAuthorizationManager on every request received?
Thanks in advance, Onam.
Any more info required let me know, will be watching this like a hawk as I am very confused when this should apparently be very simple.
[ServiceContract]
public interface IService1
{
[OperationContract]
[WebGet(UriTemplate = "/getIt",ResponseFormat=WebMessageFormat.Json)]
string GetIt();
}
public class Service1 : IService1
{
public string GetIt()
{
return "boo!";
}
}
public class MyServiceMan : ServiceAuthorizationManager
{
protected override bool CheckAccessCore(OperationContext operationContext)
{
try
{
//Some stuff here breakpoint set on above line not hit
return false;
}
catch (Exception e)
{
return false;
}
}
}
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="WcfTest.Service1">
<endpoint address=""
contract="WcfTest.IService1"
binding="webHttpBinding">
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
<serviceAuthorization serviceAuthorizationManagerType="WcfTest.MyServiceMan,WcfTest" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
Are you missing endpoint behavior?
behaviorConfiguration="WebHttpEndpointBehavior"
<endpointBehaviors>
<behavior name="WebHttpEndpointBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
I had the same problem. I resolved it by setting breakpoint in my CustomAuthorizationManager CheckAccessCore method and start debugging my WCF project in Visual Studio. Then I run from my desktop WCF Client App and execute some method and it's done.

Combining WCF SOAP and REST

The REST project works fine, this can be accessed through this address:
http://localhost:8525/Device/Login?deviceID=testid&password=a&serialNum=testserial
I also have WCF SOAP project in my REST project, these two projects are separated in different folders, "SOAP" and "REST".
My problem is that, after I put this code:
private void RegisterRoutes()
{
RouteTable.Routes.Add(new ServiceRoute("Device", new WebServiceHostFactory(), typeof(Rest.DeviceComponent)));
}
I can't access now the SOAP service which I was able to access before through this address:
http://localhost:8525/DeviceComponent.svc (using WCFTest Client)
Here is the WebConfig
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" />
<standardEndpoints>
<webHttpEndpoint>
<!--
Configure the WCF REST service base address via the global.asax.cs file and the default endpoint
via the attributes on the <standardEndpoint> element below
-->
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"/>
</webHttpEndpoint>
</standardEndpoints>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</modules>
<handlers>
<add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd"/>
</handlers>
</system.webServer>
</configuration>
And inside Global.asax.cs
private void RegisterRoutes()
{
RouteTable.Routes.Add(new ServiceRoute("Device", new WebServiceHostFactory(), typeof(Rest.DeviceComponent)));
}
SOAP sample contract
namespace TSDEVICE.SoapSVC.Interface
{
[ServiceContract]
public interface IDeviceComponent
{
[OperationContract]
Session Login(string deviceID, string password, string serialNum, string ip);
[OperationContract]
bool Logout(DeviceSession session);
[OperationContract]
bool IsLatestVersion(DeviceSession session, int version);
[OperationContract]
byte[] DownloadLatest(DeviceSession details);
[OperationContract]
DateTime GetServerTime(DeviceSession session, long branchID);
[OperationContract]
bool AddDevice(UserSession session, Device deviceitem);
[OperationContract]
bool RemoveDevice(UserSession session, long deviceID);
}
}
And the REST part:
namespace TSDEVICE.Rest
{
[ServiceContract]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
public class DeviceComponent
{
[WebInvoke(UriTemplate = "Login?deviceID={deviceID}&password={password}&serialNum={serialNum}", Method = "POST")]
[OperationContract]
public TMODELDEVICE.Entities.Session Login(string deviceID, string password, string serialNum)
{
string ip = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
TMODELDEVICE.Logic.DeviceComponent restDC = new TMODELDEVICE.Logic.DeviceComponent();
return restDC.Login(deviceID, password, serialNum, ip);
}
public string Sample()
{
return "Hello";
}
}
}
I have to access SOAP and REST, how can I do that? Thanks a lot!
EDIT
When I try to "Set as Start page" the .svc file, I get this error:
Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata.
EDIT 2
Now I found out the real problem.
When ASP.NET compatibility mode in the web.config == true, SOAP fail to work, while REST requires it. What should I do with this? Thanks
I have a REST project that as both REST and SOAP service being exposed. Now I placed an .svc file for the SOAP service to be accessed by some clients.
The below screenshot gives the folder structure of my project, the route configuration in global.asax, Output accessing the Rest Service and accessing the .svc file (SOAP service)
UPDATE:
Please find my web.Config (My application is hosted on IIS):
Please find my class that implements my interface ISampleService:
While I appreciate the solutions listed above - I have a found it is far easier to manage/deploy if you don't over think the problem and follow a KISS principle.
Service Contract: IService.cs
namespace DontTazeMe.Bro
{
[ServiceContract]
public interface IService
{
[OperationContract]
[WebGet]
List<GeoMapData> GetToTheChopper();
}
}
Implementation: Service.cs
namespace DontTazeMe.Bro
{
public class WSDLService : IService
{
public List<GeoMapData> GetToTheChopper()
{
return ItsNotEasyBeingChessy.Instance.GetToTheChopperGeoData();
}
}
public class RESTService : WSDLService
{
// Let's move along folks, nothing to see here...
// Seriously though - there is no need to duplicate the effort made in
// the WSDLService class as it can be inherited and by proxy implementing
// the appropriate contract
}
}
Configuration
<system.serviceModel>
<services>
<!-- SOAP Service -->
<service name="DontTazeMe.Bro.WSDLService">
<endpoint address="" binding="basicHttpBinding" contract="DontTazeMe.Bro.IService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/DontTazeMe.Bro/Service/" />
</baseAddresses>
</host>
</service>
<service name="DontTazeMe.Bro.RESTService">
<endpoint address="" binding="webHttpBinding" contract="DontTazeMe.Bro.IService" behaviorConfiguration="Restful" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/DontTazeMe.Bro/Rest/Service/" />
</baseAddresses>
</host>
</service>
<behaviors>
<endpointBehaviors>
<behavior name="Restful">
<webHttp defaultOutgoingResponseFormat="Json" defaultBodyStyle="Wrapped" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
This method works just fine without getting carried away with configuration

Categories