我正在創建這個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給沒有定義端點合同名單上沒有合同。
前面感謝您的幫助。
兩個端點不能具有相同的地址 –
每個綁定只能定義一個端點。 –
嘗試在兩個端點的「地址」屬性上使用不同的值 –