Social Icons

twitterfacebookgoogle pluslinkedinrss feedemail
Showing posts with label WCF. Show all posts
Showing posts with label WCF. Show all posts

Saturday, January 26, 2013

Implementing a Basic Hello World WCF Service (v4.5)

In this article, we will implement a basic WCF 4.5 service from scratch. We will build a HelloWorld WCF service by carrying out the following steps:
  • Create the solution and project
  • Create the WCF service contract interface
  • Implement the WCF service
  • Host the WCF service in IIS Express
  • Create a client application to consume this WCF service
✔ Read More...

I guess you came to this post by searching similar kind of issues in any of the search engine and hope that this resolved your problem. If you find this tips useful, just drop a line below and share the link to others and who knows they might find it useful too.

Stay tuned to my blogtwitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.


This article is related to
C#,.NET,Architect,Intermediate,VS2010,.Net,Articles,Computer Tutorials,WCF,.Net 4.5

Sunday, January 6, 2013

How to Build Flexible and Reusable WCF Services

As you may know, designing and building a flexible and reusable service layer is essential when creating robust multi-tier applications. In this article, we will discuss the pros and cons of different architectural approaches to building a service layer.

You will learn design patterns that help in building reusable services, and we will demonstrate how they are implemented for WCF services with the Open Source Xomega Framework.

We will also talk about the challenges of using WCF in Silverlight as well as solutions to work around those challenges.

✔ Read More...

I guess you came to this post by searching similar kind of issues in any of the search engine and hope that this resolved your problem. If you find this tips useful, just drop a line below and share the link to others and who knows they might find it useful too.

Stay tuned to my blogtwitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.


This article is related to
C#,.NET,Architect,Intermediate,VS2010,.Net,Articles,Computer Tutorials,WCF

Saturday, January 5, 2013

Silverlight Application with Dispatcher and asynchronous WCF service

This article is about Dispatcher that makes Silverlight application responsive. It demonstrate how Dispatcher allows to update UI of the application on the response from WCF service which is called asynchronously  and while continue to execute the other task..


I guess you came to this post by searching similar kind of issues in any of the search engine and hope that this resolved your problem. If you find this tips useful, just drop a line below and share the link to others and who knows they might find it useful too.

Stay tuned to my blogtwitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.


This article is related to
C#,.NET,Architect,Intermediate,VS2010,.Net,Articles,Computer Tutorials,Silverlight,WCF Service,WCF,Dispatcher

Tuesday, November 20, 2012

How to Use Dependency Injection (Ninject) with WCF Services

I spent a lot of time late last week trying to figure out exactly how to set up dependency injection for a WCF service I was developing on Windows Azure; there's some documentation out there on how to do it, but it's not nearly as helpful as I would like it. Thus I decided to document how I made WCF and Ninject play nice with each other, and I even provide a sample template you can use yourself.


I guess you came to this post by searching similar kind of issues in any of the search engine and hope that this resolved your problem. If you find this tips useful, just drop a line below and share the link to others and who knows they might find it useful too. 


Stay tuned to my blogtwitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.


This article is related to
C#,.NET,Architect,Intermediate,VS2010,.Net,Articles,Computer Tutorials,Dependency Injection,Ninject,WCF

How to Transfer a File with WCF Service

I wanted to expose a very simple service to upload and download files through WCF. And because I wanted to be able to pass both the file content as a stream and at least the file name, I could not just use a Stream but had to resort to using Messages: the headers would convey the file information (such as the file type) and the body the content of the file itself through a stream.


I guess you came to this post by searching similar kind of issues in any of the search engine and hope that this resolved your problem. If you find this tips useful, just drop a line below and share the link to others and who knows they might find it useful too. 


Stay tuned to my blogtwitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.


This article is related to
C#,.NET,Architect,Intermediate,VS2010,.Net,Articles,Computer Tutorials,WCF

Sunday, November 11, 2012

Select Data using LINQ with WCF

Select Data using LINQ with WCF

Select Data using LINQ with WCF   Introduction Today, in this article let's play around with one of the interesting and most useful concept in LINQ.   Question: What is select data using LINQ with WCF? In simple terms "It enables to select the data using LINQ queries via WCF Service".     Step 1: Create [...]

Read more of this post

