In this article we will learn:
- How to create Silverlight applications
- How to create simple WCF services
- How to deploy solutions on Arvixe
Preparation
To work with Silverlight 4 in Visual Studio 2010, you will need to download and install Silverlight Tools 4
Create project
Open Visual Studio and create a Silverlight Application
The New Project wizard prompts you to create our site for Silverlight applications
Create Simple WCF Services
Right click on Web project and select the “Add -> New Item…” menu
IDateTimeService.cs
[ServiceContract]
public interface IDateTimeService
{
[OperationContract]
DateTime GetDateTime();
}
DateTimeService.cs
public class DateTimeService : IDateTimeService
{
public DateTime GetDateTime()
{
return DateTime.Now;
}
}
web.config
<?xml version=”1.0“?>
<configuration>
<system.web>
<compilation debug=”true” targetFramework=”4.0” />
<customErrors mode=”Off“/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name=””>
<serviceMetadata httpGetEnabled=”true” />
<serviceDebug includeExceptionDetailInFaults=”true” />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled=”true” />
</system.serviceModel>
</configuration>
Click Add Service Reference next:
In the “Add Service Reference” dialog window, press “Discover” button and select service.
MainPage.xaml.cs
public partial class MainPage : UserControl
{
DateTimeServiceClient proxy;
public MainPage()
{
InitializeComponent();
proxy = new DateTimeServiceClient();
proxy.GetDateTimeCompleted += (sender, e) =>
{
textBlockDateTime.Text = e.Result.ToString();
};
}
private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
{
proxy.GetDateTimeAsync();
}
}
The coding is now over. Press F5 to run solution.
Deployment
Publish the Web project to file system first:
Upload the published site via FTP to Arvixe.com. In Web Site Control Panel, on the “Extensions” page, choose ASP.NET version “4.0”. Also, specify BlogArvixeCom.UserNT.WCFTestPage.aspx as default document on the “Home Folder” page. That seems to be all, but do not be surprised if clicking on the button “Server side time” causes nothing to happen. The file ServiceReferences.ClientConfig file is configured to work on localhost. All you need to do is set the correct endpoint address.
Must be remember in the website, just the WFC endpoint, change to wshttpbinding to basicHttpBinding.
I forgotten.. is the web.config where the changes…
In my approach used basicHttpBinding by default. Of course you can configure bindings in web.config. But this is beyond the scope of this article.
Setting Proxy
Cool! Thanks for this interesting post!
Heya i’m for the first time here. I came across this board and I find It really useful & it helped me out a lot. I hope to give something back and help others like you helped me.