我有一个测试项目,WCF服务库,并且我发布了这个项目。拥有一台安装了所有正确安装程序的2003服务器。我浏览到我的应用程序,在单击.svc时,我得到了这个错误。
找不到在ServiceHost指令中作为服务属性值提供的类型'SearchService‘。
这是我的web.config中的代码片段
<endpoint address="" binding="wsHttpBinding" contract="TestService.ISearchService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>我的界面:
[ServiceContract]
public interface ISearchService
{
[OperationContract]
string GetName();
}我的实现:
[ServiceBehavior(InstanceContextMode=InstanceContextMode.PerSession)]
public class SearchService :ISearchService
{
#region ISearchService Members
public string GetName()
{
returnn "HAL-2001"
}
}发布于 2009-05-08 17:06:13
嗯,wsHttpBinding要求您使用SOAP连接到您的服务-单独的web浏览器不能处理它,所以这就是当您浏览到.svc文件时它无法工作的原因。这没什么问题,真的。
您需要创建一个真正成熟的SOAP客户端来连接到您的服务并对其进行测试。或者,您也可以使用位于VS2008\Common7\IDE文件夹中的WcfTestClient.exe测试客户端。
Marc
发布于 2009-05-12 18:10:51
ANo,则错误指示主机无法在您的web.config中找到服务实现"SearchService“的定义。在您的web.config中,您需要将标记包装在标记中。的名称属性应设置为SearchService类的全名(包括所有名称空间)。您还需要定义一个行为,使服务能够在浏览器中显示WSDL。在将服务部署到服务器时,您可能还希望删除。
下面是一个示例代码片段,请确保将SearchService的完整类名放入标记中,并确保.svc文件中包含完整的类名:
<system.serviceModel>
<services>
<service name="SearchService" behaviorConfiguration="ServiceBehavior">
<endpoint address="" binding="wsHttpBinding" contract="TestService.ISearchService">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="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> </system.serviceModel>发布于 2009-05-08 21:27:06
ANo,您应该切换到basicHttpBinding并进行测试,以确保一切正常。您使用的是WSHttpBinding,默认情况下,它打开了身份验证。您的客户端需要传递凭据才能真正获得响应,这就是浏览器调用不起作用的原因。
https://stackoverflow.com/questions/840608
复制相似问题