I guess you came to this post by searching similar kind of issues in any of the search engine and hope that this resolved your problem. If you find this tips useful, just drop a line below and share the link to others and who knows they might find it useful too. 

Stay tuned to my blogtwitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.


This article is related to
C#,.NET,Architect,Intermediate,VS2010,.Net,Articles,Computer Tutorials,LINQ,WCF

Monday, October 22, 2012

Upload a file using ASP.Net file upload control and WCF

I came across a question last week on how we can upload a file on to third party server using a WCF service, So thought of solving that through an example.

So In this example we will upload a pdf file using ASP.Net upload control and passing the details to the WCF and saving the file in the server.

Read More...

I guess you came to this post by searching similar kind of issues in any of the search engine and hope that this resolved your problem. If you find this tips useful, just drop a line below and share the link to others and who knows they might find it useful too.

Stay tuned to my blogtwitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.


This article is related to
C#,.NET,Architect,Intermediate,VS2010,.Net,Articles,Computer Tutorials,WCF,ASP.Net,File Upload Control

Tuesday, October 9, 2012

WCF 4.0 Discovery

In some business solutions it is required to have different type of service enabled devices which are constantly linking and sendoff to the network. That is, the runtime location of those services is dynamic and continuously shifting. To connect to those services, clients require determining the runtime location of those service endpoints dynamically.Windows Communication Foundation (WCF) offers support to enable those services to be discoverable at runtime using the WS-Discovery protocol. In this article I will describe the WCF 4.0 Discovery System.

Read More...

I guess you came to this post by searching similar kind of issues in any of the search engine and hope that this resolved your problem. If you find this tips useful, just drop a line below and share the link to others and who knows they might find it useful too.

Stay tuned to my blogtwitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.


This article is related to

C#,.NET,Intermediate,Advanced,VS2010,.Net,Articles,.Net Tutorials,C#,Mobile Development Tutorials,Mobile Developments,Window Phone Tutorials,WP7,WP8, WCF, WCF 4.0

Monday, October 1, 2012

WCF 4.5 New Feature Simplified Config File

WCF 4.5 New Feature Simplified Config File

WCF 4.5 New Feature Simplified Config File   Introduction Today, in this article let's play around with one of the interesting and most useful concept in WCF 4.5.   Question: What is simplified configuration? In simple terms "It enables the config file to reduce the complexity and maximizes the usage power. Adding service reference only generates [...]

Read more of this post

I guess you came to this post by searching similar kind of issues in any of the search engine and hope that this resolved your problem. If you find this tips useful, just drop a line below and share the link to others and who knows they might find it useful too.

Stay tuned to my blogtwitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.


This article is related to
C#,.NET,Architect,Intermediate,VS2010,.Net,Articles,Computer Tutorials, WCF, WCF 4.5, Configuration

WCF 4.5 New Feature Intellisense support for config file

WCF 4.5 New Feature Intellisense support for config file

WCF 4.5 New Feature Intellisense support for config file   Introduction Today, in this article let's play around with one of the interesting and most useful concept in WCF 4.5.   Question: What is intellisense support for configuration file? In simple terms "It provides easy and friendly way to access the code while working with config [...]

Read more of this post

I guess you came to this post by searching similar kind of issues in any of the search engine and hope that this resolved your problem. If you find this tips useful, just drop a line below and share the link to others and who knows they might find it useful too.

Stay tuned to my blogtwitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.


This article is related to
C#,.NET,Architect,Intermediate,VS2010,.Net,Articles,Computer Tutorials, WCF, WCF 4.5, Configuration, Intellisense

Saturday, September 22, 2012

WCF 4.5 features: Simplified Generated Configuration Files

In this post we will discuss one of the most important feature of WCF 4.5. WCF 4.5 generates simplified configuration file at the client side. WCF 4.5 generates configuration file for basicHttpBinding as following,


I guess you came to this post by searching similar kind of issues in any of the search engine and hope that this resolved your problem. If you find this tips useful, just drop a line below and share the link to others and who knows they might find it useful too.

Stay tuned to my blogtwitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.


This article is related to
C#,.NET,Architect,Intermediate,VS2010,.Net,Articles,Computer Tutorials, WCF, WCF 4.5

Monday, August 27, 2012

A N-Tier Architecture Sample with ASP.NET MVC3, WCF and Entity Framework

