Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript proxy classes for compound objects in WCF
    primarykey
    data
    text
    <p>I have a WCF service that I have created and is working. It is a very basic service for now and has the following code:</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; using System.ServiceModel; using System.Text; using System.ServiceModel.Activation; [ServiceContract(Namespace = "TestServiceNameSpace")] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] public class MyTestService { [OperationContract] public MyNamespace.MyCompoundType ReturnMyCompoundType() { return new MyNamespace.MyCompoundType { DateVal = DateTime.Now, IntegerVal = 256, StringVal = "Pedro's test" }; } } </code></pre> <p>Below is the MyCompoundType class</p> <pre><code>using System.Runtime.Serialization; using System; using System.ComponentModel; namespace MyNamespace { [DataContract] public class MyCompoundType : IMyCompoundType { [DataMember] public int IntegerVal { get; set; } [DataMember] public string StringVal { get; set; } [DataMember] public DateTime DateVal { get; set; } } } </code></pre> <p>Now, when I look at the JS file for this service by going to <a href="http://localhost/MyTestService.svc/jsdebug" rel="nofollow">http://localhost/MyTestService.svc/jsdebug</a> (which I then use for making my Ajax calls) I noticed that there is no proxy created for the MyCompoundType. so, when I include this JS file, everything works fine and I can make a call to the service, but I cannot declare a javascript variable of type MyCompoundType (a proxy type that is). Is this even possible? A major part of this is so that we would use the intellisense functionality in the javascript so as to avoid bugs like somebody typing in:</p> <pre><code>var mycompundTypeReturn = returnValueFromWCFCall; alert(mycompoundTypeReturn.StrVal); //this will give us an error because mycompoundTypeReturn.StrVal does not exist, only mycompoundTypeReturn.StringVal exists </code></pre> <p>Is it possible to generate the JS proxy file using svcutil.exe and specifying more detail? Are there any attributes I have missed? Is this even possible? Does this even make sense using WCF?</p> <p>Any help will be greatly appreciated, or even a "You're wasting your time with this, it's impossible and you've missed the point of WCF" reply will be appreciated.</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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