我遇到了几个可能相关或可能不相关的问题。我注意到,当我使用Visual Studio中的Add Service Reference添加对我的数据服务的引用时,它生成的reference.cs不能编译。它抱怨缺少名称空间。我可以修复它,但是每次更新引用时都会发生这种情况,而且它也担心其他级别,比如“这会导致其他问题”。无法正确引用wcf数据服务
我也注意到,当我这样做,我的主机服务器(托管的数据服务的控制台应用程序)记录此:
An exception occurred [System.Data.Services.DataServiceException] :: The URL
representing the root of the service only supports GET requests.
这是服务的配置:
<service behaviorConfiguration="behaviour" name="StatsPlus.Server.HostedServices.SPDataServiceHost">
<endpoint address="svc" binding="webHttpBinding" contract="System.Data.Services.IRequestHandler" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8752/DataService/"/>
</baseAddresses>
</host>
</service>
而行为:
<behavior name="behaviour">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<dataContractSerializer maxItemsInObjectGraph="10"/>
</behavior>
当我尝试运行svcutil http://localhost:8752/DataService/
,我得到这样的:
HTTP GET Error
URI: http://localhost:8752/DataService
There was an error downloading 'http://localhost:8752/DataService'.
The request failed with HTTP status 405: Method Not Allowed.
任何想法?非常感谢
谢谢
我已经添加了webhttp端点行为,但我没有看到任何区别。 另一件我不确定的事情是我在同一个进程中也有一个“正常的”WCF服务(使用[ServiceContract])。 我想知道这个“错误”实际上是否正确 - 添加服务引用似乎只是尝试一堆URI变体,直到一个工程,并且它生成的代码是一些编辑罚款。我要去尝试一些基本的测试,看看它是否真的有效:) – JohnL 2010-02-27 00:33:59