N-Tier software architecture can solve the following client/server system issues: scalability, security, fault tolerance and etc. In our previous article "N-Tier Architecture and Tips" we introduce the basic N-Tier architecture concepts and some practical tips. In this article, we try to elaborate a N-Tier architecture sample with ASP.NET MVC3, WCF and Entity Framework. In Java, usually there is a pre-defined way to achieve the N-Tier architecture: J2EE architecture, which uses session bean over entity bean for business and persistence layer, Java bean, servlet or JSP for the client presenter layer, Java Swing, HTML or applet as the client side. Therefore, for J2EE, different application are very likely implemented in very similar ways. However, in .NET, even though there are many tools and features available, there isn't any pre-defined way as J2EE does to guard how to implement the N-Tier architecture. As a result, there are too many inconsistent and existing ways to do this. Some are good; some are bad. This article tries to introduce a decoupled, unit-testable, deployment-flexible, implementation-efficient and validation-flexible N-Tier architecture in .NET. What we achieved here is to put some well-known nice tools and features in .NET together and come up with a workable solution. Because there is too much to cover in one article, we will mainly concentrate on business and persistence layers of N-Tier architecture in our sample solution, but will still briefly touch other layers too. In order to understand better this article, we suggest you to read first our previous article on the basics of N-Tier architecture here. As our previous article, this article is also based on the assumption that a team has a full control over all layers of the N-Tier architecture.

Read More....


I guess you came to this post by searching similar kind of issues in any of the search engine and hope that this resolved your problem. If you find this tips useful, just drop a line below and share the link to others and who knows they might find it useful too.

Stay tuned to my blogtwitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.


This article is related to

ASP.NET,Architect,Dev,ADO.NET,WCF,Design,Beginner,Intermediate,Advanced,C#,.NET,Architect

Thursday, June 28, 2012

Silverlight Application with MVVM WCF and EF

Introduction

In this article, we will see how to develop a simple Silverlight application with MVVM, WCF services, and Entity framework. In my earlier article, I described how to develop a simple Silverlight application in MVVM pattern (link to article). In this article, we will learn how to create a Silverlight application with WCF services also.

Steps
  • Add a new Silverlight project.
  • Create a project for Model as type Class Library.
  • Add a WCF service project.
  • Configure service.
  • Add service reference to Silverlight project.
  • Add cross domain policy.
  • Run and debug the application.

Read More....


I guess you came to this post by searching similar kind of issues in any of the search engine and hope that this resolved your problem. If you find this tips useful, just drop a line below and share the link to others and who knows they might find it useful too. 

Stay tuned to my blogtwitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.


WCF - Authentication and Authorization in Enterprise Architecting

In this article I am going to show how to use Authorization and Authentication using a WCF service in Enterprise Architecting standards. This article is about advanced WCF concepts. I am using an error driven approach for better experience with the problems and the solutions.

The core aspects we cover here are:
  • WCF
  • ASP.NET Authentication Service
  • Custom Authentication
  • HTTP Cookies
  • Authorization PrincipalPermission attribute
  • Thread CurrentPrincipal
  • Message Interceptors
You will be wondering what the above are. In a quick snap following are the activities involved.
  1. Create a WCF Service Application
  2. Add a AuthenticationService.svc reusing the ASP.NET Authentication Service
  3. Create a User Validator class
  4. Enable Custom Authentication in Global.asax
  5. Return Cookie if valid user
  6. Modify service configuration
  7. Try accessing the Authentication Service in the browser
  8. Create a UtilityService.svc with a method named GetData(int)
  9. Decorate GetData(int) with the PrincipalPermission attribute for Authorized Access only
  10. Decorate the UtilityService class with the AspNetCompatibilityRequirements attribute
  11. Set he Utility Service constructor to set CurrentPrincipal from the Cookie
  12. Create the client application and add references to both services
  13. Create the Authentication Service instance and invoke the Login() method
  14. Receive the cookie and store it
  15. Create the UtilityService instance and invoke GetData()
  16. Attach the Cookie to the UtilityService client
  17. Test the application and ensure proper functioning
  18. Move the cookie attaching code to Interceptors in the Client Application
  19. Move the identity setting code to Interceptors in the Service Application
  20. Modify the service side code to include Role instead of Name
  21. Use Encrypted Ticket for storing User Name and Roles
  22. Retest the application

