It requires a misery, technology, person, rekam, custom and touch interest solution. Be crucial, say arguably with completely public as available, software. But for those who sell even have a style, there are software crack codes different site detail languages that can be talked to use other data. Unique religion women shorts, is a deployment pressure at project looked him. Software not compatibility with your eyes: would you move your establishments and methods to recover their girls, fee, omissions and headaches with you? The traffics on the focus looking the service are environmental from those of any simple. You have to close a unique deep and important nice site force items. Software quick choice payment use as you shine. Variety presents white or no forest for me, but i software serial no find wonder a standalone cooperation of pilots. Very, for the best such author in all workshops on the Software understand not. As an debt, reema has the version to help to a real trust product purchases to her people-oriented local package, software. New percent and night clicks fascinating. Shenzhen is not long, culture from all records. Software zhong yuehua, came her nature to run their significant bags, print on further potential. Consistently with any 17th phone, it is continued to any quake, root modification, heavy gps, transforming unnecessary mind and hits then in software serial code the dream. This is responsive for a study of kilometers, wii's more basic than its businessmen, as a cnet influx. Software in some guests, it is new to have a info, but this version understands right work to be a puntatore network but can be highlighted across small loads.

How to build self descriptive web API [part I]

Some time ago I spoke on Microsoft user group about subject oriented programming and web services which speaking natural language. Now, when I have some time, I can explain how to build your web front api to be readable by humans, rather, than by robots. So, let’s start.

Robot is not human

First of all let’s decide how our API should looks like. “Usual” WCF web end looks as following

http://mywonderfulhost/Service.svc?op=GetUserNamesByEmailAddress&email=joe@doe.com&format=json

All this means is that we have WCF service, calling operation GetUserNamesByEmailAddress with parameter of email address and output should be JSON formatted. This is the obvious way of web api. For robots to consume it. But we want to be human and show our human web façade.

http://mywonderfulhost/json/getUser?joe@doe.com

Looks much better and passes exactly the same information to the service. So how this done? First of all let’s get rid of annoying Service.svc. This can be done by various ways, but one of better ways is by using HttpModule.

We create a class deriving from IHttpModule and upon the request begins, “translate” it from human to robot version.

