[英]Deploy WCF service, C#, WCF, VS2008
我有一个测试项目WCF服务库,并且已发布该项目。 安装所有正确安装的2003服务器。 我浏览到我的应用程序,然后在单击.svc时出现此错误。
找不到类型“ SearchService”(在ServiceHost指令中作为服务属性值提供)。
这是我的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"
}
}
好吧,wsHttpBinding要求您使用SOAP连接到服务-单独的Web浏览器不会削减它,因此这就是为什么当您浏览到.svc文件时它不起作用的原因。 真的没错。
您需要创建一个真正的成熟的SOAP客户端以连接到您的服务并对其进行测试。 或者,您也可以使用WcfTestClient.exe
测试客户端,该客户端位于VS2008\\Common7\\IDE
文件夹中。
渣
不能,该错误表明主机在您的web.config中找不到服务实现“ SearchService”的定义。 在web.config中,您需要将<endpoint>标记包装在<service>标记中。 <service>的name属性应设置为SearchService类的全名(包括所有名称空间)。 您还需要定义一个行为以使服务能够在浏览器中显示WSDL。 在将服务部署到服务器时,您可能还想删除<dns value =“ localhost” />。
这是一个示例片段,请确保将SearchService的完整类名称放入<service>标记中,并且还应确保完整的类名称位于.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>
不能,您应该切换到basicHttpBinding并进行测试以确保一切正常。 您正在使用WSHttpBinding,并且默认情况下它已启用身份验证。 您的客户需要传递凭据才能真正获得响应,这就是浏览器调用无法正常工作的原因。
您的客户代码调用什么? 为此,它应该像下面这样调用代理类。
class SearchServiceProxy : ClientBase<ISearchService>, ISearchService
{
public string GetName()
{
return Channel.GetName();
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.