Note that there are some explanatory texts on larger screens.

plurals
  1. POCreating a Service Host?
    primarykey
    data
    text
    <p>I have created a WCF service.And i am trying to call it from another domain.I have enabled the cross domain option.But my doubt i about how to create a service host??</p> <pre><code>!-&lt;%@ ServiceHost Language="C#" Debug="true" Service="jsonwcf.Service1" CodeBehind="Service1.svc.cs" Factory="System.ServiceModel.Activation.WebScriptServiceHostFactory%&gt; </code></pre> <p>When i am changing the markup to this.it shows servicehost missing.what should i do??</p> <h2>service.cs</h2> <pre><code>namespace jsonwcf { [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together. public class Service1 : IService1 { [WebInvoke( Method = "GET", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest )] public List&lt;UserDetails&gt; SelectUserDetails() { pasDataContext db = new pasDataContext(); List&lt;UserDetails&gt; results = new List&lt;UserDetails&gt;(); foreach (User u in db.Users) { results.Add(new UserDetails() { UserID = u.UserID, EmpName = u.EmpName, Email = u.EmailID, UserName = u.UserName, UserRole = u.UserRole, Password = u.Password, Telephone = u.Telephone }); } return results; } [WebInvoke( Method = "POST", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest )] public string ins(string uid, string pwd, string uname, string ename, string tel, string urole, string eid) { pasDataContext db = new pasDataContext(); User u = new User(); u.UserID = uid; u.UserName = uname; u.UserRole = urole; u.Telephone = tel; u.Password = pwd; u.EmailID = eid; u.EmpName = ename; db.Users.InsertOnSubmit(u); db.SubmitChanges(); return "inserted successfully"; } } } </code></pre> <h2>iservice.cs</h2> <pre><code>namespace jsonwcf { [ServiceContract(Namespace = "JsonpAjaxService")] public interface IService1 { [OperationContract] [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] List&lt;UserDetails&gt; SelectUserDetails(); [OperationContract] [WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped,UriTemplate = "Service/ins")] string ins(string uid, string pwd, string uname, string ename, string tel, string urole,string eid); } [DataContract] public class UserDetails { [DataMember] public string UserID { get; set; } [DataMember] public string Password { get; set; } [DataMember] public string UserName { get; set; } [DataMember] public string Email { get; set; } [DataMember] public string EmpName { get; set; } [DataMember] public string UserRole { get; set; } [DataMember] public string Telephone { get; set; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload