【发布时间】:2015-04-10 10:27:22
【问题描述】:
我有一个有效的网络服务和测试客户端,我可以截取它们之间的消息。但是当我添加要发送到我的事件中心的代码时,客户端显示错误:
An unhandled exception of type 'System.ServiceModel.FaultException`1' occurred in mscorlib.dll
Additional information: The argument Endpoints is null or empty.
Parameter name: Endpoints
更详细的异常:
System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail]: The argument Endpoints is null or empty.
Parameter name: Endpoints (Fault Detail is equal to An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
System.ArgumentException: The argument Endpoints is null or empty.
Parameter name: Endpoints
at Microsoft.ServiceBus.ServiceBusConnectionStringBuilder.Validate()
at Microsoft.ServiceBus.ServiceBusConnectionStringBuilder.ToString()
at Microsoft.ServiceBus.Messaging.Configuration.KeyValueConfigurationManager.
Initialize(String connection, Nullable`1 transportType)
at Microsoft.ServiceBus.Messaging.Configuration.KeyValueConfigurationManager.
.ctor(Nullable`1 transportType)
at Microsoft.ServiceBus.Messaging.EventHubClient.Create(String path)
at WCFInterceptor.MessageInspector.AfterReceiveRequest(Message& request, ICli
entChannel channel, InstanceContext instanceContext)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.AfterReceiveReques
tCore(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(Me
ssageRpc& rpc)
at System.ServiceModel.Dispatc...).
这是我添加的代码:
try
{
NamespaceManager namespaceManager = NamespaceManager.CreateFromConnectionString(GetServiceBusConnectionString());
Manage.CreateEventHub(hubName, 16, namespaceManager);
}
catch (Exception e)
{
Console.WriteLine("SetupEHError" + e);
}
EventHubClient client = EventHubClient.Create(hubName);
Console.WriteLine("eventhubclient iniciado");
EventData messageData = new EventData(Encoding.UTF8.GetBytes(serializedString));
try
{
client.Send(messageData);
Console.WriteLine("MessageData enviada");
}
catch (Exception e)
{
Console.WriteLine("ErrorMessage:" + e);
}
这里是 CreateEventHub 方法:
public static void CreateEventHub(string eventHubName, int numberOfPartitions, NamespaceManager manager)
{
try
{
// Create the Event Hub
Console.WriteLine("Creating Event Hub...");
EventHubDescription ehd = new EventHubDescription(eventHubName);
ehd.PartitionCount = numberOfPartitions;
manager.CreateEventHubIfNotExistsAsync(ehd).Wait();
Console.WriteLine("Created");
}
catch (AggregateException agexp)
{
Console.WriteLine(agexp.Flatten());
}
}
WebService 控制台应用最多可打印
Creating Event Hub
Created
所以我想我可能需要为 WebService 中的 MessageInspector 添加端点,以便能够将数据发送到服务总线事件中心。如果有,配置如何?
提前致谢
【问题讨论】:
-
您使用的是服务总线还是事件中心的密钥,您是否为事件中心添加了管理权限??
-
这是我的事件中心的管理权限是的
-
我遇到了同样的问题,但我发现我使用的是服务中心的密钥而不是我的事件中心,我放下了 SDK 并使用 The Rest API 实现了我自己的简单事件中心创建功能它奏效了
-
如果您取消了 sdk 并使用 http 帖子将您的事件发送到集线器,您是如何处理 SAS 关键问题的?因为它有一个 TIL
-
如果在我的情况下可以这样做(让检查员发送消息),我更喜欢使用 sdk。另外,您确定不需要端点,因为“端点参数为空或无效”?如果这有任何意义
标签: web-services wcf endpoints idispatchmessageinspector azure-eventhub