DCSIMG
January 2011 - Posts - Ido Flatow's Blog Veni Vidi Scripsi

Ido Flatow's Blog

Veni Vidi Scripsi

News

Have you heard me speak?
Powered
<style type='text/css' media='screen' id='sm_css'> #smix {overflow: visible;height: auto;border-radius: 10px;max-width: 250px;background-color: #323232;text-align: left;font-size: 12px;line-height: 16px;font-family:'Lucida Sans Unicode','Lucida Grande',Verdana,Arial,Helvetica,sans-serif;-webkit-border-radius: 10px;-moz-border-radius: 10px;border-radius: 10px;} #smix a {color: #0056CC;text-decoration: none;} #smix .sm_head {color: #fff; line-height: 1em;font-size: 1.4em;padding: 10px;color: #fff;} #smix .sm_lanyard_wrapper {background-color: #fff;;clear: both;width: 97%;margin: 0 auto;margin-bottom: 0px;} #smix .sm_lanyard_content {padding: 7px;}#smix button.sm_rec, #smix a.sm_rec, #smix input[type=submit].sm_rec { padding: 6px 10px; -webkit-border-radius: 2px 2px;-moz-border-radius: 2px; border-radius: 2px; border: solid 1px rgb(153, 153, 153); background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(rgb(255, 255, 255)), to(rgb(221, 221, 221))); color: #333; text-decoration: none; cursor: pointer; display: inline-block; text-align: center; text-shadow: 0px 1px 1px rgba(255,255,255,1); line-height: 1; }#smix .sm_rec:hover { background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(rgb(248, 248, 248)), to(rgb(221, 221, 221))); }#smix .sm_rec:active { background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(rgb(204, 204, 204)), to(rgb(221, 221, 221))); }#smix .sm_rec.medium { padding: 3px 7px; font-size: 13px; }#smix .sm_rec span.icon.thumbs_up {background-position: 0px 36px;vertical-align: text-top;display: inline-block;margin-right: 4px;height: 18px;width: 16px;background-image: url(http://speakermix.com/images/new/thumbsold.png);}#smix .sm_rec:hover span.icon.thumbs_up {background-position: 0px 18px;} #smix .sm_events {padding:2px 0px 4px 0px;} #smix .sm_section {font-size: 10px; border-bottom: 1px solid silver; margin-bottom: 6px;} #smix .sm_subline {font-size:120%;margin-top:4px;font-weight:bold} #smix .powered {text-align: right} #smix .powered img {margin: 7px} </style>
Sela Technology Center

Advertisement

January 2011 - Posts

What’s new in WCF 4 lecture for the .NET Developers User Group

Two days ago I gave a lecture at the Israeli .Net Developers User Group (IDNDUG) in Microsoft. The lecture went great and there were a lot of good questions.

The presentation and the code samples are available for public download at the following link.

During the lecture someone asked me a question regarding support for JSONP (JSON with padding) in WCF RESTful calls, and I answered that as far as I know there is no such support. But… since I’m quite senile I forgot that I did see such support with WCF and the WebHttpBinding.

To use JSONP with WCF you’ll need to do the following:

1. Enable the crossDomainScriptAccessEnabled attribute in the webHttpBinding binding configuration element:

 <bindings>
  <webHttpBinding>
    <binding crossDomainScriptAccessEnabled="true"/>         
  </webHttpBinding>
</bindings>

2. When calling the service, add the callback key to your query string, for example:

http://localhost/myService/getSomething?id=7&callback=getSomethingCallback

3. Make sure your service returns responses in the JSON format, either by settings it in the service code, or by setting it in the webHttp behavior configuration (sample code and configuration can be found in my presentation samples).

WCF, Silverlight, Fiddler ומה שביניהם

 

שלמה העלה פוסט היום בנושא Binding ב-WCF ובו הוא הציג כיצד ניתן להשתמש ב-Custom binding ליצירת שירות שמעביר הודעות בינאריות מעל HTTP.

שלמה ציין שמקרים אלו נתמכים במצבים בהם גם הקליינט וגם השירות כתובים בדוטנט – אחד המקרים האלו הן אפליקציות Silverlight שברוב המקרים מתקשרות עם שירותים באמצעות BasicHttpBinding (כי רוב ה-bindings האחרים לא נתמכים). במקרים כאלו ניתן לשפר את הביצועים של תעבורת הרשת ע”י הגדרת custom binding המשלב binary encoding כפי ששלמה הציע ובכך לאפשר ל-Silverlight ולשירות ה-WCF להעביר הודעות יותר מהר ביניהם.

הבעיה היחידה שקיימת כאשר עובדים בצורה זו היא התמודדות עם שגיאות בתעבורה. בגלל הבעיות המוכרות של Silverlight כאשר הוא מקבל הודעות HTTP 500, אנחנו הרבה פעמים משתמשים ב-Fiddler בשביל להסתכל מה באמת הכילו הודעות השגיאה שמגיעות מ-WCF, אך כאשר אנחנו עובדים עם binary encoding אנחנו נקבל ג’יבריש במקום XML.

לשם כך הומצא ה-WCF Binary Inspector עבור Fiddler. מורידים את ה-Inspector, מעתיקים אותו לתיקיית ה-Inspectors של Fiddler והופס – אנחנו יכולים לראות את התוכן של ה-Binary encoding ב-Fiddler.

בהצלחה…