i m getting an error
The contract name 'IMetadataExchange' could not be found in the list of contracts implemented by the service Service1. Add a ServiceMetadataBehavior to the configuration file or to the ServiceHost directly to enable support for this contract.
here is the chunk of code
Java
xmlversion="1.0"?>
configuration>
configSections>
sectionGroupname="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
sectionGroupname="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
sectionname="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
sectionGroupname="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
sectionname="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" />
sectionname="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
sectionname="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
sectionname="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
sectionGroup>
sectionGroup>
sectionGroup>
configSections>
appSettings/>
connectionStrings>
addname="VotingConnectionString" connectionString="Data Source=IRAM-PC;Initial Catalog=Voting;Integrated Security=True"
providerName="System.Data.SqlClient" />
connectionStrings>
system.web>
Set compilationdebug="true" to insert debugging symbols into the compiled page. Because this affects performance, set this value to true only during development. -->
compilationdebug="false">
assemblies>
addassembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
addassembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
addassembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
addassembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
assemblies>
compilation>
The section enables configuration of the security authentication mode used by ASP.NET to identify an incoming user. -->
authenticationmode="Windows" />
The section enables configuration of what to doif/when an unhandled error occurs during the execution of a request. Specifically, it enables developers to configure html error pages to be displayed in place of a error stack trace. -->
pages>
controls>
addtagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
addtagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
controls>
pages>
httpHandlers>
removeverb="*" path="*.asmx"/>
addverb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
addverb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
addverb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
httpHandlers>
httpModules>
addname="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
httpModules>
system.web>
system.codedom>
compilers>
compilerlanguage="c#;cs;csharp" extension=".cs" warningLevel="4"
type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
providerOptionname="CompilerVersion" value="v3.5"/>
providerOptionname="WarnAsError" value="false"/>
compiler>
compilers>
system.codedom>
The system.webServer section is required for running ASP.NET AJAX under Internet Information Services 7.0. It is not necessary for previous version of IIS. -->
system.webServer>
validationvalidateIntegratedModeConfiguration="false"/>
modules>
removename="ScriptModule" />
addname="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
modules>
handlers>
removename="WebServiceHandlerFactory-Integrated"/>
removename="ScriptHandlerFactory" />
removename="ScriptHandlerFactoryAppServices" />
removename="ScriptResource" />
addname="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode"
type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
addname="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode"
type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
addname="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
handlers>
system.webServer>
runtime>
assemblyBindingxmlns="urn:schemas-microsoft-com:asm.v1">
dependentAssembly>
assemblyIdentityname="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
bindingRedirectoldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
dependentAssembly>
dependentAssembly>
assemblyIdentityname="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>
bindingRedirectoldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
dependentAssembly>
assemblyBinding>
runtime>
system.serviceModel>
bindings>
customBinding>
bindingname="customBinding0">
binaryMessageEncoding />
httpTransport>
extendedProtectionPolicypolicyEnforcement="Never" />
httpTransport>
binding>
customBinding>
bindings>
behaviors>
endpointBehaviors>
behaviorname="VotingPanel2.Web.Service1AspNetAjaxBehavior">
enableWebScript />
behavior>
endpointBehaviors>
serviceBehaviors>
behaviorname="VotingPanel2.Web.Service2Behavior">
serviceMetadatahttpGetEnabled="true" />
serviceDebugincludeExceptionDetailInFaults="false" />
behavior>
serviceBehaviors>
behaviors>
serviceHostingEnvironmentaspNetCompatibilityEnabled="true" />
services>
servicename="VotingPanel2.Web.Service1">
endpointaddress="" behaviorConfiguration="VotingPanel2.Web.Service1AspNetAjaxBehavior"
binding="webHttpBinding" contract="VotingPanel2.Web.Iservice1" />
endpointaddress="mex" binding="mexHttpBinding" bindingConfiguration=""
contract="IMetadataExchange" />
service>
services>
system.serviceModel>
configuration>
C#
using System.Data;
using System.Data.SqlClient;
using System;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.Collections.Generic;
using System.Text;
namespaceVotingPanel2.Web
{
[ServiceContract]
publicinterfaceIservice1
{
[OperationContract]
ListVote> GetChartData();
[OperationContract]
voidInsertdata(String vote, DateTime dt);
[OperationContract]
voidGetData();
}
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
publicclassService1 : Iservice1
{
SqlConnection Conn;
SqlCommand Cmd;
# region Iservice1 members//[OperationContract] public ListVote> GetChartData()
{
DataClasses1DataContext db = new DataClasses1DataContext();
var query = from c in db.Votes select c;
return query.Take(10).ToList();
}
# endregionpublicvoidInsertdata(String vote, DateTime dt)
{
Conn = new SqlConnection("Data Source=IRAM-PC;Initial Catalog=Voting;User-Id=sa;Password=sa;Integrated Security=SSPI");
Cmd = new SqlCommand();
Conn.Open();
Cmd.Connection = Conn;
Cmd.CommandText = "insert into votes values ('" + vote + "', '" + dt + "' )";
int ins = Cmd.ExecuteNonQuery();
//if (ins > 0) //{ // Inserted = true; //}
Conn.Close();
}
publicvoidGetData()
{
bool Inserted = false;
Conn = new SqlConnection("Data Source=IRAM-PC;Initial Catalog=Voting;User-id=sa;Password=sa;Integrated Security=SSPI");
Cmd = new SqlCommand();
Conn.Open();
Cmd.Connection = Conn;
Cmd.CommandText = "SELECT votingtext, COUNT(Votingtext) AS count FROM votes group by Votingtext";
int ins = Cmd.ExecuteNonQuery();
if (ins > 0)
{
Inserted = true;
}
Conn.Close();
//return Inserted;
}
}
}
Code
Answers
Know the answer? Post it. Somebody with the same question will find it here.
Answers
Know the answer? Post it. Somebody with the same question will find it here.