Showing posts with label WCF. Show all posts
Showing posts with label WCF. Show all posts

Monday, May 18, 2009

calling WCF Service method from javascript

here am speaking about the how wcf service method will call in the clientside using javascript. please find the below examples.

Before starting the code please select the template called Ajax enabled wcf service.

then call the method in the javascript.


ASPX with javascript.

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
<script language="javascript" type="text/javascript">
function getValue()
{
AjaxWCF.DoWork(onSucess,onFailure)
}
function onSucess(result)
{
alert(result);
}
function onFailure(result)
{
alert(result);
}
</script>
</head>
<body onload="getValue();">
<form id="form1" runat="server">
<asp:ScriptManager ID="script" runat="server">
<Services>
<asp:ServiceReference Path="~/AjaxWCF.svc" />
</Services>
</asp:ScriptManager>
</form>
</body>
</html>

AjaxWCF.svc File


using System;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;

namespace Xmlhttp
{
[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class AjaxWCF
{
// Add [WebGet] attribute to use HTTP GET
[OperationContract]
public string DoWork()
{
// Add your operation implementation here
return "Hi bala";
}
// Add more operations here and mark them with [OperationContract]
}
}

Tuesday, June 3, 2008

Windows Communication Foundation (WCF) features

Security Features
• Facilitates interoperability through WS-* standards
• WS-Trust. Uses the secure messaging mechanisms of WS-Security
• WS-SecureConversation
• WS-Federation
• WS-SecurityPolicy
• Confidentiality – keeping messages private
• Authentication – verifying claimed identity
• Uses transport-level protocol (like HTTPS); only point-to-point secure
• Uses WS-Security; less efficient but secure from end to end
• SOAP Message Security (OASIS)

Reliable Messaging

• Provides for SOAP messages what TCP provides for IP packets
• Ensures messages are exactly once
• Handles lost messages and duplicates
• End-to-end reliability (vs. transport reliability of TCP)

Queues

• Leverages Microsoft Message Queuing (MSMQ) as a transport
• Enables loosely coupled applications and disconnected operations

Transactions

• Takes advantage of System.Transactions in .NET 2.0
• Supports WS-AtomicTransaction

Compatibility

COM+

• Extend COM+ components as Web services
• Service derived from COM+ interface

COM

• Moniker support (GetObject) for usage of WCF services from COM-based applications

Debugging the wcf Service in client side

In web.config/App.config of WCF Service have to do two changes,The details are described below

step1:
<compilation debug=true>

step2:
<servicedebug includeExceptionDetailInfaults="true"/>

Thursday, May 29, 2008

Syndication on WCF

In dotnet 3.5 has added several new things. one of those syndication. The System.ServiceModel.web has several class that you can use to expose the ATOM and RSS feed.

Monday, March 17, 2008

Windows Communication Foundation

WCF-Windows Communication Foundation


WCF is nothing but a Distributed system. Combination of Object Oriented Architechtre and Service Oriented Architecture.


NET 3.0 comes with three main technologies in core: Windows Presentation Foundation, Windows Workflow Foundation and Windows Communication Foundation.
Windows Communication Foundation (WCF), codenamed Indigo in Microsoft, is the last generation of service oriented technologies for development. It provides all the latest means to help developers build service oriented applications. The result of service oriented design is a distributed system which runs between services and clients. Windows Communication Foundation is Microsoft infrastructure for Service Oriented architecture

Advantages

Windows Communication Foundation has some important enhancements in comparison with preceding technologies·
. It merges all older separate technologies in one place and allows you to do things easier.
· It has rich communication capabilities.
· It comes with many powerful and ready to use enterprise features.
· It can be integrated with other technologies and has great interoperability.

Fundamental Concepts

Windows Communication Foundation consists of three main concepts.
· Services: Programs that respond to clients. They can send or receive messages.
· Clients: Programs that ask for a service. They can send or receive messages.
· Intermediaries: Programs that sit between services and clients (Figure 2). They can work as a firewall or can rout messages. In all cases neither services nor clients need to be aware of intermediaries.

Architecture
Architecture of Windows Communication Foundation consists of five layers. These layers from top to down are:
· Application: In this level application is located.
· Contracts: In the second layer service, data and message contracts as well as bindings and policies are present. In this level services describe themselves to clients.
· Runtime: Behaviors are located in this layer. Runtime layer loads all services.
· Messaging: Different types of channels as well as encoders are here. This layer enables communications for services.
· Hosting: This layer is where host services in different manners, but there are two common ways to host a service. You can host a service in Internet Information Services (IIS) which is easier than the second approach and starts and stops your services automatically. The second approach is to create executable files (.EXE) for services and start and stop them manually by writing more codes.

Programming Model

Windows Communication Foundation has simple and easy to write/understand codes. It has many APIs, but beside this only a small amount of these API's is common.
There are three programming approaches in Windows Communication Foundation:
· Imperative: You use programming codes in different languages to accomplish a task.
· Configuration Based: You use configuration files to do things.
· Declarative: You use attributes to declare something.

On the other hand, you can use typed services and untyped services. In typed services you pass normal objects and data types and/or get normal objects and data types, but in untyped services you pass and get messages to work directly with messages at a lower level..

Installation
Installation of Windows Communication Foundation and its development tool is easy and consists of these steps:
· Download and install .NET Framework 3.0 RTM. I also strongly recommend you to download and install WinFX SDK as well. After this step you have all necessary API's to run Windows Communication Foundation.
· Download and install Visual Studio 2005xtensions for .NET Framework 3.0 WCF and WPF). After installing this package, you will have new project templates in your Visual Studio to start developing for Windows Communication Foundation