<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.dotnetzone.gr:443/cs/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>ASP.NET WebForms</title><link>https://www.dotnetzone.gr:443/cs/forums/13/ShowForum.aspx</link><description>Θέματα για web εφαρμογές, σε ASP.NET WebForms</description><dc:language>el</dc:language><generator>CommunityServer 2.1 SP3 (Build: 20423.1)</generator><item><title>Απ: web service that returns JSON string</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/62906.aspx</link><pubDate>Wed, 02 Feb 2011 02:18:23 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:62906</guid><dc:creator>Παναγιώτης Καναβός</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/62906.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=13&amp;PostID=62906</wfw:commentRss><description>Λοιπόν, αν κατάλαβα καλά τί υποννοεί ο spaceman, λέει ότι αν φτιάξεις ένα κλασσικό asmx web service, το μόνο που χρειάζεται από την πλευρά του service για να επιστρέψει Json είναι να βάλεις το ScriptService attribute στην κλάση, το ScriptMethod attribute στη μέθοδο και να ορίσεις ως ResponseFormat το Json - χωρίς μετατροπές με το χέρι. Έτσι το service που είχα γράψει νωρίτερα γίνεται:&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;pre&gt;&lt;span style="color:Black;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt; [WebService(Namespace &lt;span style="color:Red;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;=&lt;/span&gt; &lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"http://tempuri.org/"&lt;/span&gt;)]
    [WebServiceBinding(ConformsTo &lt;span style="color:Red;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;=&lt;/span&gt; WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(&lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;false&lt;/span&gt;)]
    &lt;span style="color:Green;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. &lt;/span&gt;
    [System.Web.Script.Services.ScriptService]
    &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;public&lt;/span&gt; &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;class&lt;/span&gt; WebService1 : System.Web.Services.WebService
    {

        [WebMethod,ScriptMethod(ResponseFormat=ResponseFormat.Json,&lt;/span&gt;&lt;span style="background-color:transparent;font-family:'Courier New';"&gt;&lt;b&gt;&lt;font class="Apple-style-span" size="2" color="#FF0000"&gt;UseHttpGet=&lt;span style="background-color:transparent;font-family:'Courier New';"&gt;true&lt;/span&gt;&lt;/font&gt;&lt;/b&gt;&lt;span class="Apple-style-span" style="font-size:11px;color:black;"&gt;)]
        &lt;/span&gt;&lt;span style="color:blue;background-color:transparent;font-family:'Courier New';font-size:11px;font-weight:normal;"&gt;public&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size:11px;color:black;"&gt; List&amp;lt;CustomerDetails&amp;gt; GetCustomers()
        {
            &lt;/span&gt;&lt;span style="color:blue;background-color:transparent;font-family:'Courier New';font-size:11px;font-weight:normal;"&gt;using&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size:11px;color:black;"&gt; (var dbContext &lt;/span&gt;&lt;span style="color:red;background-color:transparent;font-family:'Courier New';font-size:11px;font-weight:normal;"&gt;=&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size:11px;color:black;"&gt; &lt;/span&gt;&lt;span style="color:blue;background-color:transparent;font-family:'Courier New';font-size:11px;font-weight:normal;"&gt;new&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size:11px;color:black;"&gt; AdventureWorksEntities())
            {
                var customers &lt;/span&gt;&lt;span style="color:red;background-color:transparent;font-family:'Courier New';font-size:11px;font-weight:normal;"&gt;=&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size:11px;color:black;"&gt; (from customer &lt;/span&gt;&lt;span style="color:blue;background-color:transparent;font-family:'Courier New';font-size:11px;font-weight:normal;"&gt;in&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size:11px;color:black;"&gt; dbContext.Customers
                                 where customer.CustomerType == &lt;/span&gt;&lt;span style="font-family:'Courier New';font-size:11px;font-weight:normal;"&gt;"I"&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size:11px;color:black;"&gt;
                                 select &lt;/span&gt;&lt;span style="color:blue;background-color:transparent;font-family:'Courier New';font-size:11px;font-weight:normal;"&gt;new&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size:11px;color:black;"&gt; CustomerDetails
                                 {
                                     CustomerID &lt;/span&gt;&lt;span style="color:red;background-color:transparent;font-family:'Courier New';font-size:11px;font-weight:normal;"&gt;=&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size:11px;color:black;"&gt; customer.CustomerID,
                                     AccountNumber &lt;/span&gt;&lt;span style="color:red;background-color:transparent;font-family:'Courier New';font-size:11px;font-weight:normal;"&gt;=&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size:11px;color:black;"&gt; customer.AccountNumber
                                 }).Take(5);
                var list &lt;/span&gt;&lt;span style="color:red;background-color:transparent;font-family:'Courier New';font-size:11px;font-weight:normal;"&gt;=&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size:11px;color:black;"&gt; customers.ToList();
                &lt;/span&gt;&lt;span style="color:blue;background-color:transparent;font-family:'Courier New';font-size:11px;font-weight:normal;"&gt;return&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size:11px;color:black;"&gt; list;
            }
        }

    }&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Το κομμάτι σε bold διαφέρει από αυτά που έγραφαν τα posts στα οποία παραπέμπει ο spaceman. Τα posts αναφέρουν ότι υπάρχει vulnerability όταν καλείς Json arrays με GET, αυτό όμως δεν ισχύει όταν χρησιμοποιείς ASMΧ γιατί δεν σου επιστρέφει γυμνό array.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;O client όμως θα πρέπει να ορίσει το Json στο Content-Type header. Για παράδειγμα, ένας C# client θα πρέπει να κάνει το παρακάτω:&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;pre&gt;&lt;span style="color:Black;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt; WebClient client=&lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;new&lt;/span&gt; WebClient();
 client.Headers[&lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"Content-Type"&lt;/span&gt;] &lt;span style="color:Red;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;=&lt;/span&gt; &lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"application/json; charset=utf-8"&lt;/span&gt;;            
 var data=client.DownloadString(&lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;@"http://localhost/WcfJsonTest/WebService1.asmx/GetCustomers"&lt;/span&gt;);
 Console.Write(data);&lt;/span&gt;&lt;/pre&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Το αποτέλεσμα είναι&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;pre&gt;&lt;span style="color:Black;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;{&lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"d"&lt;/span&gt;:[{&lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"__type"&lt;/span&gt;:&lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"WcfJsonTest.CustomerDetails"&lt;/span&gt;,&lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"CustomerID"&lt;/span&gt;:11000,&lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"AccountNumber"&lt;/span&gt;:&lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"AW00011000"&lt;/span&gt;},{&lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"__type"&lt;/span&gt;:&lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"WcfJsonTest.CustomerDetails"&lt;/span&gt;,&lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"CustomerID"&lt;/span&gt;:11001,&lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"AccountNumber"&lt;/span&gt;:&lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"AW00011001"&lt;/span&gt;},{&lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"__type"&lt;/span&gt;:&lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"WcfJsonTest.CustomerDetails"&lt;/span&gt;,&lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"CustomerID"&lt;/span&gt;:11002,&lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"AccountNumber"&lt;/span&gt;:&lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"AW00011002"&lt;/span&gt;},{&lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"__type"&lt;/span&gt;:&lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"WcfJsonTest.CustomerDetails"&lt;/span&gt;,&lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"CustomerID"&lt;/span&gt;:11003,&lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"AccountNumber"&lt;/span&gt;:&lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"AW00011003"&lt;/span&gt;},{&lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"__type"&lt;/span&gt;:&lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"WcfJsonTest.CustomerDetails"&lt;/span&gt;,&lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"CustomerID"&lt;/span&gt;:11004,&lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"AccountNumber"&lt;/span&gt;:&lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"AW00011004"&lt;/span&gt;}]}&lt;/span&gt;&lt;/pre&gt;Όπως βλέπουμε, το array περικλείεται στο d property κι έτσι δεν υπάρχει πρόβλημα.&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Αυτό εννοούσες spaceman?&lt;/div&gt;</description></item><item><title>Απ: web service that returns JSON string</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/62903.aspx</link><pubDate>Wed, 02 Feb 2011 01:53:18 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:62903</guid><dc:creator>Παναγιώτης Καναβός</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/62903.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=13&amp;PostID=62903</wfw:commentRss><description>Χμμ, δεν θα το έλεγα misconception, απλά άγνοια μίας παλιάς και λίγο ξεπερασμένης τεχνολογίας.&amp;nbsp;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Αν κατάλαβα πάντως, αυτό υποννοείς με τις παραπομπές, σε μία φράση, είναι ότι και με ASMX παίζει, φτάνει να ΜΗΝ γυρίσεις string?&amp;nbsp;&lt;/div&gt;</description></item><item><title>Απ: web service that returns JSON string</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/62897.aspx</link><pubDate>Wed, 02 Feb 2011 01:29:34 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:62897</guid><dc:creator>spaceman</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/62897.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=13&amp;PostID=62897</wfw:commentRss><description>&lt;P&gt;&lt;A href="http://stackoverflow.com/questions/3311681/android-how-to-access-data-in-an-asp-net-database-via-app"&gt;http://stackoverflow.com/questions/3311681/android-how-to-access-data-in-an-asp-net-database-via-app&lt;/A&gt;&lt;/P&gt;
&lt;LI&gt;
&lt;P&gt;Your webservice will still return XML (so you can use it with a soap client) &lt;STRONG&gt;unless&lt;/STRONG&gt; you make a &lt;FONT style="BACKGROUND-COLOR:#ffff00;"&gt;HTTPPost request with content-type "application/json"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://encosia.com/2010/03/03/asmx-and-json-common-mistakes-and-misconceptions/"&gt;http://encosia.com/2010/03/03/asmx-and-json-common-mistakes-and-misconceptions/&lt;/A&gt;&lt;BR&gt;One of the most stubbornly persistent misconceptions about ASMX services is the rumor that they are limited to returning XML. With that notion mind, many developers understandably avoid them for client-side AJAX callbacks. When every byte counts, raw JSON is always preferable to the bloat of XML.However, the introduction of &lt;STRONG&gt;ASP.NET AJAX removed that XML limitation&lt;/STRONG&gt;.&lt;BR&gt;In any ASP.NET 2.0+ AJAX enabled site, one of ASP.NET AJAX’s additions is something called the &lt;STRONG&gt;ScriptService&lt;/STRONG&gt;. When a ScriptService is called &lt;FONT style="BACKGROUND-COLOR:#ffff00;"&gt;in the correct manner&lt;/FONT&gt;, it automatically returns its result serialized as JSON instead of XML.&lt;/P&gt;
&lt;P&gt;--HTH--&lt;/P&gt;&lt;/LI&gt;</description></item><item><title>Απ: web service that returns JSON string</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/62887.aspx</link><pubDate>Tue, 01 Feb 2011 20:33:50 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:62887</guid><dc:creator>Παναγιώτης Καναβός</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/62887.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=13&amp;PostID=62887</wfw:commentRss><description>Αν όταν ο DaltonGR λέει web services εννοεί τα παλιά ASMX web services αρχίζει να βγαίνει νόημα. Εξηγείται έτσι και το WebMethod attribute στην αρχή, το οποίο δεν είχα προσέξει. Εκεί όμως δεν υπάρχει καμμία υποστήριξη για να επιστρέψεις κάτι πέρα από SOAP XML οπότε δεν είναι δυνατόν να ξεφορτωθείς τους xml headers. Επίσης, πρέπει να κάνεις τη μετατροπή σε JSON με το χέρι, με αποτέλεσμα να βγει πολύ περισσότερος κώδικας απ' ότι χρειάζεται.&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Για παράδειγμα, παρακάτω είναι όλος ο κώδικας που χρειάστηκε να γράψω για να βγάλω δεδομένα ως JSON.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;To web service (κομπλέ με data class και interface). Έφτιαξα ένα Entity Model μόνο με τον πίνακα Customers ( Add &amp;gt; New Item &amp;gt; Data &amp;gt; ADO.NET Data Entity Model και διάλεξα μόνο τον πίνακα Customers από τη λίστα)&lt;/div&gt;&lt;div&gt;&lt;pre&gt;&lt;span style="color:Black;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt; [DataContract]
    &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;public&lt;/span&gt; &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;class&lt;/span&gt; CustomerDetails
    {
        [DataMember]
        &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;public&lt;/span&gt; &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;int&lt;/span&gt; CustomerID { get; set; }
        [DataMember]
        &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;public&lt;/span&gt; &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;string&lt;/span&gt; AccountNumber { get; set; }
    }

    [ServiceContract]
    &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;public&lt;/span&gt; &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;interface&lt;/span&gt; ICustomerService
    {
        [OperationContract, WebGet(
            ResponseFormat &lt;span style="color:Red;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;=&lt;/span&gt; WebMessageFormat.Json,
            RequestFormat=WebMessageFormat.Json,
            UriTemplate=&lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"Customers"&lt;/span&gt;)]
        List&amp;lt;CustomerDetails&amp;gt; GetCustomers();
    }

    &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;public&lt;/span&gt; &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;class&lt;/span&gt; CustomerService : ICustomerService
    {
        &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;public&lt;/span&gt; List&amp;lt;CustomerDetails&amp;gt; GetCustomers()
        {
            &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;using&lt;/span&gt; (var dbContext &lt;span style="color:Red;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;=&lt;/span&gt; &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;new&lt;/span&gt; AdventureWorksEntities())
            {
                var customers &lt;span style="color:Red;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;=&lt;/span&gt; (from customer &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;in&lt;/span&gt; dbContext.Customers
                                where customer.CustomerType== &lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"I"&lt;/span&gt;
                                select &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;new&lt;/span&gt; CustomerDetails
                                           {
                                               CustomerID=customer.CustomerID,
                                               AccountNumber=customer.AccountNumber
                                           }).Take(5);
                var list &lt;span style="color:Red;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;=&lt;/span&gt; customers.ToList();
                &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;return&lt;/span&gt; list;
            }
        }
    }&lt;/span&gt;&lt;/pre&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;και το web.config. Με κόκκινο οι γραμμές που χρειάστηκε να προσθέσω:&lt;/div&gt;&lt;div&gt;&lt;pre&gt;&lt;span style="color:Black;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;&amp;lt;?xml version=&lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"1.0"&lt;/span&gt;?&amp;gt;
&amp;lt;configuration&amp;gt;

  &amp;lt;system.web&amp;gt;
    &amp;lt;compilation debug=&lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"true"&lt;/span&gt; targetFramework=&lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"4.0"&lt;/span&gt;&amp;gt;&amp;lt;assemblies&amp;gt;&amp;lt;add assembly=&lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"&lt;/span&gt; /&amp;gt;&amp;lt;/assemblies&amp;gt;&amp;lt;/compilation&amp;gt;
  &amp;lt;/system.web&amp;gt;
  &amp;lt;system.serviceModel&amp;gt;
	  
	  &lt;/span&gt;&lt;span style="background-color:transparent;font-family:'Courier New';font-size:11px;"&gt;&lt;b&gt;&lt;font class="Apple-style-span" color="#FF0000"&gt;&amp;lt;services&amp;gt;
		  &amp;lt;service name=&lt;span style="font-family:'Courier New';font-size:11px;"&gt;"WcfJsonTest.CustomerService"&lt;/span&gt;&amp;gt;
			  &amp;lt;endpoint address=&lt;span style="font-family:'Courier New';font-size:11px;"&gt;""&lt;/span&gt; behaviorConfiguration=&lt;span style="font-family:'Courier New';font-size:11px;"&gt;"WcfJsonTest.TestServiceBehavior"&lt;/span&gt; binding=&lt;span style="font-family:'Courier New';font-size:11px;"&gt;"webHttpBinding"&lt;/span&gt; contract=&lt;span style="font-family:'Courier New';font-size:11px;"&gt;"WcfJsonTest.ICustomerService"&lt;/span&gt;&amp;gt;
			  &amp;lt;/endpoint&amp;gt;
		  &amp;lt;/service&amp;gt;
	  &amp;lt;/services&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="color:Black;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;

	  &amp;lt;behaviors&amp;gt;
		  &lt;/span&gt;&lt;span style="background-color:transparent;font-family:'Courier New';font-size:11px;"&gt;&lt;b&gt;&lt;font class="Apple-style-span" color="#FF0000"&gt;&amp;lt;endpointBehaviors&amp;gt;
			  &amp;lt;behavior name=&lt;span style="font-family:'Courier New';font-size:11px;"&gt;"WcfJsonTest.TestServiceBehavior"&lt;/span&gt;&amp;gt;
				  &amp;lt;webHttp helpEnabled=&lt;span style="font-family:'Courier New';font-size:11px;"&gt;"true"&lt;/span&gt; /&amp;gt;
			  &amp;lt;/behavior&amp;gt;
		  &amp;lt;/endpointBehaviors&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="color:Black;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;
		  &amp;lt;serviceBehaviors&amp;gt;
        &amp;lt;behavior&amp;gt;		
          &amp;lt;!-- To avoid disclosing metadata information, set the value below to &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;false&lt;/span&gt; and remove the metadata endpoint above before deployment --&amp;gt;
          &amp;lt;serviceMetadata httpGetEnabled=&lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"true"&lt;/span&gt; /&amp;gt;
          &amp;lt;!-- To receive exception details &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;in&lt;/span&gt; faults &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;for&lt;/span&gt; debugging purposes, set the value below to &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;true&lt;/span&gt;.  Set to &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;false&lt;/span&gt; before deployment to avoid disclosing exception information --&amp;gt;
          &amp;lt;serviceDebug includeExceptionDetailInFaults=&lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"true"&lt;/span&gt; /&amp;gt;
			
        &amp;lt;/behavior&amp;gt;
      &amp;lt;/serviceBehaviors&amp;gt;

	  &amp;lt;/behaviors&amp;gt;
    &amp;lt;serviceHostingEnvironment multipleSiteBindingsEnabled=&lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"true"&lt;/span&gt;/&amp;gt;
  &amp;lt;/system.serviceModel&amp;gt;
 &amp;lt;system.webServer&amp;gt;
    &amp;lt;modules runAllManagedModulesForAllRequests=&lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"true"&lt;/span&gt; /&amp;gt;
  &amp;lt;/system.webServer&amp;gt;
  
&amp;lt;connectionStrings&amp;gt;&amp;lt;add name=&lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"AdventureWorksEntities"&lt;/span&gt; connectionString=&lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string=&amp;amp;quot;Data Source=.;Initial Catalog=AdventureWorks;Integrated Security=True;MultipleActiveResultSets=True&amp;amp;quot;"&lt;/span&gt; providerName=&lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"System.Data.EntityClient"&lt;/span&gt; /&amp;gt;&amp;lt;/connectionStrings&amp;gt;&amp;lt;/configuration&amp;gt;&lt;/span&gt;&lt;/pre&gt;To περίεργο connection string χρησιμοποιείται από το Entity Framework για τη σύνδεση στη βάση, το οποίο δημιουργήθηκε από τον wizard του EF&lt;/div&gt;</description></item><item><title>Απ: web service that returns JSON string</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/62885.aspx</link><pubDate>Tue, 01 Feb 2011 20:16:40 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:62885</guid><dc:creator>dimos.homatas</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/62885.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=13&amp;PostID=62885</wfw:commentRss><description>&lt;div&gt;Παναγιώτη το λέω γιατί είδα αυτό:&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="http://www.dotnetzone.gr/cs/Themes/default/images/icon-quote.gif"&gt; &lt;strong&gt;DaltonGR:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;μάλλον θα μείνω προσωρινά με τα web services, γιατί απο ότι καταλαβαίνω θέλει αρκετό χρόνο, και επειδή για αρχή θα πρέπει να λειτουργεί κάποιο service πιλοτικά.&amp;nbsp;&lt;br&gt;&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;και υπέθεσα ότι μιλάμε για τα απλά xml web services. Τώρα, τι έχει γίνει με το γενικότερο "πακετάρισμα" κάτω από το WCF στο 4άρι .ΝΕΤ, δεν γνωρίζω. Είχα την εντύπωση πάντως ότι όλα θα αποτελούσαν μέρος του WCF.&lt;/div&gt;</description></item><item><title>Απ: web service that returns JSON string</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/62884.aspx</link><pubDate>Tue, 01 Feb 2011 19:59:34 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:62884</guid><dc:creator>Παναγιώτης Καναβός</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/62884.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=13&amp;PostID=62884</wfw:commentRss><description>&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="http://www.dotnetzone.gr/cs/Themes/default/images/icon-quote.gif"&gt; &lt;strong&gt;dimos.homatas:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;Μμμμμ, νόμιζα ότι έλεγες για τα WCF services, sorry.&lt;/div&gt;&lt;/BLOCKQUOTE&gt; Μα γι αυτά λέω. Μπορείς να ορίσεις σε ένα WCF service να επιστρέφει XML ή JSON.&amp;nbsp;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Τα WCF &lt;b&gt;Data &lt;/b&gt;Services απλά βολεύουν στο σενάριο του DaltonGR περισσότερο από τα απλά WCF Services.&lt;/div&gt;</description></item><item><title>Απ: web service that returns JSON string</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/62883.aspx</link><pubDate>Tue, 01 Feb 2011 19:56:16 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:62883</guid><dc:creator>Παναγιώτης Καναβός</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/62883.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=13&amp;PostID=62883</wfw:commentRss><description>Όσον αφορά το xml header, ΜΗΝ μετατρέπεις ΤΙΠΟΤΕ σε string. Τη μετατροπή την κάνει το ίδιο το WCF αφού του είπες να χρησιμοποιήσει JSON. Η ερώτηση στο StackOverflow ρωτάει ακριβώς γιατί εμφανίζεται το XML Header και του απαντάνε να ΜΗΝ προσπαθήσει ο ίδιος να κάνει την μετατροπή και να ΜΗΝ επιστρέψει string.</description></item><item><title>Απ: web service that returns JSON string</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/62882.aspx</link><pubDate>Tue, 01 Feb 2011 19:55:44 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:62882</guid><dc:creator>dimos.homatas</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/62882.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=13&amp;PostID=62882</wfw:commentRss><description>Μμμμμ, νόμιζα ότι έλεγες για τα WCF services, sorry.</description></item><item><title>Απ: web service that returns JSON string</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/62881.aspx</link><pubDate>Tue, 01 Feb 2011 19:53:07 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:62881</guid><dc:creator>Παναγιώτης Καναβός</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/62881.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=13&amp;PostID=62881</wfw:commentRss><description>Δήμο, ήδη δείξαμε ότι όντως επιστρέφουν προσθέτωντας ένα attribute στο operation και μερικές γραμμές στο web.config.&amp;nbsp;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;DaltonGR, τα WCF Data Services τα ανέφερα γιατί είναι πολύ πιο εύκολο και γρήγορο να κάνεις αυτό που ζητάς με αυτά - φτιάχνεις ένα μοντέλο από τη βάση με drag &amp;amp; drop και το κάνεις expose με 5 γραμμές! Σίγουρα πολύ λιγότερο κώδικα από αυτόν που έγραψες για το post σου. Επιπλέον, ο κώδικας που έγραψες σε δεσμεύει σε ένα και μόνο. Τα WCF Data Services σου επιτρέπουν να κάνεις όποιο query θέλεις από τη μεριά του client, φτάνει να κάνεις expose τους κατάλληλους πίνακες ως entities.&lt;/div&gt;</description></item><item><title>Απ: web service that returns JSON string</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/62880.aspx</link><pubDate>Tue, 01 Feb 2011 19:40:54 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:62880</guid><dc:creator>dimos.homatas</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/62880.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=13&amp;PostID=62880</wfw:commentRss><description>Έχω την αμυδρή εντύπωση ότι τα web services δεν επιστρέφουν json, αν και δεν είμαι σίγουρος. Από όσο ξέρω τα λέγανε &lt;i&gt;XML Web Services.&lt;/i&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Quick n Dirty solution:&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Φτιάχνεις ένα container αντικείμενο και έχεις ένα method το οποίο κάνει dump το json string. Οπότε παίρνεις ένα xml αντικείμενο από το service, πχ το myObject και απλά του λες κάτι του στυλ string s = myObject.DumpToJSon();&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Παίρνεις μετά το s και το κάνεις deserialize (κάπου έχει πάρει το μάτι ένα JSon.NET)&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Βέβαια από ότι καταλαβαίνω μάλλον θέλεις να αποφύγεις εντελώς το xml, και όχι απλά να το έχεις ως περιτύλιγμα για το json.&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Από την άλλη, μήπως τα πράγματα θα ήταν πιο απλά εάν δεν χρησιμοποιούσες web service και έκανες ένα dump το json string?&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;my 2 cents...&amp;nbsp;&lt;/div&gt;</description></item><item><title>Απ: web service that returns JSON string</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/62879.aspx</link><pubDate>Tue, 01 Feb 2011 18:49:20 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:62879</guid><dc:creator>DaltonGR</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/62879.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=13&amp;PostID=62879</wfw:commentRss><description>μάλλον θα μείνω προσωρινά με τα web services, γιατί απο ότι καταλαβαίνω θέλει αρκετό χρόνο, και επειδή για αρχή θα πρέπει να λειτουργεί κάποιο service πιλοτικά. Λοιπόν έχω την παρακάτω web method&lt;br&gt;&lt;pre&gt;&lt;span style="color:Black;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt; &amp;lt;WebMethod()&amp;gt; _
    &amp;lt;ScriptMethod(ResponseFormat:=ResponseFormat.Json)&amp;gt; _
    &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;Public&lt;/span&gt; &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;Function&lt;/span&gt; getAllCustomers() &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;As&lt;/span&gt; &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;String&lt;/span&gt;
        Using myConnection &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;As&lt;/span&gt; &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;New&lt;/span&gt; SqlConnection(&lt;span style="font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"Data Source=.\sqlexpress;Initial Catalog=DBName;Integrated Security=True;User ID=sa;Password=;"&lt;/span&gt;)
            &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;If&lt;/span&gt; myConnection.State &lt;span style="color:Red;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;=&lt;/span&gt; ConnectionState.Closed &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;Then&lt;/span&gt;
                myConnection.Open()
            &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;End&lt;/span&gt; &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;If&lt;/span&gt;

            &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;Dim&lt;/span&gt; DRAllData &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;As&lt;/span&gt; SqlDataReader
            &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;Dim&lt;/span&gt; myCommand &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;As&lt;/span&gt; &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;New&lt;/span&gt; SqlCommand
            myCommand.Connection &lt;span style="color:Red;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;=&lt;/span&gt; myConnection
            myCommand.CommandType &lt;span style="color:Red;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;=&lt;/span&gt; CommandType.Text

            &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;Try&lt;/span&gt;
                myCommand.CommandText &lt;span style="color:Red;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;=&lt;/span&gt; &lt;span style="font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"Select Top 10 CustomerID,FName,LName From Customers"&lt;/span&gt;
                DRAllData &lt;span style="color:Red;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;=&lt;/span&gt; myCommand.ExecuteReader

                &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;Dim&lt;/span&gt; DTAllData &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;As&lt;/span&gt; &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;New&lt;/span&gt; DataTable
                DTAllData.Load(DRAllData)

                &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;Return&lt;/span&gt; ConvertJSON.GetJSONString(DTAllData)
            &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;Catch&lt;/span&gt; ex &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;As&lt;/span&gt; Exception
                &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;Return&lt;/span&gt; &lt;span style="font-family:Courier New;font-size:11px;font-weight:normal;"&gt;""&lt;/span&gt;
            &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;End&lt;/span&gt; &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;Try&lt;/span&gt;
        &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;End&lt;/span&gt; Using
    &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;End&lt;/span&gt; &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;Function&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;γίνεται convert sε μορφή Json με την παρακάτω κλάση,&lt;br&gt;&lt;pre&gt;&lt;span style="color:Black;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;    &lt;span style="color:Green;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;'Μετατρέπει ένα DataTable με δεδομένα σε JSON αντικείμενο.&lt;/span&gt;
    &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;Public&lt;/span&gt; &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;Shared&lt;/span&gt; &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;Function&lt;/span&gt; GetJSONString(&lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;ByVal&lt;/span&gt; Dt &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;As&lt;/span&gt; DataTable) &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;As&lt;/span&gt; &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;String&lt;/span&gt;
        &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;Dim&lt;/span&gt; StrDc &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;As&lt;/span&gt; &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;String&lt;/span&gt;() &lt;span style="color:Red;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;=&lt;/span&gt; &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;New&lt;/span&gt; &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;String&lt;/span&gt;(Dt.Columns.&lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;Count&lt;/span&gt; &lt;span style="color:Red;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;-&lt;/span&gt; 1) {}

        &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;Dim&lt;/span&gt; HeadStr &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;As&lt;/span&gt; &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;String&lt;/span&gt; &lt;span style="color:Red;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;=&lt;/span&gt; &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;String&lt;/span&gt;.Empty
        &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;For&lt;/span&gt; i &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;As&lt;/span&gt; &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;Integer&lt;/span&gt; &lt;span style="color:Red;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;=&lt;/span&gt; 0 &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;To&lt;/span&gt; Dt.Columns.&lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;Count&lt;/span&gt; &lt;span style="color:Red;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;-&lt;/span&gt; 1
            StrDc(i) &lt;span style="color:Red;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;=&lt;/span&gt; Dt.Columns(i).Caption
            HeadStr += &lt;span style="font-family:Courier New;font-size:11px;font-weight:normal;"&gt;""""&lt;/span&gt; &amp;amp; StrDc(i) &amp;amp; &lt;span style="font-family:Courier New;font-size:11px;font-weight:normal;"&gt;""" : """&lt;/span&gt; &amp;amp; StrDc(i) &amp;amp; i.ToString() &amp;amp; &lt;span style="font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"¾"&lt;/span&gt; &amp;amp; &lt;span style="font-family:Courier New;font-size:11px;font-weight:normal;"&gt;""","&lt;/span&gt;
        &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;Next&lt;/span&gt;

        HeadStr &lt;span style="color:Red;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;=&lt;/span&gt; HeadStr.Substring(0, HeadStr.Length &lt;span style="color:Red;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;-&lt;/span&gt; 1)
        &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;Dim&lt;/span&gt; Sb &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;As&lt;/span&gt; &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;New&lt;/span&gt; StringBuilder()

        Sb.Append(&lt;span style="font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"{"""&lt;/span&gt; &amp;amp; Convert.ToString(&lt;span style="font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"WebServiceData"&lt;/span&gt;) &amp;amp; &lt;span style="font-family:Courier New;font-size:11px;font-weight:normal;"&gt;""" : ["&lt;/span&gt;)
        &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;For&lt;/span&gt; i &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;As&lt;/span&gt; &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;Integer&lt;/span&gt; &lt;span style="color:Red;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;=&lt;/span&gt; 0 &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;To&lt;/span&gt; Dt.Rows.&lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;Count&lt;/span&gt; &lt;span style="color:Red;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;-&lt;/span&gt; 1
            &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;Dim&lt;/span&gt; TempStr &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;As&lt;/span&gt; &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;String&lt;/span&gt; &lt;span style="color:Red;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;=&lt;/span&gt; HeadStr
            Sb.Append(&lt;span style="font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"{"&lt;/span&gt;)
            &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;For&lt;/span&gt; j &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;As&lt;/span&gt; &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;Integer&lt;/span&gt; &lt;span style="color:Red;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;=&lt;/span&gt; 0 &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;To&lt;/span&gt; Dt.Columns.&lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;Count&lt;/span&gt; &lt;span style="color:Red;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;-&lt;/span&gt; 1
                TempStr &lt;span style="color:Red;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;=&lt;/span&gt; TempStr.&lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;Replace&lt;/span&gt;(Dt.Columns(j).ToString &amp;amp; j.ToString() &amp;amp; &lt;span style="font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"¾"&lt;/span&gt;, Dt.Rows(i)(j).ToString())
            &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;Next&lt;/span&gt;
            Sb.Append(TempStr &amp;amp; &lt;span style="font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"},"&lt;/span&gt;)
        &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;Next&lt;/span&gt;
        Sb &lt;span style="color:Red;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;=&lt;/span&gt; &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;New&lt;/span&gt; StringBuilder(Sb.ToString().Substring(0, Sb.ToString().Length &lt;span style="color:Red;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;-&lt;/span&gt; 1))

        Sb.Append(&lt;span style="font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"]}"&lt;/span&gt;)
        &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;Return&lt;/span&gt; Sb.ToString()
    &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;End&lt;/span&gt; &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;Function&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;αλλα πάλι μου βάζει xml header&lt;br&gt;&amp;lt;string xmlns="http://www.minosnet.gr/"&amp;gt;{"WebServiceData" : [{"CustomerID" : "31","FName" : "ÎÏÏÏÎ±Ï","LName" : "ÎÎ¿ÏÏÏÎ¿ÏÎ»Î¬ÎºÎ·Ï"},{"CustomerID" : "32","FName" : "ÎÎ¹Î¬Î½Î½Î·Ï","LName" : "ÎÎ±ÏÎ±Î¼Î¿ÏÏÎ±Î´Î¬ÎºÎ·Ï"},{"CustomerID" : "33","FName" : "ÎÎ¶Î±Î¼ÏÎ­Î»Î±","LName" : "Î£ÏÎµÏÎ±Î½Î¿ÏÎ´Î¬ÎºÎ·"},{"CustomerID" : "34","FName" : "ÎÎ±ÏÎ±Î»Î¯Î±","LName" : "ÎÎµÎ»Î±ÏÎ´Î®"},{"CustomerID" : "35","FName" : "ÎÎ¹ÏÎ®Î½Î·","LName" : "ÎÎ½Î´ÏÎµÎ±Î´Î¬ÎºÎ·"},{"CustomerID" : "36","FName" : "ÎÎ±ÏÎ¯Î±","LName" : "Î¤Î¶Î¹Î»Î¹Î²Î¬ÎºÎ·"},{"CustomerID" : "37","FName" : "ÎÎ¿ÏÎ¯Î½Î±","LName" : "ÎÎ±ÏÎµÎ´Î¬ÎºÎ·"},{"CustomerID" : "38","FName" : "ÎºÎºÎºÎº","LName" : "ÎÎ±ÏÎµÎ´Î¬ÎºÎ·"},{"CustomerID" : "39","FName" : "ÎÎ±Î½ÏÎ»Î·Ï","LName" : "ÎÏÎ»ÏÎ½Î¬ÎºÎ·Ï"},{"CustomerID" : "40","FName" : "ÎÎ¹ÏÏÎ³Î¿Ï","LName" : "Î¤ÏÎ¹Î»Î¹Î²Î¬ÎºÎ·Ï"}]}&amp;lt;/string&amp;gt;&lt;br&gt;&lt;br&gt;πώς μπορώ να επιστρέφει η ςeb method μόνο το Json αντικείμενο; Να επιστρέφω αντικείμενο τύπου Customers?(Με αντίστοιχη κλάση Customer)&lt;br&gt;&lt;br&gt;ευχαριστώ και πάλι.&lt;br&gt;&lt;br&gt;</description></item><item><title>Απ: web service that returns JSON string</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/62875.aspx</link><pubDate>Tue, 01 Feb 2011 07:35:37 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:62875</guid><dc:creator>Παναγιώτης Καναβός</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/62875.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=13&amp;PostID=62875</wfw:commentRss><description>Τότε αξίζει να κοιτάξεις τα &lt;a href="http://msdn.microsoft.com/en-us/data/bb931106.aspx"&gt;WCF Data Services&lt;/a&gt;. Εμφανίζουν με πολύ απλό τρόπο τα περιεχόμενα ενός μοντέλου Entity Framework ως REST είτε σε μορφή Atom Feed είτε JSON και επιτρέπουν τη δημιουργία queries (κομπλέ με selects, paging, sorting) μέσω του URL, της Javascript ή ακόμα και LINQ αν η εφαρμογή σου είναι .NET. Δες &lt;a href="http://msdn.microsoft.com/en-us/magazine/ee336022.aspx"&gt;αυτό το άρθρο&amp;nbsp;&lt;/a&gt;στο MSDN Magazine για το πως μπορεί κανείς να καλέσει ένα WCF Data Service μέσω του ASP.NET Ajax library και &lt;a href="http://wildermuth.com/2010/02/23/WCF_Data_Services_and_jQuery"&gt;αυτό το άρθρο&lt;/a&gt; του Shawn Wildermuth για το πως να το καλέσει μέσω jQuery και να πάρει πίσω JSON. Για να πάρεις JSON το μόνο που χρειάζεται είναι να βάλεις τα σωστά HTTP Header στο request (contentType: "application/json; charset=utf-8", &amp;nbsp;dataType: "json")&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Όσο για το πως φτιάχνεις ένα WCF Data Service, στην απλούστερη μορφή του είναι απλά το παρακάτω:&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;pre&gt;&lt;span style="color:Black;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;&lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;public&lt;/span&gt; &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;class&lt;/span&gt; NorthwindService : DataService&amp;lt;NorthwindEntities&amp;gt;
{
   &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;public&lt;/span&gt; &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;static&lt;/span&gt; &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;void&lt;/span&gt; InitializeService(IDataServiceConfiguration config)
   {
      config.SetEntitySetAccessRule(&lt;span style="color:#666666;background-color:#e4e4e4;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;"Customers"&lt;/span&gt;, EntitySetRights.All);
    }
}&lt;/span&gt;&lt;/pre&gt;όπου NorthwindEntities είναι το context που δημιουργεί το EF και Customers το όνομα της κλάσης (του EntitySet για την ακρίβεια) που θέλεις να βγάλεις προς τα έξω&lt;/div&gt;</description></item><item><title>Απ: web service that returns JSON string</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/62864.aspx</link><pubDate>Tue, 01 Feb 2011 05:35:00 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:62864</guid><dc:creator>DaltonGR</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/62864.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=13&amp;PostID=62864</wfw:commentRss><description>ευχαριστώ για την απάντηση. Θα πρέπει να αρχίσω το ψάξιμο με WCF γιατί είμαι ακόμα στην αρχή. Αυτό που θέλω γενικά να κάνω είναι να δημιουργήσω 3 services που επιστρέφουν δεδομένα απο SQL server. Μόνο για ανάγνωση θα είναι αυτά τα δεδομένα.&lt;br&gt;&lt;br&gt;ευχαριστώ και πάλι.&lt;br&gt;</description></item><item><title>Απ: web service that returns JSON string</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/62857.aspx</link><pubDate>Tue, 01 Feb 2011 02:17:12 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:62857</guid><dc:creator>Παναγιώτης Καναβός</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/62857.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=13&amp;PostID=62857</wfw:commentRss><description>Ουπς, λείπει και κάτι ακόμα. Πρέπει στο config του WCF service σου να ορίσεις και ένα &lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.webhttpbinding.aspx"&gt;WebHttpBinding&lt;/a&gt; endpoint για να μπορεί να το καλέσει κώδικας από javascript. Για παράδειγμα, έφτιαξα ένα χαζό service σε WCF 4 το οποίο λέγεται ... Service1 και χρειάστηκε να προσθέσω το παρακάτω XML μέσα στο &amp;lt;system.serviceModel&amp;gt;&lt;div&gt;&lt;pre&gt;&lt;span style="color:Black;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;	  &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:Maroon;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;services&lt;/span&gt;&lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;&amp;gt;&lt;/span&gt;
		  &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:Maroon;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;service&lt;/span&gt; &lt;span style="color:Red;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;name&lt;/span&gt;&lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;="WcfJsonTest.Service1"&lt;/span&gt;&lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;&amp;gt;&lt;/span&gt;
			  &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:Maroon;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;endpoint&lt;/span&gt; &lt;span style="color:Red;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;address&lt;/span&gt;&lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;=""&lt;/span&gt; &lt;span style="color:Red;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;behaviorConfiguration&lt;/span&gt;&lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;="WcfJsonTest.TestServiceBehavior"&lt;/span&gt; &lt;span style="color:Red;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;binding&lt;/span&gt;&lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;="webHttpBinding"&lt;/span&gt; &lt;span style="color:Red;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;contract&lt;/span&gt;&lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;="WcfJsonTest.IService1"&lt;/span&gt;&lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;&amp;gt;&lt;/span&gt;
			  &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:Maroon;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;endpoint&lt;/span&gt;&lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;&amp;gt;&lt;/span&gt;
		  &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:Maroon;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;service&lt;/span&gt;&lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;&amp;gt;&lt;/span&gt;
	  &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:Maroon;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;services&lt;/span&gt;&lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;και το παρακάτω στο &amp;lt;behaviors&amp;gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;pre&gt;&lt;span style="color:Black;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;		  &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:Maroon;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;endpointBehaviors&lt;/span&gt;&lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;&amp;gt;&lt;/span&gt;
			  &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:Maroon;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;behavior&lt;/span&gt; &lt;span style="color:Red;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;name&lt;/span&gt;&lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;="WcfJsonTest.TestServiceBehavior"&lt;/span&gt;&lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;&amp;gt;&lt;/span&gt;
				  &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:Maroon;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;webHttp&lt;/span&gt; &lt;span style="color:Red;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;helpEnabled&lt;/span&gt;&lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;="true"&lt;/span&gt;&lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;/&amp;gt;&lt;/span&gt;
			  &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:Maroon;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;behavior&lt;/span&gt;&lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;&amp;gt;&lt;/span&gt;
		  &lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:Maroon;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;endpointBehaviors&lt;/span&gt;&lt;span style="color:Blue;background-color:Transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Το helpEnabled ενεργοποιεί μία help σελίδα στο Service1.svc/help η οποία εμφανίζει όλες τις μεθόδους του service μου και το URL που πρέπει να φτιάξω για να το καλέσω&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Το λαμπρό αποτέλεσμα είναι παρακάτω:&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;[{"BoolValue":true,"StringValue":"Moo"},{"BoolValue":false,"StringValue":"Moo1"}]&lt;/div&gt;</description></item><item><title>Απ: web service that returns JSON string</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/62854.aspx</link><pubDate>Mon, 31 Jan 2011 23:45:17 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:62854</guid><dc:creator>Παναγιώτης Καναβός</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/62854.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=13&amp;PostID=62854</wfw:commentRss><description>Μπορείς να δημιουργήσεις WCF Service το οποίο επιστρέφει JSON. Θα πρέπει όμως να αλλάξεις τον τύπο των δεδομένων σε κάτι πέρα από DataTable, π.χ. σε List&amp;lt;Customer&amp;gt;. Μετά, απλά αλλάζεις το Request/ResponseFormat των μεθόδων σου σε JSON. Δες και &lt;a href="http://stackoverflow.com/questions/2086666/wcf-how-do-i-return-clean-json"&gt;αυτή την ερώτηση στο StackOverflow&lt;/a&gt; που απαντάει ακριβώς σε αυτό που ρωτάς.&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;</description></item></channel></rss>