This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hiya,
I'm trying to put together a "hello-world"-type application in silveright, where the client would make a call via a WCF web service, and retrieve a "hello world" from an SQLite or MySQL database.
I seem to fail tragically at this, how can this be achieved? I want to have a LSmodel on the server-side which would be used to query the DB using LINQ and results would be returned via WebService's methods?
|
|
|
Have a look at the sample "DTO Sample", included with LightSpeed 3. This doesn't use Silverlight as a client, but it does demonstrate how to build a Web service with LightSpeed (using SQLite as it happens). You should then be able to use Add Service Reference in your Silverlight project to bring in the service. (Warning: I have found that, if you use the "Discover services in solution" option, ASR can be a bit shonky -- it has a tendency to use the wrong protocol, which you can fix in the WCF client bindings, and you'll probably need to turn off the "reuse types in referenced assemblies" option via the Advanced button.) |
|
|
I'm trying to run the sample, but I keep getting exceptions, so I'm unable to see it in "all the glory".
System.ServiceModel.FaultException was unhandled by user code
Anyway, I see that the idea in this case is to host the service "manually" via a ServiceHost, it's confusing for me a bit... Is it possible to create a Silverlight-enabled WCF Service that is capable of utilizing LightSpeed? If I create a basic service of such type I get the following code :
[ServiceContract(Namespace = "")]
How should I modify the above code to get the same result as in the sample? Could you show me that please? I really don't see it. |
|
|
Well, return void isn't very useful for a service that's going to return DTOs, so the first thing to do is create a new method in the interface: [OperationContract] Then we create an implementation in the service class: public ProductDto[] GetProducts() You'll need to add the relevant using statements of course. I've simplified this slightly so as to make the UOW boundaries explicit and avoid the ServiceBase and UOW scope classes. But basically you should be able to take all the service stuff -- i.e. everything except the ServiceHost plumbing -- and copy that directly into an ASP.NET hosted WCF service. |
|