Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing an ASP.Net class object (asp.net project is WCF service) from ajax (jquery)
    primarykey
    data
    text
    <p>I have a WCF service which sends string lists from client(jquery web pages).The wcf project runs perfect in visual studio when I run it with F5,a window is opening and I'm clicking Invoke after I can see the list object under the Invoke.I will using my list datas in jquery so I'm using ajax to call my wcf service,all configuration settings are right. I'm using <code>abc</code> class which have a list veriable,and I have a function data which sets some data to that list. Here is my Service contract and Data contract form WCF(IService1.cs):</p> <pre><code>namespace kgms { [ServiceContract] public interface IService1 { [OperationContract] [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)] abc data(abc obj); } [DataContract] public class abc { [DataMember] public List&lt;string&gt; sval { get; set; } [DataMember] public List&lt;string&gt; kval { get; set; } } } </code></pre> <p>And here is my data function info(Service1.svc.cs):</p> <pre><code>namespace kgms { [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] public class Service1 : IService1 { public abc data(abc obj) { obj.sval.Add("asd"); obj.sval.Add("sdf"); obj.kval.Add("example"); obj.kval.Add(":-)"); return obj; } } } </code></pre> <p>I will access from that ajax call:</p> <pre><code>$('#buton').click(function () { Type = "POST"; Url = "http://compname/sil/Service1.svc/data"; ContentType = "application/json; charset=utf-8"; DataType = "json"; var ProcessData = true; CallService(); }); function CallService() { $.ajax({ type: Type, url: Url, data: Object, contentType: ContentType, dataType: DataType, processdata: ProcessData, success: function (msg) { ServiceSucceeded(msg); }, error: ServiceFailed }); } function ServiceFailed(result) { alert("basarisiz"); alert('Service call failed: ' + result.status + '' + result.statusText); Type = null; varUrl = null; Data = null; ContentType = null; DataType = null; ProcessData = null; } function ServiceSucceeded(result) { alert("good"); } }); </code></pre> <p>what parameter must I send with <code>Data: Object</code> Object is sample, what must write instead of Object. Because my WCF function is taking an abc class object, what can I do.</p>
    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.
    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