Imam jedan problem koji ne mogu da resim, a problem je jako jednostavan. Dakle, hocu da napravi WCF servis u WPF projektu. Sve ja uradim kako mislim da treba ali mi se uvek pojavi zero application endpoints greska.
Evo c# koda:
Code:
namespace Klient
{
[ServiceContract]
public interface IChat
{
[OperationContract]
string PrimiPoruku(string s);
}
public class Chat : IChat
{
string IChat.PrimiPoruku(string s)
{
return s;
}
}
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
private void btn_Click(object sender, RoutedEventArgs e)
{
try
{
ServiceHost host = new ServiceHost(typeof(Chat));
host.Open();
}
catch (Exception ex) { MessageBox.Show(ex.Message); }
}
}
}
namespace Klient
{
[ServiceContract]
public interface IChat
{
[OperationContract]
string PrimiPoruku(string s);
}
public class Chat : IChat
{
string IChat.PrimiPoruku(string s)
{
return s;
}
}
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
private void btn_Click(object sender, RoutedEventArgs e)
{
try
{
ServiceHost host = new ServiceHost(typeof(Chat));
host.Open();
}
catch (Exception ex) { MessageBox.Show(ex.Message); }
}
}
}
Evo i app.config koda:
Code:
<system.serviceModel>
<services>
<service name="Klient.Chat" behaviorConfiguration="aaa">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8000/Klient"/>
</baseAddresses>
</host>
<endpoint address=""
binding="basicHttpBinding"
contract="Klient.IChat"></endpoint>
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"></endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="aaa">
<serviceMetadata httpGetEnabled="True"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<system.serviceModel>
<services>
<service name="Klient.Chat" behaviorConfiguration="aaa">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8000/Klient"/>
</baseAddresses>
</host>
<endpoint address=""
binding="basicHttpBinding"
contract="Klient.IChat"></endpoint>
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"></endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="aaa">
<serviceMetadata httpGetEnabled="True"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Ako neko moze da pomogne bio bih mu veoma zahvalan.