我正在创建这个WCF,但我遇到了我的WCF的ABC这个问题。WCF端点将不会注册
在我App.Config中我有以下几点:
<service name="WCFService.AuctionService">
<endpoint address="" binding="basicHttpBinding" contract="WCFService.IAuctionService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="" binding="basicHttpBinding" contract="WCFService.IArtPieceService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/Design_Time_Addresses/WCFService/AuctionService/"/>
<add baseAddress="http://localhost:8733/Design_Time_Addresses/WCFService/ArtPieceService/"/>
</baseAddresses>
</host>
</service>
</services>
以上是app.config文件的更新版本。
然后它不会运行。 它给我一个未定义的端点。 服务未在合同列表中找到。
以下是我的课:
public class AuctionService : IAuctionService {
private AuctionDb _ctr = new AuctionDb();
public void Add(Auction auction) {
String regName = "^[a - zA - Z0 - 9]{ 4,10}$";
if (Regex.IsMatch(auction.AuctionName, regName) || auction.AuctionName.Length > 1)
throw new ArgumentException();
if(auction.LotDuration.TotalSeconds > 0 || auction.LotDuration.TotalMinutes > 120 || auction.Lots.Count > 0)
throw new ArgumentException();
_ctr.Add(auction);
}
public void Update(Auction auction) {
String regName = "^[a - zA - Z0 - 9]{ 4,10}$";
if (Regex.IsMatch(auction.AuctionName, regName) || auction.AuctionName.Length > 1)
throw new ArgumentException();
if (auction.LotDuration.TotalSeconds > 0 || auction.LotDuration.TotalMinutes > 120 || auction.Lots.Count > 0)
throw new ArgumentException();
_ctr.Update(auction);
}
public List<Auction> GetAll() {
return _ctr.GetAll();
}
}
public class ArtPieceService : IArtPieceService
{
public void Add(ArtPiece piece)
{
throw new NotImplementedException();
}
}
以下是我的ServiceContracts:
[ServiceContract]
public interface IArtPieceService
{
[OperationContract]
void Add(ArtPiece piece);
}
而其他合同:
[ServiceContract]
public interface IAuctionService
{
[OperationContract]
void Add(Auction auction);
[OperationContract]
void Update(Auction auction);
[OperationContract]
List<Auction> GetAll();
}
我的ArtPieceService给没有定义端点合同名单上没有合同。
前面感谢您的帮助。
两个端点不能具有相同的地址 –
每个绑定只能定义一个端点。 –
尝试在两个端点的“地址”属性上使用不同的值 –