I have a wcf service that works fine for one call. I have tried several different things and I just can't get it to accept more than one call from the client. This is my first wcf service so any help would be great. Below is my code.
for service1.svc.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.Data.SqlClient;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Net;
using System.Net.NetworkInformation;
using System.Threading;
using System.Globalization;
using System.Timers;
namespace aim_wcf_service
{
[ServiceBehavior(InstanceContextMode=InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Multiple)]
public class NIM_Latency : IService1
{
#region IService1 Members
public void submitData(Latency latency)
{
SqlConnection cs = new SqlConnection(@"Server=130-ASQL1-P-001.ocsd.LOCAL;Initial Catalog=AIM;User ID=user;Password=pass");
cs.Open();
SqlCommand insert = new SqlCommand(@"Insert into NIM_Latency (stationName, latency, stationIP) values ('" + latency.stationName + "', '" + latency.latency + "', '" + latency.stationip + "')", cs);
insert.CommandType = CommandType.Text;
insert.ExecuteNonQuery();
cs.Close();
}
public void updateData(Latency latency)
{
SqlConnection cs = new SqlConnection(@"Server=130-ASQL1-P-001.ocsd.LOCAL;Initial Catalog=AIM;User ID=user;Password=pass");
cs.Open();
SqlCommand update = new SqlCommand(@"Update NIM_Latency set latency = '" + latency.latency + "' where stationName = '" + System.Environment.MachineName + "'", cs);
update.CommandType = CommandType.Text;
update.ExecuteNonQuery();
cs.Close();
}
#endregion
}
}
then for IService1.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
namespace aim_wcf_service
{
[ServiceContract]
public interface IService1
{
[OperationContract]
void submitData(Latency latency);
[OperationContract]
void updateData(Latency latency);
}
[DataContract]
public class Latency
{
[DataMember]
public string stationName;
[DataMember]
public long latency;
[DataMember]
public string stationip;
}
}
and my web.config
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<customErrors mode ="Off">
</customErrors>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- 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>
<serviceHostingEnvironment multipleSiteBindingsEnabled="false" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
that was the web.config from the wcf service. Just to be safe here is the app.config from the client(windows service).
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:3909/NIM_Latency.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceReference1.IService1"
name="BasicHttpBinding_IService1" />
</client>
</system.serviceModel>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Reactive" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.1.11111.0" newVersion="1.1.11111.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Reactive.Windows.Threading" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.1.11111.0" newVersion="1.1.11111.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
after debugging further, it throws the following error when the client calls the service the second time.
Could not find endpoint element with name 'BasicHttpBinding_IService1' and contract 'ServiceReference1.IService1' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this name could be found in the client element.