在我的客户端应用程序,我发现了以下错误:WCF - 客户端点配置错误
Could not find endpoint element with name 'QueuedService' and contract
'IMyService' in the ServiceModel client configuration section. This might
be because no configuration file was found for your application, or because no
endpoint element matching this name could be found in the client element.
我用svutil.exe生成我使用的客户端代理。通常我的手,推出自己的代理,然后我注意到了界面的服务合同所产生的版本没有命名空间中的我原来在服务合同中规定:
// Auto-generated proxy
namespace MyServices.Contracts
{
// Request object in correct namespace
[System.Runtime.Serialization.DataContractAttribute(
Name="MyRequest",
Namespace="http://schemas.datacontract.org/2004/07/MyServices.Contracts")]
public class MyRequest
{
// ...
}
}
// Service contract NOT in namespace
[System.ServiceModel.ServiceContractAttribute(
ConfigurationName="IMyService")]
public interface IMyService
{
// ...
}
我的主机应用程序的web.config指定服务端点(一个用于MSMQ和一个TCP):
<system.serviceModel>
<service>
<!-- etc... -->
<endpoint name="QueuedService"
address="net.msmq://localhost/private/MyQueue"
binding="netMsmqBinding"
bindingConfiguration="MsmqDefaultBinding_Local"
contract="MyService.Contracts.IMyService" />
<endpoint name="TcpService"
address="net.tcp://localhost/ServiceHost/TheService.svc"
contract="MyServices.Contracts.IMyService"
binding="netTcpBinding"
bindingConfiguration="netTcpWindowsBinding" />
</service>
</system.serviceModel>
客户端应用程序使用的服务是这样的:
var endpointConfigName = GetEndpointConfigNameFromConfig();
using(var myServiceClient = new MyServiceClient(endpointConfigName))
{
// Create Request object...
// Call service like so:
myServiceClient.SomeServiceMethod(requestObject);
}
和客户端的web.confi g:
<client>
<endpoint name="QueuedService"
address="net.msmq://localhost/private/MyQueue"
binding="netMsmqBinding"
bindingConfiguration="MsmqDefaultBinding_Local"
contract="MyServices.Contracts.IMyService" />
<endpoint name="TcpService"
address="net.tcp://localhost/ServiceHost/TheService.svc"
contract="MyServices.Contracts.IMyService"
binding="netTcpBinding"
bindingConfiguration="netTcpWindowsBinding" />
</client>
任何想法?
错误似乎与客户端配置文件。你确定客户端应用程序有一个与它关联的app.config吗? – 2012-01-11 06:58:56
TCP端点是否工作? – 2012-01-11 08:16:07
你能发布完整的客户端配置和服务接口吗? – Rajesh 2012-01-11 09:25:53