i want to make a WCF application or [application] in c# for respond queries who i send through My HTML based application.
suppose i send a queries to url and they respond me for that by calling a TCP socet who already installed in the system of user.
can you tell me it's possible to call the开发者_高级运维m locally through HTML. are they allow them to call.
Are i can make a application in HTML , css , javascript who call the WCF and WCF respond the queries.
WCF is a communication frame work that supports all of the scenarios you mention. WCF is easily accessed from both web based technology and windows based. ]
EDIT
One File no config WCF service.
using System.ServiceModel;
using System.ServiceModel.Description;
using System.Runtime.Serialization;
using System;
[ServiceContract]
public interface AddStuff
{
[OperationContract]
int Add(int X,int Y);
}
public class opAddStuff : AddStuff
{
public int Add(int X, int Y)
{
return X + Y;
}
}
public class Pgm
{
static void Main(string[] args)
{
string httpAddr = "http://127.0.0.1:6001/AddStuff";
string netAddr= "net.tcp://127.0.0.1:5001/AddStuff";
System.ServiceModel.ServiceHost SH = new ServiceHost(typeof(opAddStuff),new Uri(httpAddr));
BasicHttpBinding B = new BasicHttpBinding();
NetTcpBinding NB = new NetTcpBinding();
SH.AddServiceEndpoint(typeof(AddStuff), B, httpAddr);
SH.AddServiceEndpoint(typeof(AddStuff), NB, netAddr);
System.ServiceModel.Description.ServiceMetadataBehavior smb = SH.Description.Behaviors.Find<ServiceMetadataBehavior>();
// If not, add one
if (smb == null)
smb = new ServiceMetadataBehavior();
smb.HttpGetEnabled = true;
smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
SH.Description.Behaviors.Add(smb);
SH.AddServiceEndpoint( ServiceMetadataBehavior.MexContractName, MetadataExchangeBindings.CreateMexHttpBinding(), "mex");
SH.Open();
Console.WriteLine("Service at your service");
string crap = Console.ReadLine();
}
}
This is a simple enough starting point http://www.codeproject.com/KB/WCF/GettingStartedWithWCF.aspx.
If you like to immediately get started with code, create a new project of type "WCF Service application" in Visual Studio. You'll then get the some skeleton service which you can run. Right-click, the Service.svc file --> Browse. The service "help" (a blue-themed) page will be displayed in internet exploere and voila you have a running wcf service.
The code for the service is in Service.svc.cs file and the contract implemented by the service is in the IService.cs file.
精彩评论