Friday, May 28, 2010

Invoking a Method Call Over RIA Services

To invoke a method through RIA Services:

On the server side, declare the method, an decorate it with the [Invoke] annotation. Return types can be simple types or collections.  Not sure if complex types work or not.

[Invoke]

public string BuildAdjusterMetricBatch(string users)
{
    DoSomeWork()

    return batch;
}

On the client side, invoke the method, and pass it a function for the asynchronous Callback:

var context = new Web.Services.MSIClaimContext();
context.BuildAdjusterMetricBatch(txtFilter.Text,  
    BatchBuildCompleted, null);

then declare a method for the callback that matches the return type of the Method.

void BatchBuildCompleted(InvokeOperation<string>
    invokeOperation)
{
    string myValue = invokeOperation.Value;
    DoClientSideWork();

}

No comments:

Post a Comment