Locations of visitors to this page


Onteora Software - July 2008

Onteora Software

Ken Tucker's Blog

About the author

Author Name is someone.
E-mail me Send mail

Recent posts

Recent comments

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008

Publishing a VB Silverlight 2 Beta 2 app which uses a WCF service

I created a Silverlight 2 beta 2 app which uses a WCF Silverlight service which worked fine localy but did call the service when I published it to my web host.  After playing around with the different settings I finally came across an entry in the Silverlight Forums by sladapter with a solution. 

 

http://silverlight.net/forums/t/19021.aspx 

 

So lets create a simple Silverlight 2 App to demo how to do this.  I created a silverlight app with a web application project.   I prefer web applications to web sites but a web site will work the same.  

 

Add a WCF Silverlight- enabled service named  service1 to the web application. 

 

This is the code I am using for the service

 

Imports System.ServiceModel
Imports System.ServiceModel.Activation

<ServiceContract(Namespace:="")> _
<AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Allowed)> _
Public Class Service1

    <OperationContract()> _
    Public Function SayHello() As String
        ' Add your operation implementation here
        Return "Hello World"
    End Function
End Class

 

Lets add a TextBlock to the Page.xaml to display our message.

 

<UserControl x:Class="SilverlightApplication2.Page"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Width="400" Height="300">
    <Grid x:Name="LayoutRoot" Background="White">
            <TextBlock x:Name="txt">Loading..</TextBlock>
    </Grid>
</UserControl>

 

Now run the app.  Once that is done we can add a service reference to our silverlight app.  Press the arrow on the Discover button and select services in the solution.  You should windup with something like this.

 

image

 

In the silverlight app open up the file ServiceReferences.ClientConfig

 

<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_Service1" maxBufferSize="65536"
                    maxReceivedMessageSize="65536">
                    <security mode="None" />
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:1205/Service1.svc" binding="basicHttpBinding"
                bindingConfiguration="BasicHttpBinding_Service1" contract="ServiceReference1.Service1"
                name="BasicHttpBinding_Service1" />
        </client>
    </system.serviceModel>
</configuration>

 

In the endpoint address change the contract to include the project name.

 

<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_Service1" maxBufferSize="65536"
                    maxReceivedMessageSize="65536">
                    <security mode="None" />
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:1205/Service1.svc" binding="basicHttpBinding"
                bindingConfiguration="BasicHttpBinding_Service1" contract="SilverlightApplication2.ServiceReference1.Service1"
                name="BasicHttpBinding_Service1" />
        </client>
    </system.serviceModel>
</configuration>

 

Now lets add some code to call the service. Page.Xaml.VB

 

Partial Public Class Page
    Inherits UserControl
    Dim current As String

    Public Sub New()
        InitializeComponent()
    End Sub

    Private Sub Page_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded
        Dim ws As New ServiceReference1.Service1Client
        AddHandler ws.SayHelloCompleted, AddressOf HelloComplete
        ws.SayHelloAsync()
    End Sub

    Private Sub HelloComplete(ByVal sender As Object, ByVal e As ServiceReference1.SayHelloCompletedEventArgs)
        txt.Text = e.Result
    End Sub

End Class

 

Now if we run the app you should see Hello World but when published you will only see loading.   So lets change how we create the service so that this will work once deployed.  Basically we tell the service to use the current web address.

 

Private Sub Page_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded
    Dim address = New Uri(Application.Current.Host.Source, "../Service1.svc")

    Dim ws As New ServiceReference1.Service1Client("BasicHttpBinding_Service1", address.AbsoluteUri)
    AddHandler ws.SayHelloCompleted, AddressOf HelloComplete
    ws.SayHelloAsync()
End Sub

 

Hope this helps

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: Silverlight | VB
Posted by Ken Tucker on Tuesday, July 15, 2008 1:54 PM
Permalink | Comments (0) | Post RSSRSS comment feed

The INETA Community Champion Award

INETA Rewards those Active in the User Group Community

An XBox or MSDN Subscription to the 10 Most Active Contributors in the User Group Community each quarter.
How?  By doing what you are doing already, you stand to win:
a) Valuable Prizes: An MSDN Subscription.  And, if you already have one, you can choose an XBox instead.

XBox
MSDN Professional Subscription

XBox
MSDN Subscription

b) The Fame and Prestige of having an award to hang on your wall that shows that INETA recognizes your contributions to the User Group Community.

Champion Award

c) Official Recognition on the INETA Website  for one year.
All of your peers will be able to see that you stand out above the crowd. If the opportunity presents itself for you to show your dedication to the User Group Community in a public way, there is no better way than to show off your name highlighted on the website of a highly respected organization like INETA.
d) A Badge for your website showing that you are a Community Champion.
When folks visit your website, blog or any other place where you publicly post your work, they will see that you are a Community Champion.
Oooohhhh. Recognition by INETA? Valuable Prizes? An award to hang on my wall? A Badge?  How can I participate?

Well, I am glad that you asked.

INETA has long been known for it's support of User Groups and this year, there are a number of great new programs supporting the User Group Community.  The Community Champs program is one of them.  INETA wants to recognize individuals who are demonstrating their involvement in the User Group community.  The program is aimed at rewarding those that are the most active with the prizes and award mentioned above.  It is INETA's way of recognizing the ones that really bring the community together.  So, in short, if you are the kind of person who helps to run user group meetings, codecamps, or helps out in any number of other ways, you should let INETA know the kind of activities that you are involved in.  If you are very active, you may be recognized by INETA in a very public and spectacular way for the activities that you currently do to help the user group community.

INETA and Community-Credit are making it happen.

Community Credit has been helping to recognize fellow developers for the past number of years for their accomplishments and INETA has been the mainstay of User Groups for many years, so it is no surprise that the two would be working together to make this great program possible.  Best of all, the contributions that you record will also count toward Community Credit prizes, so you may even have a chance to be rewarded with a Geeky, Community Credit prize as an added bonus.

How do I submit my contributions?

Visit the INETA website and go to the Champions section, sign in and let INETA know what you are doing by recording your contributions.  The current quarterly period counts for contributions during period of  June 30th, 2007 to June 30th, 2008.  The final submissions can be made until July 14th.  Keep in mind that the end of this current quarter is coming up pretty soon, so if you have been very active over the last year, be sure to enter them soon so that you don't miss this great opportunity.

What are the benefits of participating?

If you are an individual who is always contributing to the User Group Community, you do it because you like it.  You don't do it because you expect to be rewarded.  At the same time, if you just happen to be rewarded and recognized then that makes it that much better.  Imagine playing on an XBox that you received as a thanks for all of your hard work.  It makes the games just a little bit more fun.  Using your MSDN subscription that you "earned" makes the tools just a little bit better and seeing the award hanging on your wall is a reminder to you and your colleagues just how committed you are.

Can anybody participate?

Unfortunately, the current period (being our first) is for participants in North America only.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: User Group
Posted by Ken Tucker on Tuesday, July 01, 2008 12:34 PM
Permalink | Comments (0) | Post RSSRSS comment feed