using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using System.ServiceModel; namespace WCFTemplateExample { [ServiceContract] interface WCFInterface { [OperationContract] DataSet GetData(); } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data.SqlClient; using System.Data; namespace WCFTemplateExample { public class WCFClass :WCFInterface { #region WCFInterface Members public System.Data.DataSet GetData() { SqlConnection con = new SqlConnection(@"Data Source=iicss20\PMIS;Initial Catalog=MSSLMS;Persist Security Info=True;User ID=nkhn3059;Password=nkhn3059"); SqlDataAdapter da = new SqlDataAdapter("select * from ss.lease",con); DataSet ds = new DataSet(); da.Fill(ds, "ss.lease"); return ds; } #endregion } }
<system.serviceModel> <services> <service name="WCFTemplateExample.WCFClass" behaviorConfiguration="WCFTemplateExample.WCFClassBehavior"> <host> <baseAddresses> <add baseAddress = "net.tcp://localhost:8731/Design_Time_Addresses/WCFTemplateExample/WCFClass/" /> </baseAddresses> </host> <endpoint address="net.tcp://localhost:8008/WCFClass" binding="netTcpBinding" contract="WCFTemplateExample.WCFInterface"></endpoint> <!-- Service Endpoints --> <!-- Unless fully qualified, address is relative to base address supplied above --> <!--<endpoint address ="" binding="Binding" contract="WCFTemplateExample.WCFInterface"> --><!-- Upon deployment, the following identity element should be removed or replaced to reflect the identity under which the deployed service runs. If removed, WCF will infer an appropriate identity automatically. --><!-- <identity> <dns value="localhost"/> </identity> </endpoint>--> <!-- Metadata Endpoints --> <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. --> <!-- This endpoint does not use a secure binding and should be secured or removed before deployment --> <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/> </service> </services> <behaviors> <serviceBehaviors> <behavior name="WCFTemplateExample.WCFClassBehavior"> <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> <serviceMetadata httpGetEnabled="false"/> <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> <serviceDebug includeExceptionDetailInFaults="False" /> </behavior> </serviceBehaviors> </behaviors> </system.serviceModel>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)