Điều này thực sự làm tôi thất vọng trong một vài giờ. Tôi tạo ra dịch vụ WCF đơn giản nhất bằng cách sử dụng một ràng buộc TCP.Ràng buộc TCP TCP: Tiền tố URI không được nhận dạng
namespace WcfTcpService
{
public class TestTcpService : ITestTcpService
{
public string Hello(string name)
{
return "Hello, " + name + "!";
}
}
}
namespace WcfTcpService
{
[ServiceContract]
public interface ITestTcpService
{
[OperationContract]
string Hello(string name);
}
}
file Web.config có phần sau:
<system.serviceModel>
<services>
<service name="WcfTcpService.TestTcpService" behaviorConfiguration="TestServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:808/WcfTcpService.TestTcpService" />
</baseAddresses>
</host>
<endpoint address="" binding="netTcpBinding" bindingConfiguration="tcpBinding" contract="WcfTcpService.ITestTcpService"></endpoint>
<endpoint address="mex" binding="mexTcpBinding" bindingConfiguration="" contract="IMetadataExchange"></endpoint>
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="tcpBinding" portSharingEnabled="true">
<security mode="None"></security>
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="TestServiceBehavior">
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<!--<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
<add binding="netTcpBinding" scheme="net.tcp" />
</protocolMapping>-->
<!--<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />-->
</system.serviceModel>
Dịch vụ này được lưu trữ trong IIS:
Bây giờ, khi cố gắng để thêm một tham chiếu đến net.tcp://localhost:808/WcfTcpService.TestTcpService
từ ứng dụng khách, tôi tiếp tục gặp lỗi:
The URI prefix is not recognized.
Metadata contains a reference that cannot be resolved: 'net.tcp://localhost/WcfTcpService.TestTcpService'.
The message could not be dispatched because the service at the endpoint address 'net.tcp://localhost/WcfTcpService.TestTcpService' is unavailable for the protocol of the address.
If the service is defined in the current solution, try building the solution and adding the service reference again.
Dịch vụ net.tcp đang chạy, tôi nhận được lỗi tương tự với WcfTestClient.exe. và tôi có thể chạy thành công http://localhost/WcfTcpService/TestTcpService.svc
.
Tôi đã tìm kiếm trên google nhưng không có gì xuất hiện.
Cảm ơn!
EDIT:
Màn hình ràng buộc của 'trang web mặc định' trông như thế này btw:
Bạn nhận được lỗi này khi bạn chọn "Add tài liệu tham khảo phục vụ"? Hãy thử địa chỉ http: //localhost/WcfTcpService/TestTcpService.svc trong hộp thoại này. – empi
Kiểm tra các ràng buộc trong IIS/IIS bày tỏ Xem câu hỏi này: http://stackoverflow.com/questions/3188618/enabling-net-tcp – nakchak
@empi Bạn đã có được đùa tôi ... đó công trinh. Nếu bạn đăng bài này như một giải pháp, tôi sẽ chấp nhận nó. Cảm ơn! – Nullius