WCF, . WCF , , , Windows.
, :
[ServiceContract]
public interface ITestService {
[OperationContract]
[WebGet(
BodyStyle = WebMessageBodyStyle.Bare,
ResponseFormat = WebMessageFormat.Xml
)]
XElement DoWork(string myId);
}
:
public class TestService : ITestService {
public XElement DoWork(string myId) {
return new XElement("results", new XAttribute("myId", myId ?? ""));
}
}
config (web.config app.config) :
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="WebBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="WebApplication1.TestService">
<endpoint behaviorConfiguration="WebBehavior"
binding="webHttpBinding"
contract="WebApplication1.ITestService">
</endpoint>
</service>
</services>
</system.serviceModel>
ASP.NET, TestService.svc :
<%@ ServiceHost Language="C#" Debug="true"
Service="WebApplication1.TestService"
CodeBehind="TestService.svc.cs" %>