2014-01-06 79 views
0

我已经基于ASP.Net网站创建了WFC RIA服务,并为RIA服务添加了nuget包。我还通过扩展DomainService类创建了一个名为“FactoryService”的服务。如何获取WCF RIA服务URL

我已经通过创建一个带有指向该服务的DomainDataSource的GridView来测试该服务。该服务正在工作。

现在我想从其他客户端访问服务,因为我启用了SOAP端点。但是我找不到服务的URL到svc文件。我需要此URL来将服务引用添加到我的其他项目。我如何找到服务网址?

我试过以下的URL和所有的返回值404(命名空间“WebApplication3”,DomainService类“FactoryService”)。

- http://localhost:15066/WebApplication3-FactoryService.svc 
- http://localhost:15066/services/WebApplication3-FactoryService.svc 
- http://localhost:15066/ClientBin/WebApplication3-FactoryService.svc 
- http://localhost:15066/FactoryService.svc 
- http://localhost:15066/services/FactoryService.svc 
- http://localhost:15066/ClientBin/FactoryService.svc 
+0

示例应用程序在http://sdrv.ms/1cSMl4P – Elangovan

+0

中可用在附加说明中,所有前三个都可以使用。域服务模块将服务以正确合格的服务类名称结尾的所有请求。任何中间路径片段都将被忽略。 – John

回答

1

我发现了这个问题。在DomainService类中,我错过了用[EnableClientAccess()]对其进行注释。

域服务类必须与 EnableClientAccessAttribute属性标记,以提供给 客户端项目的服务。当您在添加新域服务类对话框 框中选中启用 客户端访问复选框时,EnableClientAccessAttribute属性 自动应用于域服务。

当我使用VS2013时,向导不可用并且错过了使用该属性对其进行注释的问题。

0

通常有以下形式

基地址+的ClientBin +的DomainService的全名(命名空间+类型名由-分隔) 所以你的情况应该看起来像

http://localhost:15066/ClientBin/WebApplication3-FactoryService.svc 

当您在浏览器中访问此链接时,您将看到一个与此类似的页面

Service 

You have created a service. 

To test this service, you will need to create a client and use it to call the service. You can do this using the svcutil.exe tool from the command line with the following syntax: 


svcutil.exe http://localhost:15066/ClientBin/WebApplication3-FactoryService.svc?wsdl 
You can also access the service description as a single file: 

http://localhost:15066/ClientBin/WebApplication3-FactoryService.svc?singleWsdl 
This will generate a configuration file and a code file that contains the client class. Add the two files to your client application and use the generated client class to call the Service. For example: 

C# 

class Test 
{ 
    static void Main() 
    { 
     HelloClient client = new HelloClient(); 

     // Use the 'client' variable to call operations on the service. 

     // Always close the client. 
     client.Close(); 
    } 
} 

Visual Basic 

Class Test 
    Shared Sub Main() 
     Dim client As HelloClient = New HelloClient() 
     ' Use the 'client' variable to call operations on the service. 

     ' Always close the client. 
     client.Close() 
    End Sub 
End Class 
+0

当我打开您提到的网址时,会显示前面提到的“无法找到资源”错误消息。 – Elangovan

+0

@Elangovan您的网络服务器是否运行该应用程序的宿主? – Jehof

+0

是的,它正在运行。我已经创建了一个测试页面来测试使用GridView和DomainDataSource指向服务的服务。该服务正在工作..它也起作用。您可以在http://sdrv.ms/1cSMl4P中找到创建的测试应用程序 – Elangovan