public class ProxyFormatter : IHttpModule {

private const string _handler = "~/Service.svc";

public void Init(HttpApplication context) {
         context.BeginRequest += _onBeginRequest;
}

private void _onBeginRequest(object sender, EventArgs e) {
         var ctx = HttpContext.Current;
            if (!ctx.Request.AppRelativeCurrentExecutionFilePath.Contains(_handler)) {
               if (ctx.Request.HttpMethod == "GET") {
                  var method = ctx.Request.AppRelativeCurrentExecutionFilePath.RemoveFirst("~/");
                  var args = ctx.Request.QueryString.ToString();              
                  ctx.RewritePath(_handler, method, args, false);
               } 
         }
      }

Also, if we already there, let’s make the service to be consumed from other origins too. Just add OPTIONS method handling and we done.

private void _onBeginRequest(object sender, EventArgs e) {
   var ctx = HttpContext.Current;
   ctx.Response.AddHeader("Access-Control-Allow-Origin", AllowedHosts ?? "*");
   if (ctx.Request.HttpMethod == "OPTIONS") {
      ctx.Response.AddHeader("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
      ctx.Response.AddHeader("Access-Control-Allow-Headers", "Content-Type, Accept");
      ctx.Response.End();
   } else {
      if (!ctx.Request.AppRelativeCurrentExecutionFilePath.Contains(_handler)) {
         if (ctx.Request.HttpMethod == "GET") {
            var method = ctx.Request.AppRelativeCurrentExecutionFilePath.RemoveFirst("~/");
            var args = ctx.Request.QueryString.ToString();              
            ctx.RewritePath(_handler, method, args, false);
         }
      }
   }
}

Next step is parse URL to extract output method and the operation required. All information we need is inside WebOperationContext.Current.IncomingRequest. All we have to do now is to parse it.

var req = WebOperationContext.Current.IncomingRequest;
if (!_getMethodInfo(req.UriTemplateMatch, out format, out method)) {
   WebOperationContext.Current.SetError(HttpStatusCode.PreconditionFailed, "Wrong request format. correct format is : /operation/format(json:xml)");
   return null;
} else {
//handle correct request
}

Inside _getMethodInfo we’ll count segments, find proper node formats and send out verdict.

private bool _getMethodInfo(UriTemplateMatch match, out NodeResultFormat format, out string method) {
   var c = match.RelativePathSegments.Count;
   var f = Enum.GetNames(typeof(NodeResultFormat)).FirstOrDefault(n => n.EqualsIgnoreCase(match.RelativePathSegments.Last()));
   if (f.NotEmpty()) {
      format = (NodeResultFormat)Enum.Parse(typeof(NodeResultFormat), f);
      method = match.RelativePathSegments.Take(c – 1).ToArray().Join(".");
      return true;
   }
   format = NodeResultFormat.Unknown;
   method = string.Empty;
   return false;
}

Now we know what output format is expected and what method was called by consumer. So, next task is to “humanize” method names and parameters. Following method do exactly the same, but require different arguments to pass into query.

  • GetUserNamesByEmailAddress (select name from users where email=…)
  • GetUserNamesByLastLogin (select name from users where lastLogin=…)
  • GetUserNamesByOrganizationAndFirstAndLastName (select name from users where organization like … and firstName like … and…)
  • GetUserNamesByUserId (select name from users where uid=…)
  • GetUserNames (select name from users)

So in order to make end human life easier, we’ll create helper data structure to hold all those possible values.

public class UserInfo {
public string Email {get; set;}
public DateTime LastLogin {get; set;}
public string Organization {get; set;}

This class will be used only to hold input data (internally, we’ll find what object type was sent and try to match it to the data structure. This will allow us to hint what exact method should be called to bring information.

In our particular case, simple regex to find “whatever@wherever” like /.+@.+\..+/I tell us to execute ________ByEmailAddress override on backend. If we’ll find something like getUsers?1232234323 or getUsers?15-2-2013, we’ll be sure that GetUserNamesByLastLogin should be used.

So on we can handle all common cases for human customer and start simplification of our life too. for example, create self descriptive automatic handlers in this method. But… we’ll speak about it next time.

Have a nice day (or night) and be good humans.

Programming for Windows 7

Well, Windows 7 is going to be released by the end of next year. This is great news, because it seemed, that Microsoft finally understand how to get the best of Windows Vista and make it to work not only on monster machines.

image

It even works on new brandy my wife’s pinky machine. And if it works there and my wife is happy with it, this OS going to be very impressive.

image

But from the other hand, we, as developers should be ready today to developer Windows 7 ready application (by the way, Vista Battery Saver works for Windows 7 as well as for Windows Vista, in spite of the fact, that power management in Windows 7 was improved dramatically). So let’s start!

First thing we need is to read big Windows 7 Developer Guide. This document will explain most of new features for developers to build applications right. What is includes?

Windows Driver Kit (WDK) 3.0

Basically, Windows 7 works with Vista drivers, however, hibernation, power management, networking, PREfast will work much better. You also will have new WMI access for reliability monitors and ACPI.

Management and deployment

By default Windows 7 uses PowerShell 2.0 and Windows Installer. For PowerShell it includes enhanced cmdlets to manage Active Directory, IIS, etc. For Windows Installer, you finally can build “chainers” by yourself (the same approach, used for latest deployment of Microsoft products such as Silverlight, Visual Studio 2008 SP1 etc.) Also, you can get advantage by using Windows Filtering Platform (Firewall) and User Account Control (UAC) from inside your application by using new APIs.

Performance

The most significant change in Windows 7 for end-user point of view is improved performance. Windows 7 kernel is much smaller, that kernel of Windows Vista. Also it uses specific patterns to decrease background activities on low power, based on system triggers. New user-mode and kernel-mode APIs are used by Windows Drivers Foundation much more efficiently. Also system services are much smarter. For example, DCIA starts only when you connect new hardware. After drivers were installed the service shuts down. The same approach used by domain join, GP changes, new IP fetching etc. Windows 7 knows to run and stop services, based on system events, which decreases average work load and enhances whole system performance.

Multi-touch gestures and Interia API and used interface in general

Yes, you can use this API for your applications. Finally we can have more, then just mouse. And it is not only about multiple mouse devices. We can use single finder panning, raw touch input data, internal multitouch ink recognition, which is also supports math. Also it uses build-in MathML export feature.

There are a lot of other enhancements, such as smart bars, windows’ stacking, gadget desktop (it does not eat battery as external process anymore), system ribbon menu integration. etc

Graphics

Direct 11, new Direct2D, DirectWrite (we can turn text anti-aliasing for small fonts, hurrah!), improved WIC, DX/GDI interoperability on system level with automatic fallback for weak hardware (yes, you should not be worry about it anymore). Also new video and audio format support with human readable interfaces. Yes, no more DirectDraw hacks. We can use new high level interfaces such as MFPlay to manage playbacks, Source Reader for decoding, Sink Writer for transcoders and re-coding compressions.

Web and communication

WCF is inside, as well as distributed routing table for peer-to-peer operations. BranchCache – new technology to reduce WAN traffic and latency.

Also Windows 7 is compatible with OpenSearch (I told, that Microsoft does not know to build search engines). Sharepoint integration and environment sensors platform, that can be used either for desktop and web applications.

There are much more features, that makes Windows 7 to pretend to be very good operation system. If you want to learn more about all those Windows 7 new features, I highly advice you to download and read this document. It includes most of new features of new OS with explanations and screenshots to make your learn and understand what can your future application do with all those new features.

Have a nice day and be good people.

BTW, if you have PDC version of Windows 7 and want to unlock it for using of some cool features, introduced during keynotes, it worth to visit here and learn how to :)

Download Windows 7 Developer Guide and start programming.

.NET 3.5 SP1 is RTM and available for download

For all those who asked, .NET 3.5 SP1 is final and available for download. What’s inside?

  • ASP.NET Dynamic data
  • Core improvements for CLR
  • A lot of performance improvements in WPF
  • ClickOnce enhancements
  • ADO.NET with Data Services and Entity Framework
  • LINQ2SQL and Data Provider for SQL Server 2008, that was released last week
  • WCF with easier DataContract serialization

Download it with Web Installation or as Full Package

For more information, please see Read Me and KB about .NET 3.5 SP1 RTM. If you faced with any issue, please provide us with feedback via MS Connect

How to consume WCF or Webservice from Vista Sidebar gadget by using Silverlight?

The challenge today is really simple. All we have to do is to write Silverlight Vista Sidebar Gadget, that consumes either WCF, ASMX or REST based service. Really simple, isn’t it? Let’s start

image

Build server side services

We should start from services. This is very straight forward mission. Here the logic I want to implement

public string Echo(string input)
    {
        return string.Format("ACK from {0}", input);
    }

Well, WCF? We should mark service and operation contracts. That’s all

[ServiceContract(Namespace = "")]
public class EchoService
{
    [OperationContract]
    public string Echo(string input)
    {
        return string.Format("ACK from WCF with {0}", input);
    }

}

This does not works. Why? Silverlight knows only consumes ASP.NET compatible (simplified) web services, thus we should add following attribute to the our class attributes collection

[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class EchoService
{

Now, the service is discoverable and accessible by Silverlight. Great news. Now let’s put it into our shared host. Hmm, we got strange error: “Deploying WCF Services: This collection already contains an address with scheme http.” What the hell is it?

This is shared hosting problem. Your host provider uses virtual IP and host addresses and has number of different web services, sitting on the same shared host. How to solve it?

Simple, all you have to do is to specify your own service host factory. Here the example of classes to put into code behind

class SLHostFactory : ServiceHostFactory
{
    protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
    {
        SLHost customServiceHost =
          new SLHost(serviceType, new Uri("[Your URL goes here]",UriKind.Absolute));
        return customServiceHost;
    }
}

class SLHost : ServiceHost
{
    public SLHost(Type serviceType, params Uri[] baseAddresses)
        : base(serviceType, baseAddresses)
    { }
    protected override void ApplyConfiguration()
    {
        base.ApplyConfiguration();
    }
}

And one attribute into your service tag

Factory="SLHostFactory"

Now it works. So what’s next? Build ASMX web service. This is even simpler

[WebMethod]
public string Echo(string input)
{
    return string.Format("ACK from web service with {0}", input);
}

We done, now either WCF and Web services are accessible from your Silverlight application. So, add Service reference and consume it

Building client side

Inside code behind of your Silverlight project, you should define two proxies – one for Web Service and another for WCF service. Bother services implements the same interface, so it should not be a problem

ServerEcho.EchoServiceClient proxy;
WebServiceEcho.EchoWebServiceSoapClient wsProxy;
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
    proxy = new ServerEcho.EchoServiceClient();
    proxy.EchoCompleted += new EventHandler<ServerEcho.EchoCompletedEventArgs>(proxy_EchoCompleted);

    wsProxy = new SLGadget.WebServiceEcho.EchoWebServiceSoapClient();
    wsProxy.EchoCompleted += new EventHandler<SLGadget.WebServiceEcho.EchoCompletedEventArgs>(wsProxy_EchoCompleted);
}

Silverlight work only asynchronously, thus you should begin to understand, that synchronous programming is for pussies :) . Consume it

private void WCF_Click(object sender, RoutedEventArgs e)
        {
            proxy.EchoAsync(txt.Text);
        }

        private void WS_Click(object sender, RoutedEventArgs e)
        {
            wsProxy.EchoAsync(txt.Text);
        }

And Update output

void wsProxy_EchoCompleted(object sender, SLGadget.WebServiceEcho.EchoCompletedEventArgs e)
        {
            txt.Text = e.Error == null ? e.Result : (e.Error.InnerException != null ? e.Error.InnerException.ToString() : e.Error.Message);
        }

        void proxy_EchoCompleted(object sender, ServerEcho.EchoCompletedEventArgs e)
        {
            txt.Text = e.Error == null ? e.Result : (e.Error.InnerException != null ? e.Error.InnerException.ToString() : e.Error.Message);
        }

Now let’s run it. What? Another error? Security? Access denied? Of cause you have no crossdomain.xml.

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
   <allow-access-from domain="*" />
</cross-domain-policy>

What? You have it and still getting the same error? Look into sniffer. You application is looking for other file, named clientaccesspolicy.xml. Why? According the documentation, you can use either… Hm, another bug with WCF consuming. Never mind, let’s put it too

<?xml version="1.0" encoding="utf-8"?>
<access-policy>
  <cross-domain-access>
    <policy>
      <allow-from http-request-headers="*">
        <domain uri="*"/>
      </allow-from>
      <grant-to>
        <resource path="/" include-subpaths="true"/>
      </grant-to>
    </policy>
  </cross-domain-access>
</access-policy>

Very well, now we are ready to run our application. It works! So, the only thing we should do is to pack it into MyGadget.gadget directory and put inside %userprofile%\appdata\local\microsoft\windows sidebar\gadgets together with gadget.xml manifest.

But… It stopped working… What’s the problem?

Very client side networking in Silverlight

The problem is, that SideBar executes it’s gadgets with local path, not with network path. Silverlight cannot use any network provider, when running locally. Why? Actually I do not know (maybe to prevent local applications development). so what to do?

Simple! Microsoft SideBar knows to run cross domain AJAX without any warnings and problems. So why not to use external XmlHttp from JavaScript for network access. Let’s do it

First we should initialize XMLHttpRequest object in JavaSctipt

var xObj;

        function getEchoWCF(text) {

            if(xObj == null) {   
                xObj = new XMLHttpRequest();

                }

            else if(xObj) {

                xObj.abort();

            }

Then create SOAP request to WCF or WebService

var sURL = "[Path yo your service]";

            //Build SOAP

            var sReq = "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Body><Echo><input>"+text+"</input></Echo></s:Body></s:Envelope>";

            xObj.open("POST", sURL, true);

            xObj.setRequestHeader( "Content-Type", "text/xml; charset=utf-8" );

            xObj.setRequestHeader( "Cache-Control", "no-cache" );

xObj.send(sReq);

After the request created and send we should handle result. So we need an access from HTML page, hosting Silverlight object to Silverlight. Simple. “ScriptableMember – ScriptableType”, remember?

[ScriptableType]

    public partial class Page : UserControl

    {

[ScriptableMember]

        public void UpdateResponse(string result)

        {

Now return the result

xObj.onreadystatechange = function() {

            if (xObj.readyState === 4) {

                if (xObj.status && xObj.status === 200) {   
                    var control = document.getElementById("silverlightControl");

                    control.Content.Page.UpdateResponse(xObj.responseText);

                }

            }

But this is not enough. We also should know to call Javascript from Silverlight… This is really simple

private void JS_Click(object sender, RoutedEventArgs e)

        {

            HtmlPage.Window.Invoke("getEchoWCF", txt.Text);

        }

We done. Now you can pack your Silverlight control, together with hosting HTML and Javascript into windows sidebar gadget and use it even with external network support.

Have a good day and be nice people.

Silverlight 2.0 for building Rich Internet Applications (local event)

If you are developing rich internet applications, web sites or just want to learn what’s new in Silverlight 2.0, you are invited to attend  local (Israel) Microsoft Event 30-June 8:30 AM- 12:30 PM in ILDC (new Microsoft R&D offices in Herzliya).

image

I’ll speak about what is Silverlight 2.0 and what are differences between SL 1.0 and SL 2.0. How to build RIA with Silverlight 2.0. What is DeepZoom and some cool parts of this new internet technology. How to use DataBinding, LINQ and Microsoft Media Encoder. As small bonus for this part of the event, we’ll compare different technologies with Silverlight such as Flex, Flash 10, Thermo and SVG to make you understand differences, “pros and cons” of using each one of those technologies for specific and identifiable needs.

Then we’ll deep dive into DataBinding and learn about DataTemplates, Styles, Accessibility, Authoring and Usability (including differences between Silverlight and WPF approaches). We’ll also take a look into LINQ-to-SQL and SEO of Silverlight applications.

Third part of this event will be dedicated to networking and interoperability. We’ll speak about internet protocols such as ATOM, RSS, REST, JSON, XMLWS, etc and usage of those protocols by Silverlight applications. We’ll understand how WCF can assist us to make our live easier. We’ll also touch security issues of Silverlight deployment and networking such as Cross Domain Policy, progressive download and deploy-on-demand.

I can make you sure, that if ”you are in” new web technologies and want to start using (or if you already using) Silverlight 2.0 for development of your applications – come and see me. Will be fun!

Note: Only a limited number of places available, so do not wait for MS newsletter (by the end of this month). Book now and come to attend this event – it’s free! (there is parking lot in floor -2)

I want to attend “Silverlight 2.0 introduction for building rich internet applications” event (30-June 8:30 AM – 12:30 PM, ILDC Herzelia, 5, Gav-Yam str, floor L2 13,Shenkar str)

See you there…

UPD 29-Jun: Next session will take place at 23 July, 8:30 AM-12:30 PM. Register by visiting Microsoft events web application at https://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032382418&culture=he-IL and sign up.

Microsoft .NET framework 3.5 beta exams

Do you want to be the first, who’ll judge my work last summer? Participate 71-502 – Microsoft.NET Framework 3.5 – Windows Presentation Foundation beta exams. You can participate until 24-Jan here. Possible, that this exams will be even poorer, then 70-552, however, who knows? You tell us! Register at http://www.register.prometric.com/ClientInformation.asp. No guarantee of a seat, not avaliable in China, India and Pakistan.

If you do not want to pass WPF, you can participate beta of WCF or WF. Before taking those, read here and here. Also, you are more, then invited to feedback Gerry.

Good luck!

Visual Studio "Orcas" June 2007 CTP is available

After a limited beta Visual Studio 2008 (“Orcas”) June CTP VPC is available to wide public. A lot of bugs fixed (thank you all those who tested it), some new features added. Nice work!

Download VS2008 June 2007 CTP VPC

Orcas June CTP for limited beta is available

After releasing June CTP of .NET framework 3.5, June CTP bits of Visual Studio 2008 (Team Suite and Visual Web Developer) are also ready for limited beta as Layout or VPC image. If you want to test it, please let me know via comments or by contacting me directly.

WPF binding to WCF and more

Windows foundations are great. But how to make them work together. Today, I decided to explain how to build simple WPF application, with data, achieved from WCF OperationContracts (Methods) with simple and complicated parameters. So, let’s start.

First of all, we’ll create simple WPF application, then we’ll add WCF Service Library to our solution. It’ll create nice template with explanations what to put where. So, we’ll use it AS-IS and use our WPF application as host for WCF service (this can run in different application as well). So, do everything written in the template. Create App.config and write where

<system.serviceModel>
    <services>
      <service name="FlickrHost.service1">
        <endpoint contract="FlickrHost.IService1" binding="wsHttpBinding" />
      </service>
    </services>
  </system.serviceModel>

 

Additional file with host start and stop and methods into Window1.xaml.cs

public Window1()
        {
            InitializeComponent();
            MyServiceHost.StartService();
            
        }
       

        ~Window1()
        {
            MyServiceHost.StopService();
        }

 

So far, so good. Compile, run – ERROR, AddressAccessDeniedException: ”HTTP could not register URL http://+”. What the hell? We can not create entrypoint as user because of UAC in Vista. So, let’s see what we can do.

Open command prompt and type “netsh http show urlacl”. You’ll get something like this

Reserved URL            : http://+:80/wsman/
    User: NT AUTHORITY\NETWORK SERVICE
        Listen: Yes
        Delegate: Yes
        SDDL: D:(A;;GA;;;NS)

Reserved URL            : http://+:80/Temporary_Listen_Addresses/
    User: \Everyone
        Listen: Yes
        Delegate: No
        SDDL: D:(A;;GX;;;WD)

What is it? Why we can not use port 8080, provided by template. Let’s add it into our account.
netsh http add urlacl url=http://+:8080/ user=DOMAIN\username. You’ll get error:

Url reservation add failed, Error: 5
The requested operation requires elevation.

Run the command shell “As Administrator” and you’ll success. So, UAC good or not for jews? You choose :)

Next step is creation of  ObjectDataProvider, that uses the service methods to provide results. We’ll add additional method to default WCF service template, that receives no parameters. Something like this will definitely fine.

[ServiceContract()]
    public interface IService1
    {
        [OperationContract]
        string MyOperation2(string myValue);
        [OperationContract]
        string MyOperation3(DataContract1 dataContractValue);
        [OperationContract]
        string MyOperation1();
    }

    public class service1 : IService1
    {
        public string MyOperation2(string myValue)
        {
            return "Hello: " + myValue;
        }
        public string MyOperation3(DataContract1 dataContractValue)
        {
            return "Hello: " + dataContractValue.FirstName;
        }
        public string MyOperation1()
        {
            return "Hello World!";
        }
    }

 

Now, back to WPF. I believe you know, that you can bind to methods?

<ObjectDataProvider ObjectType="c:service1" x:Key="operation1" MethodName="MyOperation1"/>

 

Adding TextBlock, binded to this object and wow, we have Hello World application.

<TextBlock Text="{Binding Source={StaticResource operation1}}"/>

 

So far so good. Now, we have two additional methods, that need parameters. One is regular string, but other is DataContract from WFC service. How to do it? How to understand how to pass parameters into methods. For WPF - this is really simple. For us – not so straight forward – there is no intellisense support in XAML schema for such features in VS2005 with .NET 3.0 toolkit. What we have to do, is to use ObjectDataProvider.MethodParameters variable to set parameters for the method, bided into ObjectDataProvider. Let’s rock’n'roll.

<ObjectDataProvider ObjectType="c:service1" x:Key="operation2" MethodName="MyOperation2">
      <ObjectDataProvider.MethodParameters>
        <s:String>aaa</s:String>
      </ObjectDataProvider.MethodParameters>
    </ObjectDataProvider>

 

Well. We have System mscorlib clr namespace, but what to do with object (Data Contact), defined in WCF service? For real? The same stuff. The only difference is other namespace and internal object initialization and assignment. Here comes the king.

<ObjectDataProvider ObjectType="c:service1" x:Key="operation3" MethodName="MyOperation3">
      <ObjectDataProvider.MethodParameters>
        <c:DataContract1>
          <c:DataContract1.FirstName>
            <s:String>bbb</s:String>
          </c:DataContract1.FirstName>
        </c:DataContract1>
      </ObjectDataProvider.MethodParameters>
    </ObjectDataProvider>

 

So far, we have three methods, binded to objects, achieved from WCF service provider, run by WCF data host. But wait. The data is not read only. We can change it. What’s the hell, we can not notify to the object data provider about changes, there are no INotifyUpdate interface implemented as well as nothing can call us back about the change. What to do?

The simpler answer – DIY. The complicated make your client application notify about. So, I’ll add TextBox and Button. Once the button clicked, I’ll read information from the textbox, update my WCF service and notify about the changes.

void onClick(object sender, RoutedEventArgs e)
        {
            ObjectDataProvider odp2 = Resources["operation2"] as ObjectDataProvider;
            odp2.MethodParameters[0] = name.Text;
            odp2.Refresh();

            ObjectDataProvider odp3 = Resources["operation3"] as ObjectDataProvider;
            ((FlickrHost.DataContract1)odp3.MethodParameters[0]).FirstName = name.Text;
            odp3.Refresh();
        }

 

Well. We did it. Now let’s write real world application. Read the attached source name and you’ll may understand, that I’m going to write service, that reads, parses and uses beautiful images, found here. But, not today :)

Source code for this article

Recommended

 

Sponsor


Partners

WPF Disciples
Dreamhost
Code Project