System.ArgumentException:空字符串“”不是有效的本地名称

时间:2018-12-28 11:40:32

标签: wcf soap mono xml-serialization

我正在使用已消耗的Web服务,并已在Visual Studio中自动生成代码。

服务就是这样的:https://www.onvif.org/onvif/ver10/events/wsdl/event-vs.wsdl

这部分代码可以正常运行,并且可以在Windows 10上正常运行,但是在Ubuntu中的Mono 5.18.0.225上运行相同的EXE时,会发生以下异常。

我可以成功连接到SOAP服务器(IP CCTV摄像机),并且许多命令都可以正常运行。但是,当我尝试订阅事件时,会收到错误消息:

Unhandled Exception:
System.InvalidOperationException: There was an error generating the XML document. ---> System.ArgumentException: The empty string '' is not a valid local name.

此函数的第三行似乎是发生错误的地方,但是我无法进一步调试并查看内部实际运行的代码是什么(因为我假设这是内部.NET代码)。

public Onvif.OnvifEventServiceReference.SubscribeResponse 
  Subscribe(Onvif.OnvifEventServiceReference.Subscribe Subscribe1) {
  Onvif.OnvifEventServiceReference.SubscribeRequest inValue = new  
  Onvif.OnvifEventServiceReference.SubscribeRequest();
  inValue.Subscribe = Subscribe1;
  Onvif.OnvifEventServiceReference.SubscribeResponse1 retVal = ((Onvif.OnvifEventServiceReference.NotificationProducer)(this)).Subscribe(inValue);
    return retVal.SubscribeResponse;
}

消息永远不会发送到网络,因为应用程序会在发生异常之前引发异常。

