Hi I am using WCF Rest in my app with a layered architecture. My dataflow heirarchy is given below:
Data Layer -> Linq2Sql
||
Business Layer
||
WCF Rest Service
||
ASPX Pages
I am using JSON via JQuery to Select/Delete and codebehind to Insert/Update so as I can pass .Net objects to database base through my business layer(to check if i have business logic for them.) using WCF servive.
Forexample , I am ciphering password and deciphering password in my business layer and sending it to datalayer.Anyways, thats not the Issue. The issue is with WCF service configurationsettings. Every time i am getting unique exceptions like:
What I tried is
As per answer suggested by Tom Haigh. protected Save_Click(sender,e) {
var user = new User { Login = login.Value, Password = pwd.Value, RealName = realname.Value, AccessRight = accessrights.Value, CustomAccesRight = customaccessrights.Value };
var remoteAddress = new EndpointAddress("http://localhost:2360/UserService.svc");
using (var client = new UserServiceClient(new BasicHttpBinding(), remoteAddress))
{
//set timeout
client.Endpoint.Binding.SendTimeout = new TimeSpan(0, 0, 0, 10000);
//call ws method
client.Insert(user);
} //using
}
I removed using an tried also, got Error 400
protected Save_Click(sender,e) {
var user = new User { Login = login.Value, Password = pwd.Value, RealName = realname.Value, AccessRight = accessrights.Value, CustomAccesRight = customaccessrights.Value };
var remoteAddress = new EndpointAddress("http://localhost:2360/UserService.svc");
var client = new UserServiceClient(new BasicHttpBinding(), remoteAddress);
//set timeout
client.Endpoint.Binding.SendTimeout = new TimeSpan(0, 0, 0, 10000);
//call ws method
client.Insert(user);
}
My Config file of Service:
<system.serviceModel>
<services>
<service name="EnergyManagementControl.WcfSvc.UserService" behaviorConfiguration="ServiceBehaviour" >
<endpoint name="" binding="webHttpBinding" contract="EnergyManagementControl.WcfSvc.IUserService" address="http://localhost:2360/UserService.Svc" behaviorConfiguration="web"></endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviour" >
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
My Config file of Client
<system.serviceModel>
<client>
<endpoint
name = "Receptor"
address="http://localhost:2360/UserService.Svc"
binding = "wsHttpBinding"
contract="IUserService"
/>
</client>
</system.serviceModel>
But nothing seems to help. I know its config error ,please help me. Also any brief reference on WCF rest based on my scenario will be great help.....
Please not the WCF is created as a WCF Service Application and is a project in my Solution with my Web app. See image below:
Also I am getting error on WebDev Server,not on IIS or Cassini
I can't speak much to WCF usage for REST services, but your service & client endpoint bindings do not match. WCF uses the binding to find a matching endpoint.