I guess you came to this post by searching similar kind of issues in any of the search engine and hope that this resolved your problem. If you find this tips useful, just drop a line below and share the link to others and who knows they might find it useful too. 

Stay tuned to my blogtwitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.


Wednesday, June 27, 2012

How to consume WCF SOAP Service in C#/XAML based Metro Application

In this post we will consume WCF SOAP Service in C#/XAML based Metro Application. This is level 100 post showing basic steps to create simple WCF Service and consume that in Metro Application.

Very first let us create a WCF Service using VS2012. Form File menu create a new project by choosing WCF Service Application project template from WCF tab.

Read More...


I guess you came to this post by searching similar kind of issues in any of the search engine and hope that this resolved your problem. If you find this tips useful, just drop a line below and share the link to others and who knows they might find it useful too. 

Stay tuned to my blogtwitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.


Friday, December 17, 2010

How to connect to Oracle database using WCF in Silverlight

In this article we will be seeing how to connect to the Oracle database using WCF in Silverlight and will perform a search to retrieve the data from the database, display them in the Silverlight data grid using Visual Studio 2010.

In the Oracle database we will be having a table Employee Details with three columns Employee_ID, FirstName and LastName, having more than 10,000 data. Based on the Employee_ID we can search for the employees using this Silverlight search page.

Steps Involved:

Creating a Silverlight Application:

I. Open Visual Studio 2010.

ii. Go to File => New => Project.

iii. Select Silverlight from the Installed templates and choose the Silverlight Application template.

iv. Enter the Name and choose the location. 


WcfSil1.gif

v. Click OK.
vi. In the New Silverlight Application wizard check the "Host the Silverlight Application in a new Web site". 


WcfSil2.gif

vii. Click OK.

Adding WCF Service:

I. Right click on the asp.net website (in my case SilverlightApplicationSearchWebpartForOracle.web) which is automatically added to the Silverlight solution when we have created the Silverlight Application (If you check the Host the Silverlight application in a new Web site check box in the New Silverlight Application dialog box, an ASP.NET Web site is created and added to the Silverlight solution), select Add a new item. 


WcfSil3.gif

ii. Select Web from the Installed templates and choose the WCF Service.

iii. Enter the Name for the service. 
WcfSil4.gif

iv. Click OK.

v. Add the reference System.Data.OracleClient.

vi. Open IService1.cs.

vii. Replace the code with the following.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace SilverlightApplicationSearchWebpartForOracle.Web
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1"
in both code and config file together.
    [ServiceContract]
    public interface IService1
    {
        [OperationContract]
        List<Employee> getEmployees(string empId);
    }
    [DataContract]
    public class Employee
    {
        public int _employee_ID;
        public string _firstName;
        public string _lastName;

        [DataMember]
        public int Employee_ID
        {
            get { return _employee_ID; }
            set { _employee_ID = value; }
        }
 
        [DataMember]
        public string FirstName
        {
            get { return _firstName; }
            set { _firstName = value; }
        }
        [DataMember]
        public string LastName
        {
            get { return _lastName; }
            set { _lastName = value; }
        }
    }
 
}

viii. Open Service1.svc.cs.

ix. Replace the code with the following.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Data.OracleClient;
using System.Text;

namespace SilverlightApplicationSearchWebpartForOracle.Web
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.
    public class Service1 : IService1
    {
        public List<Employee> getEmployees(string empId)
        {

            List<Employee> employees = new List<Employee>();
            string connectionString = "Data Source=orcl;Persist Security Info=True;" +
                   "User ID=system;Password=password-1;Unicode=True";
            using (OracleConnection connection = new OracleConnection())
            {
                connection.ConnectionString = connectionString;
                connection.Open();
                OracleCommand command = connection.CreateCommand();
                string sql;
 
                if (!string.IsNullOrEmpty(empId))
                {
                    sql = "SELECT * FROM employeedetails where employee_id like '%" + empId + "%'";
 
                }
                else
                {
                    sql = "SELECT * FROM employeedetails";
                }

                command.CommandText = sql;
                OracleDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    Employee employee = new Employee();
                    employee.Employee_ID = Convert.ToInt32(reader["Employee_ID"]);
                    employee.FirstName = Convert.ToString(reader["FirstName"]);
                    employee.LastName = Convert.ToString(reader["LastName"]);
                    employees.Add(employee);
                }
                return employees.ToList();
            }
        }
    }
}