Unhandled Exception:
System.InvalidOperationException: There was an error generating the XML document. ---> System.ArgumentException: The empty string '' is not a valid local name.
  at System.Xml.XmlWellFormedWriter.WriteStartElement (System.String prefix, System.String localName, System.String ns) [0x00146] in <2388e378a5cd4e65bc514c9bf93520a5>:0 
  at System.Xml.XmlDictionaryWriter+XmlWrappedWriter.WriteStartElement (System.String prefix, System.String localName, System.String namespaceUri) [0x00000] in <41eb8dec95f040e1b682e5e0332b385c>:0 
  at System.Xml.Serialization.XmlSerializationWriter.WriteStartElement (System.String name, System.String ns, System.Object o, System.Boolean writePrefixed, System.Xml.Serialization.XmlSerializerNamespaces xmlns) [0x00163] in <2388e378a5cd4e65bc514c9bf93520a5>:0 
  at System.Xml.Serialization.XmlSerializationWriter.WriteStartElement (System.String name, System.String ns, System.Object o, System.Boolean writePrefixed) [0x00000] in <2388e378a5cd4e65bc514c9bf93520a5>:0 
  at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write9_Item (System.Object[] p) [0x00010] in <9ab12e2c4426454c93cd13f209eb743f>:0 
  at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer.Serialize (System.Object objectToSerialize, System.Xml.Serialization.XmlSerializationWriter writer) [0x00000] in <9ab12e2c4426454c93cd13f209eb743f>:0 
  at System.Xml.Serialization.XmlSerializer.Serialize (System.Xml.XmlWriter xmlWriter, System.Object o, System.Xml.Serialization.XmlSerializerNamespaces namespaces, System.String encodingStyle, System.String id) [0x0007d] in <2388e378a5cd4e65bc514c9bf93520a5>:0 
   --- End of inner exception stack trace ---
  at (wrapper managed-to-native) System.Object.__icall_wrapper_mono_remoting_wrapper(intptr,intptr)
  at (wrapper remoting-invoke) Onvif.OnvifEventServiceReference.NotificationProducer.Subscribe(Onvif.OnvifEventServiceReference.SubscribeRequest)
  at Onvif.OnvifEventServiceReference.NotificationProducerClient.Onvif.OnvifEventServiceReference.NotificationProducer.Subscribe (Onvif.OnvifEventServiceReference.SubscribeRequest request) [0x00007] in <53625273723a41699e0b65b8c3c620fe>:0 
  at Onvif.OnvifEventServiceReference.NotificationProducerClient.Subscribe (Onvif.OnvifEventServiceReference.Subscribe Subscribe1) [0x0000e] in <53625273723a41699e0b65b8c3c620fe>:0 
  at Onvif.OnvifEvents.Subscribe (System.String uri, System.Double deviceTimeOffset, System.String username, System.String password) [0x000a5] in <53625273723a41699e0b65b8c3c620fe>:0 
  at Onvif.MonitoringThread.Connect (System.String ip, System.Int32 port) [0x0027c] in <53625273723a41699e0b65b8c3c620fe>:0 
  at Onvif.Program.Main (System.String[] args) [0x0000c] in <53625273723a41699e0b65b8c3c620fe>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidOperationException: There was an error generating the XML document. ---> System.ArgumentException: The empty string '' is not a valid local name.
  at System.Xml.XmlWellFormedWriter.WriteStartElement (System.String prefix, System.String localName, System.String ns) [0x00146] in <2388e378a5cd4e65bc514c9bf93520a5>:0 
  at System.Xml.XmlDictionaryWriter+XmlWrappedWriter.WriteStartElement (System.String prefix, System.String localName, System.String namespaceUri) [0x00000] in <41eb8dec95f040e1b682e5e0332b385c>:0 
  at System.Xml.Serialization.XmlSerializationWriter.WriteStartElement (System.String name, System.String ns, System.Object o, System.Boolean writePrefixed, System.Xml.Serialization.XmlSerializerNamespaces xmlns) [0x00163] in <2388e378a5cd4e65bc514c9bf93520a5>:0 
  at System.Xml.Serialization.XmlSerializationWriter.WriteStartElement (System.String name, System.String ns, System.Object o, System.Boolean writePrefixed) [0x00000] in <2388e378a5cd4e65bc514c9bf93520a5>:0 
  at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write9_Item (System.Object[] p) [0x00010] in <9ab12e2c4426454c93cd13f209eb743f>:0 
  at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer.Serialize (System.Object objectToSerialize, System.Xml.Serialization.XmlSerializationWriter writer) [0x00000] in <9ab12e2c4426454c93cd13f209eb743f>:0 
  at System.Xml.Serialization.XmlSerializer.Serialize (System.Xml.XmlWriter xmlWriter, System.Object o, System.Xml.Serialization.XmlSerializerNamespaces namespaces, System.String encodingStyle, System.String id) [0x0007d] in <2388e378a5cd4e65bc514c9bf93520a5>:0 
   --- End of inner exception stack trace ---
  at (wrapper managed-to-native) System.Object.__icall_wrapper_mono_remoting_wrapper(intptr,intptr)
  at (wrapper remoting-invoke) Onvif.OnvifEventServiceReference.NotificationProducer.Subscribe(Onvif.OnvifEventServiceReference.SubscribeRequest)
  at Onvif.OnvifEventServiceReference.NotificationProducerClient.Onvif.OnvifEventServiceReference.NotificationProducer.Subscribe (Onvif.OnvifEventServiceReference.SubscribeRequest request) [0x00007] in <53625273723a41699e0b65b8c3c620fe>:0 
  at Onvif.OnvifEventServiceReference.NotificationProducerClient.Subscribe (Onvif.OnvifEventServiceReference.Subscribe Subscribe1) [0x0000e] in <53625273723a41699e0b65b8c3c620fe>:0 
  at Onvif.OnvifEvents.Subscribe (System.String uri, System.Double deviceTimeOffset, System.String username, System.String password) [0x000a5] in <53625273723a41699e0b65b8c3c620fe>:0 
  at Onvif.MonitoringThread.Connect (System.String ip, System.Int32 port) [0x0027c] in <53625273723a41699e0b65b8c3c620fe>:0 
  at Onvif.Program.Main (System.String[] args) [0x0000c] in <53625273723a41699e0b65b8c3c620fe>:0 

我正在寻找有关调试位置的建议-好像是Xml WriteStartElement函数引发错误-也许localname变量传递不正确。但是即使我逐步执行,也无法看到,因为这都是WCF的内部代码。

任何指针表示赞赏。

0 个答案:

没有答案