Tôi có dịch vụ lưu trữ IIS7 mà tôi cần để hiển thị cho hai khách hàng khác nhau. Đối với một trong những khách hàng tôi cần phải thực thi một hành vi Throttling nghiêm ngặt hơn khác.Thực hiện dịch vụ đơn lẻ của WCF, Nhiều hành vi. Có thể
Điều này có nghĩa là tôi cần phải xác định hai thẻ và vì chúng chỉ có thể được tham chiếu từ thẻ, sau đó tôi cần hai trong số này?
Tôi đã xác định web.config sau. Vấn đề là, khi tôi cố gắng duyệt đến một trong hai dịch vụ để tôi có thể lấy siêu dữ liệu, sau đó tôi nhận được lỗi sau:
Parser Error Message: A child element named 'service' with same key already exists at the same configuration scope.
Collection elements must be unique within the same configuration scope (e.g. the same application.config file). Duplicate key value: 'WCFTwoEndpoints.Calculate'.
Tôi có đi đúng không?
<system.serviceModel>
<services>
<service name="WCFTwoEndpoints.Calculate" behaviorConfiguration ="NotThrottled">
<endpoint address="http://localhost/WCFTwoEndpoints/Calculate.svc"
binding="wsHttpBinding" bindingConfiguration="" name="Calculator"
contract="WCFTwoEndpoints.ICalculate" />
<endpoint binding="mexHttpBinding" name="mex" contract="IMetadataExchange" />
</service>
<service name="WCFTwoEndpoints.Calculate" behaviorConfiguration ="Throttled">
<endpoint address="http://localhost/WCFTwoEndpoints/ThrottledCalculate.svc"
binding="wsHttpBinding" bindingConfiguration="" name="ThrottledCalculator"
contract="WCFTwoEndpoints.ICalculate" />
<endpoint binding="mexHttpBinding" name="mex" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="NotThrottled">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="Throttled">
<serviceMetadata httpGetEnabled="true" />
<serviceThrottling maxConcurrentCalls="19" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
Bạn có 2 tệp .svc khác nhau được gọi là Calculate.svc và ThrottledCalculate.svc – Rajesh
Có tôi có 2 tệp .svc khác nhau nhưng cả hai đều trỏ đến cùng .cs –
Tôi đoán có cùng tên lớp như mã phía sau là gây ra vấn đề khi WCF mong đợi các phần tử Service là duy nhất và bạn có 2 phần tử dịch vụ có cùng tên. Bạn có thể đẩy các chức năng vào một baseclass và sau đó kế thừa rằng trong các lớp khác nhau để tên dịch vụ của bạn trở thành duy nhất. – Rajesh