积极答复者
WCF RIA 的引用方式

问题
-
我们有个一个团队已经开发好了基于WCF RIA+Silverlight的应用,一切OK
这里假设WCF的服务地址是
http://example.com/ClientBin/RIADomainService.svc
使用浏览器打开,会提示测试服务可以访问:
svcutil.exe http://example.com/Services/RIADomainService.svc?wsdl
现在我需要基于这个服务开发另一个silverlight客户端,但是在silverlight工程中添加服务引用的时候一直提示 404 错误(无论上面哪个链接地址),请问我应该如何引用这个服务呢?
谢谢!
答案
-
你好,
请问在浏览器可以打开http://example.com/Services/RIADomainService.svc?wsdl 么?如果可以的话,请尝试新建一个WinForms 项目并对其使用“Add Service Reference”将该URL输入,看是否可以成功添加服务引用。
关于WCF RIA Service的问题,你可以到这里提问以获取更好的回复。
Haixia
MSDN Community Support | Feedback to us
Develop and promote your apps in Windows Store
Please remember to mark the replies as answers if they help and unmark them if they provide no help.- 已编辑 Haixia_XieModerator 2013年6月19日 3:12 update
- 已标记为答案 Haixia_XieModerator 2013年7月1日 10:00
全部回复
-
你好,
请问在浏览器可以打开http://example.com/Services/RIADomainService.svc?wsdl 么?如果可以的话,请尝试新建一个WinForms 项目并对其使用“Add Service Reference”将该URL输入,看是否可以成功添加服务引用。
关于WCF RIA Service的问题,你可以到这里提问以获取更好的回复。
Haixia
MSDN Community Support | Feedback to us
Develop and promote your apps in Windows Store
Please remember to mark the replies as answers if they help and unmark them if they provide no help.- 已编辑 Haixia_XieModerator 2013年6月19日 3:12 update
- 已标记为答案 Haixia_XieModerator 2013年7月1日 10:00
-
你好,
svcutil.exe后面的地址是元数据的地址。
http://msdn.microsoft.com/en-us/library/aa751951.aspxHaixia
MSDN Community Support | Feedback to us
Develop and promote your apps in Windows Store
Please remember to mark the replies as answers if they help and unmark them if they provide no help. -
你好,
>>浏览器可以打开,内容和/ClientBin/一样
元数据类似于:
<?xml version="1.0" encoding="UTF-8"?> -<wsdl:definitions xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:tns="http://tempuri.org/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://tempuri.org/" name="Service1">-<wsp:Policy wsu:Id="wsHttp_policy">-<wsp:ExactlyOne>-<wsp:All><wsaw:UsingAddressing/></wsp:All></wsp:ExactlyOne></wsp:Policy>-<wsdl:types>-<xsd:schema targetNamespace="http://tempuri.org/Imports"><xsd:import namespace="http://tempuri.org/" schemaLocation="http://localhost:8732/Design_Time_Addresses/WcfServiceLibrary1/Service1/?xsd=xsd0"/><xsd:import namespace="http://schemas.microsoft.com/2003/10/Serialization/" schemaLocation="http://localhost:8732/Design_Time_Addresses/WcfServiceLibrary1/Service1/?xsd=xsd1"/><xsd:import namespace="http://schemas.datacontract.org/2004/07/WcfServiceLibrary1" schemaLocation="http://localhost:8732/Design_Time_Addresses/WcfServiceLibrary1/Service1/?xsd=xsd2"/></xsd:schema></wsdl:types> ...
尝试新建一个WinForms 项目并对其使用“Add Service Reference”将该URL输入,看是否可以成功添加服务引用。可以么?
Haixia
MSDN Community Support | Feedback to us
Develop and promote your apps in Windows Store
Please remember to mark the replies as answers if they help and unmark them if they provide no help. -
感谢您的回复
我新建了一个 WinForm 项目,添加服务引用,但还是一样的错误提示。我使用了下 svcutil 工具,查到这样的信息,是不是 WCF 服务没有写对呢?
SvcUtil.exe http://example.com/Services/RIADomainService.svc?wsdl Microsoft (R) Service Model Metadata Tool [Microsoft (R) Windows (R) Communication Foundation,版本 4.0.30319.17929] 版权所有(C) Microsoft Corporation。保留所有权利。 正在尝试使用 WS-Metadata Exchange 或 DISCO 从“http://example.com/Services/RIADomainService.svc?wsdl”下载元数据。 正在生成文件... 警告: 未生成任何代码。 如果尝试生成客户端,此问题可能是由于元数据文档中未包含任何有效的约定或服务所致, 或者由于发现所有约定/服务均存在于 /reference 程序集中所致。请验证是否已将所有元数据文档传递给工具。 警告: 如果要通过架构生成数据约定,请确保使用 /dataContractOnly 选项。
-
你好,
我不是很明白“浏览器可以打开,内容和/ClientBin/一样”的意思,请问正确显示了原数据么(类似于上一条回复中我贴的例子)?
如果原数据没有正确显示的话,使用svcutil 生成代理类也是会有错误的。
Haixia
MSDN Community Support | Feedback to us
Develop and promote your apps in Windows Store
Please remember to mark the replies as answers if they help and unmark them if they provide no help. -
Hello, Haixia
很抱歉回复晚了
“和/ClientBin/一样”,就是说,不管我用访问 /ClientBin/RIADomainService.svc 还是 /Services/RIADomainService.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://example.com/Services/RIADomainService.svc?wsdl
......
而看不到元信息的内容
- 已编辑 IronBloodNet 2013年6月27日 1:12 更新样式
-
你好,
根据你的描述,原数据没有被成功发布,参考我的第二条回复里的连接来发布原数据,既可以通过配置文件发布也可以通过代码方式发布。这里需要确保原数据成功发布了,然后利用原数据生成客户端代理类(无论是通过添加服务引用的方式或是使用SvcUtil.exe工具)。
这里有一个使用SvcUtil.exe生成客户端代理类的例子,供参考:http://social.msdn.microsoft.com/Forums/vstudio/en-US/bf82000a-6e2e-4e04-b024-809ff86f028e/wcf-proxy-generation-issue-from-vs2010-ide
我没有在WCF RIA 服务上试过,如果问题没有解决,建议你到这里(专门讨论WCF RIA问题)提问以获取更好的回复。谢谢谅解。
Haixia
MSDN Community Support | Feedback to us
Develop and promote your apps in Windows Store
Please remember to mark the replies as answers if they help and unmark them if they provide no help.