Adding clientaccesspolicy and crossdomain.xml files:

I. WCF service is going to be called from an outside domain, so we need to enable the cross domain policy in the WCF service by creating 'CrossDomain.xml' and 'ClientAccessPolicy.xml'. Below are both the code snippets. The first code snippet is for cross domain and the second for client access policy.

ii. Add the following two files to the SilverlightApplicationSearchWebpartForOracle.web.

iii. ClientAccessPolicy.xml

xml version="1.0" encoding="utf-8" ?>
       <access-policy>
         <cross-domain-access>
          <policy>
             <allow-from http-request-headers="*">
               <domain uri="*"/>
             allow-from>
             <grant-to>
               <resource include-subpaths="true" path="/"/>
             grant-to>
          policy>
         cross-domain-access>
       access-policy>

iv. CrossDomain.xml

xml version="1.0"?>
       DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
       <cross-domain-policy>
         <allow-http-request-headers-from domain="*" headers="*"/>
        cross-domain-policy>

Creating the UI for the Search Page:

v. Open MainPage.xaml file and replace the code with the below one.

<UserControl xmlns:my="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data" 
x:Class="SilverlightApplicationSearchWebpartForOracle.MainPage"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="500">

    <Grid x:Name="LayoutRoot"  Background="Beige" ShowGridLines="False">
        <Grid.RowDefinitions>
            <RowDefinition Height="25" />
            
            <RowDefinition Height="50"  />
            
            <RowDefinition Height="*" />
            
            <RowDefinition Height="10" />
            
        Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="20" />
            
            <ColumnDefinition Width="*" />
            
            <ColumnDefinition Width="20" />
            
        Grid.ColumnDefinitions>
        <Canvas Grid.Column="0"  Grid.Row="0" Background="White"/>
        <Canvas Grid.Column="2"  Grid.Row="0" Background="White" />
        <Canvas Grid.Column="1"  Grid.Row="0" Background="White">
            <Image Canvas.Left="10" Canvas.Top="5" Height="20" Width="20" 
Source="/SilverlightApplicationSearchWebpartForOracle;component/Images/peopletitle.png">Image>
            <TextBlock Canvas.Left="35" Canvas.Top="5" Text="Search for employee from Oracle Database">TextBlock>
        Canvas>

        <Canvas Grid.Row="1" Grid.Column="1" >
            <TextBlock Canvas.Left="7" Canvas.Top="20" Text="Find " Height="25" Width="30" FontWeight="Bold" Foreground="Black">TextBlock>
 
            <TextBox x:Name="EmpName" Width="250" Height="25" Canvas.Left="35" 
Canvas.Top="15" Margin="2,0,0,4"

VerticalAlignment="Bottom"/>
            <Button x:Name="Search" Height="25" Width="25" Canvas.Top="15" 
Canvas.Left="280" 
 Background="Transparent">

                <Image Source="/SilverlightApplicationSearchWebpartForOracle;component/Images/search32x32.png"  >Image>
            Button>
            <my:DataGrid x:Name="theDataGrid" AlternatingRowBackground="Beige" 
  Canvas.Left="7" Canvas.Top="50"
AutoGenerateColumns="True" Width="380" Height="300" Grid.Row="2"
Grid.Column="1" CanUserResizeColumns="True" />
            <my:DataPager  Canvas.Left="50" Canvas.Top="370" Source="{Binding  Path=ItemsSource, ElementName=theDataGrid}" PageSize="100"
 Margin="166,0,50,0">my:DataPager>
        Canvas>

    Grid>
UserControl>
<UserControl xmlns:my="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
  x:Class="SilverlightApplicationSearchWebpartForOracle.MainPage"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="500">

    <Grid x:Name="LayoutRoot"  Background="Beige" ShowGridLines="False">
        <Grid.RowDefinitions>
            <RowDefinition Height="25" />
            
            <RowDefinition Height="50"  />
            
            <RowDefinition Height="*" />
            
            <RowDefinition Height="10" />
            
        Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="20" />
            
            <ColumnDefinition Width="*" />
            
            <ColumnDefinition Width="20" />
            
        Grid.ColumnDefinitions>
        <Canvas Grid.Column="0"  Grid.Row="0" Background="White"/>
        <Canvas Grid.Column="2"  Grid.Row="0" Background="White" />
        <Canvas Grid.Column="1"  Grid.Row="0" Background="White">
            <Image Canvas.Left="10" Canvas.Top="5" Height="20" Width="20" 
