简体   繁体   English

WCF服务可在WCF客户端中使用,但不能在IIS中使用

[英]WCF service works in WCF Client but not in IIS

I have a WCF service that uses Microsoft.Synchronization.SyncAgent to synchronize a database on an Windows CE device. 我有一个WCF服务,该服务使用Microsoft.Synchronization.SyncAgent来同步Windows CE设备上的数据库。 It works great when I run the service from Visual Studio 2008 but when I host it in IIS (using Windows 10 by the way), the sync fails with a TargetInvocationException. 当我从Visual Studio 2008运行该服务时,它工作得很好,但是当我在IIS中托管它(顺便使用Windows 10)时,同步失败,并显示TargetInvocationException。 If I browse to the service with http://192.168.1.34:8711/InventoryCacheSyncService/InventoryServiceLibrary.InventoryCacheSyncService.svc I get the expected "You have created a service." 如果我使用http://192.168.1.34:8711/InventoryCacheSyncService/InventoryServiceLibrary.InventoryCacheSyncService.svc浏览到服务, http://192.168.1.34:8711/InventoryCacheSyncService/InventoryServiceLibrary.InventoryCacheSyncService.svc得到预期的“您已创建服务”。 page, but if I use http://192.168.1.34:8711/InventoryCacheSyncService/WTF which is the endpoint for the service just mentioned (as well as the url for the client web reference) I get a 404 error - although that url works fine when hosting it in Visual Studio's WCF Test Client. 页,但是如果我使用http://192.168.1.34:8711/InventoryCacheSyncService/WTF ,这是刚才提到的服务的端点(以及客户端Web参考的url),则会收到404错误-尽管该url有效在Visual Studio的WCF测试客户端中托管时很好。 I have tried just about every alteration I can think of to the url in the Win CE client but I'm getting nowhere. 我已经尝试过几乎可以想到的对Win CE客户端中url的所有更改,但是却无济于事。 I'm new to WCF services, so obviously I'm missing something incredible simple. 我是WCF服务的新手,因此显然我缺少了一些难以置信的简单操作。 Here's my web.config file: 这是我的web.config文件:

web.config web.config中

PLEASE help me out if have any ideas. 如果有什么想法请帮助我。 Thanks! 谢谢!

You can do below steps to host WCF in simple steps 您可以按照以下步骤执行以下步骤来托管WCF:

  1. Goto Properties of application in visual studio 转到Visual Studio中的应用程序的属性
  2. Click on Web tab 点击网页标签
  3. Select radio button "Use Local IIS Web server" 选择单选按钮“使用本地IIS Web服务器”
  4. Click on "Create Virtual directory" button 点击“创建虚拟目录”按钮

Virtual Directory will be created to your local system. 虚拟目录将创建到您的本地系统。

If want to host WCF in some other server, you can copy same folders to server and can create Virtual directory with same kind of physical path 如果要将WCF托管在其他服务器上,则可以将相同的文件夹复制到服务器,并可以使用相同的物理路径创建虚拟目录

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM