|
WCF- Service
CF binding is a set of binding elements and each element specify, how the service and client will communicates with each other's. Each binding must have at least one transport element and one message encoding element.
Different types of WCF bindings
WCF has a couple of built in bindings which are designed to fulfill some specific need. You can also define your own custom binding in WCF to fulfill your need. All built in bindings are defined in the System.ServiceModel Namespace. Here is the list of 10 built in bindings in WCF which we commonly used:
Basic binding
This binding is provided by the BasicHttpBinding class. It is designed to expose a WCF service as an ASMX web service, so that old clients (which are still using ASMX web service) can consume new service. By default, it uses Http protocol for transport and encodes the message in UTF - 8 text for-mat. You can also use Https with this binding.
Web binding
This binding is provided by the WebHttpBinding class. It is designed to expose WCF services as Http requests by using HTTP-GET, HTTP-POST. It is used with REST based services which may give output as an XML or JSON format. This is very much used with social networks for implementing a syndication feed.
Web Service (WS) binding
This binding is provided by the WSHttpBinding class. It is like as Basic binding and uses Http or Https protocols for transport. But this is designed to offer various WS - * specifications such as WS – Reliable Messaging, WS - Transactions, WS - Security and so on which are not supported by Basic binding.
wsHttpBinding= basicHttpBinding + WS-* specification
WS Dual binding
This binding is provided by the WsDualHttpBinding class. It is like as wsHttpBinding except it sup-ports bi-directional communication means both clients and services can send and receive messages.
TCP binding
This binding is provided by the NetTcpBinding class. It uses TCP protocol for communication be-tween two machines with in intranet (means same network). It encodes the message in binary format. This is faster and more reliable binding as compared to the Http protocol bindings. It is only used when communication is WCF - to – WCF means both client and service should have WCF.
IPC binding
This binding is provided by the NetNamedPipeBinding class. It uses named pipe for Communication between two services on the same machine. This is the most secure and fastest binding among all the bindings.
MSMQ binding
This binding is provided by the NetMsmqBinding class. It uses MSMQ for transport and offers sup-port to disconnected message queued. It provides solutions for disconnected scenarios in which service processes the message at a different time than the client send the messages.
Federated WS binding
This binding is provided by the WSFederationHttpBinding class. It is a specialized form of WS binding and provides support to federated security.
Peer Network binding
This binding is provided by the NetPeerTcpBinding class. It uses TCP protocol but uses peer net-working as transport. In this networking each machine (node) acts as a client and a server to the other nodes. This is used in the file sharing systems like torrent.
MSMQ Integration binding
This binding is provided by the MsmqIntegrationBinding class. This binding offers support to communicate with existing systems that communicate via MSMQ.
<pre lang="c#"><pre lang="c#"> Choosing an Appropriate WCF binding
. Depending upon your requirements, you can choose a binding for your service as shown below in the diagram:
Vasudev Choudhary
modified 10-Mar-14 14:56pm.
|
|
|
|
|
|
How to deal with the critical region in the programming language C #. Is there an example of this case or reference explaining that
|
|
|
|
|
|
|
The Thread class has a critical region method[^] that you could use.
There are other constructs like Mutex etc that could help you setup a critical region.
|
|
|
|
|
I'm trying to write a client for a webservice method, which responds with byte[]
I would like to stream it because byte[] will be failed if there is large file. I changed Transfer Mode and Encoding to Streamed and Mtom respectively. I commented XMLTypeAttribute declaration in reference file for the byte[] class. Please correct the code.
Reference.cs
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.4016")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
public partial class echoBinaryDataResponse : object, System.ComponentModel.INotifyPropertyChanged {
private byte[] paramField;
[System.Xml.Serialization.XmlElementAttribute(DataType = "base64Binary", Order = 0)]
public byte[] param
{
get {
return this.paramField;
}
set {
this.paramField = value;
this.RaisePropertyChanged("param");
}
}
My client call
-----------
ServiceReference1.echoBinaryData echo = new ServiceReference1.echoBinaryData();
MemoryStream str = new MemoryStream(myByteArray);
echo.param = str;
ServiceReference1.echoBinaryDataResponse echoResp = new ServiceReference1.echoBinaryDataResponse();
ServiceReference1.SamplePortTypeClient sample = new ServiceReference1.SamplePortTypeClient();
sample.echoBinaryData(echo);-----getting exception here
Note: myByteArray is of type byte[];
|
|
|
|
|
NarVish wrote: sample.echoBinaryData(echo);-----getting exception here
What exception?
Binding 100,000 items to a list box can be just silly regardless of what pattern you are following. Jeremy Likness
|
|
|
|
|
Sorry, forgot to add the exception
Exception:There was an error reflecting 'echoBinaryData'.
|
|
|
|
|
You need to trap this with your debugger or add some more code to identify the inner exception. "There was an error" tells us nothing.
Binding 100,000 items to a list box can be just silly regardless of what pattern you are following. Jeremy Likness
|
|
|
|
|
Irrespective of above exceptions, can u just guide me to stream byte array (which comes as response of webmethod)
|
|
|
|
|
Sorry, not something I have much experience of. Try the articles section or the MSDN documentation.
Binding 100,000 items to a list box can be just silly regardless of what pattern you are following. Jeremy Likness
|
|
|
|
|
|
Hello,
I was trying to connect to a machine(192.168.1.194); using powershell using the following query Enter-PSSession 192.168.1.194. But I got the following error.
Enter-PSSession : Connecting to remote server failed with the following error message : Access is denied. For more information, see the about_Remote_Troubleshooting Help topic.At line:1 char:16
+ Enter-PSSession <<<< 192.168.1.194
+ CategoryInfo : InvalidArgument: (192.168.1.194:String) [Enter-PSSession], PSRemotingTransportException
+ FullyQualifiedErrorId : CreateRemoteRunspaceFailed
Can you help me to solve this? Any help would be appreciated.
Thanks & Regards
Sebastian
|
|
|
|
|
1. This is nothing to do with C#.
2. You already asked here[^].
Binding 100,000 items to a list box can be just silly regardless of what pattern you are following. Jeremy Likness
|
|
|
|
|
hi all,
I have an image processing homework, object tracking. But how can I get video stream from usb cam buffer. Before writing disk. usb cam use YUV format I need just Y (gray level) how can I get? thnx.
|
|
|
|
|
Hi,
i use Visual C# express 2010 to develop my application.
I installed sql server 2008, I tried to generate the database from EDM and when I want to connect to sql server I can't find the provider of Microsoft Sql Server
|
|
|
|
|
MemberDotNetting wrote: provider of Microsoft Sql Server
Why not? Is SQL Server running? Can you connect using the management studio?
MemberDotNetting wrote: I installed sql server 2008
Did you configure it after you was done installing it?
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
|
|
|
|
|
yes i can connect from mangemenet studio and i configured it
|
|
|
|
|
Either your Visual Studio installation is corrupt or you might need to install vs2010 sp1
|
|
|
|
|
hi all, i use c# windows form application
& i want to change latitude & longitude in google api v3 JavaScript code
var myLatlng = new google.maps.LatLng(30.050144, 31.240042);
according to
C# form latitude text box & longitude text box entered value
I can display the page in webbrowser control but it's static
how can i do this???
thanks in advance
|
|
|
|
|
This is the third time you have asked this question but you have not explained which part does not work.
Binding 100,000 items to a list box can be just silly regardless of what pattern you are following. Jeremy Likness
|
|
|
|
|
var myLatlng = new google.maps.LatLng(30.050144, 31.240042);
this javascript code works but,
i want to replace the static values of latitude (30.050144) & longitude (31.240042)
in javascript code
with any value entered by user in latitude textbox
& longitude textbox
|
|
|
|
|
this code i use in html page
<%--!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
--%>
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map_canvas { height: 100% }
function initialize() {
var myOptions = {
center: new google.maps.LatLng(30.04866, 31.23688),
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
var myLatlng = new google.maps.LatLng(30.050144, 31.240042);
var myOptions = {
zoom: 20,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: "Hello World!"
});
}
&
this code i have used in c# form
StringBuilder queryAddress = new StringBuilder();
queryAddress.Append("file:///C:/Users/mrx1000/documents/visual studio 2010/Projects/testgoogleapi3/testgoogleapi/HTMLPage1.htm");
webBrowser1.Navigate(queryAddress.ToString());
this image for my form in running
http://www.mediafire.com/?rqckg28xb4rlahb
as you see i didn't enter anything in latitude text box or longitude text box
i find away but it's very difficult in this example & when i use it gives me errors
// webBrowser1.DocumentText =
//"" +
//"function test(message) { alert(message); }" +
//"" +
//"";
what i should i do now?
|
|
|
|
|
Your C# WinForm application with webbrowser control embedded in the form can use the following ways to achieve two-way communication between your C# code and the JavaScript code loaded by the webbrowser control.
From JavaScript to C#, follow these steps:
1. Create a member function in C#. In this example, suppose we have a function called "report_location":
public void report_location(double latitude, double longitude)
{
}
2. From your JavaScript code whenever you need to call the above C# function, do it like this:
window.external.report_location(...);
In the above function call the "... " represents the arguments you pass to the function. Use whatever arguments you need to use. For example if you are using Google Maps API and you add a listener to the map's click event, the function will be like this:
google.maps.event.addListener(
map,
'click',
function(event){
window.external.report_location(
event.latLng.lat(),
event.latLng.lng()
);
}
);
Your C# code will be able to get the clicked location's latitude/longitude.
From C# to JavaScript, follow these steps: (These will answer your specific question.)
1. In your JavaScript code create a function. In this example, suppose we have a function called "set_location":
function set_location(latitude, longitude){
var myLatlng = new google.maps.LatLng(latitude, longitude);
}
2. In your C# code whenever you need to call the above function to set the location, do it like this (suppose your webbrowser control is represented by the variable wb_map :
wb_map.Document.InvokeScript(
"set_location",
new string[]{
"30.050144",
"31.240042"
}
);
Of course if the numbers are stored in variables such as latitude , longitude , the above call will be
wb_map.Document.InvokeScript(
"set_location",
new string[]{
latitude.ToString(),
longitude.ToString()
}
);
Hope this answers your question. Happy programming!
|
|
|
|