Source="/SilverlightApplicationSearchWebpartForOracle;component/Images/peopletitle.png">Image>
            <TextBlock Canvas.Left="35" Canvas.Top="5" Text="Search for employee from Oracle Database">TextBlock>
        Canvas>

        <Canvas Grid.Row="1" Grid.Column="1" >
            <TextBlock Canvas.Left="7" Canvas.Top="20" Text="Find " Height="25" Width="30" FontWeight="Bold" Foreground="Black">TextBlock>
 
            <TextBox x:Name="EmpName" Width="250" Height="25" Canvas.Left="35" Canvas.Top="15" 
 Margin="2,0,0,4"

VerticalAlignment="Bottom"/>
            <Button x:Name="Search" Height="25" Width="25" Canvas.Top="15" Canvas.Left="280" 
 Background="Transparent">
 
                <Image Source="/SilverlightApplicationSearchWebpartForOracle;component/Images/search32x32.png"  >Image>

            Button>
            <my:DataGrid x:Name="theDataGrid" AlternatingRowBackground="Beige"  Canvas.Left="7" 
 Canvas.Top="50"
AutoGenerateColumns="True" Width="380" Height="300" Grid.Row="2"
Grid.Column="1" CanUserResizeColumns="True" />
            <my:DataPager  Canvas.Left="50" Canvas.Top="370" Source="{Binding  Path=ItemsSource, 
 ElementName=theDataGrid}" PageSize="100"Margin="166,0,50,0">my:DataPager>
        Canvas>

    Grid>
 
UserControl>

Adding Service Reference:

I. Right click on the Silverlight solution SilverlightApplicationSearchWebpartForOracle

and click Add Service Reference.

WcfSil5.gif

ii. Add Service Reference wizard will popup.

iii. Click on Discover.

iv. You will be able to see the service that we have created.

WcfSil6.gif

v. Select the service and click OK.

vi. Open MainPage.xaml.cs and replace the code with the below one.
using System;
 using System.Collections.Generic; 
using System.Linq;
 using System.Net; 
using System.Windows; 
using System.Windows.Controls; 
using System.Windows.Documents; 
using System.Windows.Input; 
using System.Windows.Media; 
using System.Windows.Media.Animation; 
using System.Windows.Shapes;
 using SilverlightApplicationSearchWebpartForOracle.ServiceReference1; 
using System.Windows.Data;
namespace SilverlightApplicationSearchWebpartForOracle
{
    public partial class MainPage : UserControl    {
        public MainPage()
        {
            InitializeComponent();
            Loaded += new RoutedEventHandler(MainPage_Loaded);
        }
        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            Search.Click += new RoutedEventHandler(Search_Click);
        }
        void Search_Click(object sender, RoutedEventArgs e)
        {
            ServiceReference1.Service1Client webservice = new SilverlightApplicationSearchWebpartForOracle.ServiceReference1.Service1Client();
            webservice.getEmployeesCompleted += new EventHandlergetEmployeesCompletedEventArgs>(webservice_getEmployeesCompleted);
            webservice.getEmployeesAsync(EmpName.Text);
        }

        void webservice_getEmployeesCompleted(object sender, ServiceReference1.getEmployeesCompletedEventArgs e)
        {
            PagedCollectionView pcv = new PagedCollectionView(e.Result);
            theDataGrid.ItemsSource = pcv;
        }
    }
}



Testing the solution:

I. Build the solution.

ii. Hit F5.

iii. Silverlight search page will be opened.
iv. Enter some number in the text box and click search, it will retrieve the values from the
Oracle database that contains the text that we have entered in the text box and display 
them in the grid.

WcfSil7.gif
Thus we have connected to the Oracle database using WCF service and performed 
a search on the Oracle data. The search results are displayed in the Silverlight data grid.
There was an error in this gadget
 
Get Twitter Fan Box Widget

Like Us On Facebook and Receive All Updates!

You can also receive Free Email Updates:

Powered By Tutorails

Followers