November 28, 2008
Probem With Cross-Domain Silverlight Calls
I've just been trying to get a Silverlight control to make a cross-domain HTTP POST call using an experimental Silverlight build of XML-RPC.NET. I placed a client access policy file on the root of the server but I was still getting a System.Security.SecurityException when I tried to make the call. I eventually worked out the cause of the problem was that when I created the Silverlight project in Visual Studio I selected "Automatically generate a test page to host Silverlight at build time". This results in the page being loaded using the file:// scheme when debugging, and cross-scheme access is not allowed in this case, i.e. file:// to http://, even with a client access policy file on the server.
I created another project and this time chose the option to add a web project to the solution. The cross-domain calls, now http:// to http://, succeeded.
November 02, 2008
XML-RPC From F#
#light
open CookComputing.XmlRpc
type Request = { state1 : int; state2 : int; state3 : int; }
[<XmlRpcUrl("http://www.cookcomputing.com/xmlrpcsamples/RPC2.ashx")>]
type IStateName =
[<XmlRpcMethod("examples.getStateName")>]
abstract GetStateName : number: int -> string
[<XmlRpcMethod("examples.getStateStruct")>]
abstract GetStateNames : request: Request -> string
let proxy = XmlRpcProxyGen.Create<IStateName>()
let name = proxy.GetStateName(1)
printfn "name is %s" name
let request = { state1 = 1; state2 = 2; state3 = 3; }
let names = proxy.GetStateNames(request)
printfn "names are %s" names
September 01, 2007
Contract Name Not Found In List Of Contracts
I have just started to dive into Windows Communication Foundation. Long overdue I know. One beginner's tip is that if an instance of InvalidOperationException is thrown when you try to create your service host and the exception's message is something like this:
The contract name 'TestContract' could not be found in the list of contracts implemented by the service 'TestService'.
... it may be because you have forgotten to specify that the interface is a service contract. You need to decorate the interface with the ServiceContract attribute:
[ServiceContract]
public interface TestContract
{
[OperationContract]
int Add(int x, int y);
}