我有一个工作的网络服务和测试客户端,我可以拦截它们之间的消息。但是当我添加要发送到我的事件中心的代码时,客户端显示错误:
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 添加端点,以便能够将数据发送到服务总线事件中心。如果是这样,配置如何?
提前致谢