Hallo,
Hab erst gerade mit dem WCF- Buch angefangen und wollte mal einen kleinen Chat, bzw. einfach eine Nachrichtenübermitlung probieren. Dafür hab ich folgende Klassen:
Jedenfalls kommt immer die Fehlermeldung:
Der Server hat die Aktualisierungsanforderung abgelehnt
Jetzt bin ich mir nicht sicher woran der Fehler liegt. Port 80 wurde auf Port Forwarding eingerichtet.
Jetzt hab ich nur keinen Plan wo der Fehler liegt, habe das Gefühl, dass es am Binding liegt, bin aber überfragt.
Wäre über Vermutungen froh, bzw. wenn jemand wüsste auf was die Fehlermeldung zurückzuführen ist.
Host:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
namespace WcfHost
{
class Host
{
static void Main(string[] args)
{
Console.Title = "Host Application";
using (ServiceHost host = new ServiceHost(typeof(WcfServiceLibrary.WcfService)))
{
host.AddServiceEndpoint(typeof(WcfServiceLibrary.IWcfService), new NetTcpBinding(), "net.tcp://localhost:80/WcfTest");
host.Open();
Console.ReadLine();
}
}
}
}
Client
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
namespace WcfClient
{
[ServiceContract(Namespace = "Andi")]
public interface IWcfService
{
[OperationContract]
string SayHello(string msg);
}
class Client
{
static void Main(string[] args)
{
Console.Title = "Client Application";
IWcfService proxy = ChannelFactory<IWcfService>.CreateChannel(new NetTcpBinding(), new EndpointAddress("net.tcp://84.227.126.134:80/WcfTest"));
while (true)
{
Console.WriteLine("Enter something and hit return: ");
string msg = Console.ReadLine();
string result = proxy.SayHello(msg);
Console.WriteLine("Server returned " + result);
}
}
}
}
WcfServiceLibrary
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace WcfServiceLibrary
{
public class WcfService : IWcfService
{
public string SayHello(string msg)
{
Console.WriteLine("Received Message: " + msg);
return String.Format("You entered: {0}, at {1} ", msg, DateTime.Now);
}
}
}
Schnittstelle
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
namespace WcfServiceLibrary
{
[ServiceContract(Namespace = "Name")]
public interface IWcfService
{
[OperationContract]
string SayHello(string msg);
}
}
Gruss Aratar
Bei netTcpBinding würde ich empfehlen, die Sicherheit auszuschalten, über ein entsprechend konfiguriertes Behavior:
<binding name="MyNetTcp" transactionFlow="true">
<security mode="None" />
</binding>