我正在使用网络服务而且出乎意料地突然失败并出现以下错误:
System.InvalidOperationException was caught
Message="No corresponding start element is open."
Source="mscorlib"
正确调用webservice并使用有效的xml返回正常响应(使用fiddler检查)。
我有一个hunge我在我生成的soap客户端的某个地方缺少一个数据元素但是不知道从哪里开始,因为我无法进入自动生成的soap客户端代码..
经过几个小时的浪费,我希望有人可以帮我解决如何开始排除故障的问题.. 有没有办法可以进入自动生成的soap客户端代码? 我可以采取任何其他方法来确定哪些是错的?
我正在开发VS2008 SP1。 自动生成的代码具有运行时版本:2.0.50727.3634
生成的代码位于类库中,并从控制台应用程序调用。 对于服务绑定,以下内容已从控制台应用程序添加到app.config中:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="OrderServiceSoap" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://www.acdc.com/services/order.asmx"
binding="basicHttpBinding" bindingConfiguration="OrderServiceSoap"
contract="MLOrderServiceReference.OrderServiceSoap" name="OrderServiceSoap" />
</client>
</system.serviceModel>
这是我错误的堆栈跟踪:
System.InvalidOperationException was caught
Message="No corresponding start element is open."
Source="mscorlib"
StackTrace:
Server stack trace:
at System.Xml.XmlBaseReader.ReadEndElement()
at System.ServiceModel.Channels.Message.ReadFromBodyContentsToEnd(XmlDictionaryReader reader, EnvelopeVersion envelopeVersion)
at System.ServiceModel.Channels.Message.ReadFromBodyContentsToEnd(XmlDictionaryReader reader)
at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeBodyContents(Message message, Object[] parameters, Boolean isRequest)
at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeReply(Message message, Object[] parameters)
at System.ServiceModel.Dispatcher.ProxyOperationRuntime.AfterReply(ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)\r\n\r\nException rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at DS.ACDC.AppService.MLOrderServiceReference.OrderServiceSoap.GetOrderDetail(Int32 ClientId, Int32 OrderId)
at DS.ACDC.AppService.MLOrderServiceReference.OrderServiceSoapClient.GetOrderDetail(Int32 ClientId, Int32 OrderId) in C:\\localdata\\ML\\ACDC\\DS.ACDC.AppService\\Service References\\MLOrderServiceReference\\Reference.cs:line 4151
at DS.ACDC.AppService.OrderService.getOrder(CISmapping CISdetails) in C:\\localdata\\ML\\ACDC\\DS.ACDC.AppService\\OrderService.cs:line 123
修改 它似乎与使用WCF服务引用而不是良好的旧Web引用有关。不知何故,当XmlSerializer工作时,DataContractSerializer会搞乱。
答案 0 :(得分:1)
好的,以防其他人遇到同样的问题我在这里回答我自己的问题..
“在何处/如何开始调试外部Web服务”这一问题的答案是将以下内容添加到配置文件中:
<system.diagnostics>
<switches>
<add name="XmlSerialization.Compilation" value="1" />
</switches>
</system.diagnostics>