// These setting are exactly as the web.config in the IDataService. NetTcpBinding binding = new NetTcpBinding() ; binding.TransactionFlow = false; binding.PortSharingEnabled = true; binding.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.EncryptAndSign; binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows; binding.Security.Mode = SecurityMode.None; binding.ReceiveTimeout = TimeSpan.MaxValue; var endPointAddress = new EndpointAddress(new Uri("net.tcp://SOMESERVER:9000/OperationsDataService.DataService.svc"), new SpnEndpointIdentity("MYSERVICE/MyMachine")); var proxy = ChannelFactory<idataservice>.CreateChannel(binding, endPointAddress); // SpParameter is a [DataContract] class in the WCF interface service that has a few [DataMembers]. SpParameter[] spParams = new SpParameter[1]; spParams[0] = new SpParameter(); spParams[0].Paraname = @"@Commodity"; spParams[0].Paratype = @"char(1)"; spParams[0].Paravalue = @"'P'"; // The proxy method returns a [DataContract] called ReturnResults which is basically a DataSet. This DataSet gets added into the grid cntrol. dataGridViewReturn.DataSource = proxy.ExecuteStoredProcedure("PowerTrading_Dev_I", "", spParams, true); My web.config: <pre lang="HTML"> <system.serviceModel> <diagnostics> <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" /> </diagnostics> <bindings> <netTcpBinding> <binding name="netTcpBinding" maxBufferPoolSize="10000000" maxBufferSize="10000000" maxConnections="100" maxReceivedMessageSize="10000000" portSharingEnabled="true"> <readerQuotas maxDepth="255000" maxStringContentLength="255000" maxArrayLength="255000" maxBytesPerRead="255000" maxNameTableCharCount="255000" /> <security mode="None"> <message clientCredentialType="Windows" /> </security> </binding> </netTcpBinding> </bindings> <services> <service behaviorConfiguration="OperationsDataService.DataServiceBehavior" name="OperationsDataService.DataService"> <endpoint address="" behaviorConfiguration="ImpersonationBehavior" binding="netTcpBinding" bindingConfiguration="netTcpBinding" name="NetTcpEndpoint" contract="OperationsDataService.IDataService"> <identity> <servicePrincipalName value="MYSERVICE/MyMachine" /> <dns value="SOMESERVER" /> </identity> </endpoint> <endpoint address="net.tcp://SOMESERVER:9000/mex" binding="mexTcpBinding" bindingConfiguration="" name="MexTcpEndPoint" contract="System.ServiceModel.Description.IMetadataExchange" /> <host> <baseAddresses> <add baseAddress="net.tcp://SOMESERVER:9000/OperationsDataService.DataService.svc" /> </baseAddresses> </host> </service> </services> <behaviors> <endpointBehaviors> <behavior name="ImpersonationBehavior"> <clientCredentials> <windows allowedImpersonationLevel="Impersonation" /> <httpDigest impersonationLevel="Impersonation" /> </clientCredentials> <callbackDebug /> </behavior> </endpointBehaviors> <serviceBehaviors> <behavior name="OperationsDataService.DataServiceBehavior"> <serviceMetadata httpGetEnabled="false" /> <serviceDebug includeExceptionDetailInFaults="false" /> </behavior> </serviceBehaviors> </behaviors> </system.serviceModel>
<servicebehaviors> <behavior> <datacontractserializer maxitemsinobjectgraph="2147483647" /> .... </behavior> ... </servicebehaviors>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)