2010-01-05 120 views
0

当访问一个CGI Web服务,它引发错误[有XML文档中的错误(] 此错误只发生如果返回paramater是对象的数组访问web服务,抛出错误

如何解决这个问题?

------------ execption details --------------- System.InvalidOperationException is unhandled Message =“There is在XML文档(1,452)中出错。“ Source =”System.Xml“ StackTrace: at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader,S tring encodingStyle,XmlDeserializationEvents events) at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader,String encodingStyle) at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message,WebResponse response,Stream responseStream,Boolean asyncCall) at:System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName,Object [] parameters) at D:\ Samjog \ Temp Project \ ProxyTest \ ProxyTest \ MyWebService.CallMyMethod(String hostName,String YourAppMyApptoken,Int32 subscription_id) MyWebService.cs:line 93 at D:\ Samjog \ Temp Project \ ProxyTest \ ProxyTest \ Form1.cs中的ProxyTest.Form1.btnListFeeds_Click(对象发件人,EventArgs e):第209行 at System.Windows.Forms.Control.OnClick (EventArgs e) 在Syst em.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at System.Windows.Forms.Control.WmMouseUp(Message & m,MouseButtons button,Int32 clicks) 在System.Windows.Forms.Control.WndProc(消息&米) 在System.Windows.Forms.ButtonBase.WndProc(消息&米) 在System.Windows.Forms.Button.WndProc(消息&米) 在System.Windows.Forms.Control.ControlNativeWindow.OnMessage(消息&米) 在System.Windows.Forms.Control.ControlNativeWindow.WndProc(消息&米) 在System.Windows.Forms.NativeWindow.Debug gableCallback(IntPtr的的HWND,MSG的Int32,IntPtr的WPARAM,IntPtr的LPARAM) 在System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG & MSG) 在System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods。 IM3ComponentManager.FPushMessageLoop(Int32 dwComponentID,Int32 reason,Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason,ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext上下文) at System.Windows.Forms.Application.Run(Form mainForm) at ProxyTest.Program.Main()in D:\ Samjog \ Temp Project \ ProxyTest \ ProxyTest \ Program.cs:line 18 at System。 AppDomain._nExecuteAssembly(大会组件,字串[] args) 在System.AppDomain.ExecuteAssembly(字符串assemblyFile,证据assemblySecurity,字串[] args) 在Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() 在System.Threading.ThreadHelper.ThreadStart_Context(对象状态) 在System.Threading.ExecutionContext.Run(的ExecutionContext的ExecutionContext,ContextCallback回调,对象状态) 在System.Threading.ThreadHelper.ThreadStart() 的InnerException:System.InvalidCastException 消息=“无法分配类型System.Int32的对象到MyAppWSDLSubscribedFeedInfo类型的对象。“ Source =”dz-gayew“ StackTrace: at Microsoft.Xml.Serialization.GeneratedAssembly。XmlSerializationReaderMyWebService.Read19_CallMyMethodResponse() 在Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer14.Deserialize(XmlSerializationReader阅读器) 在System.Xml.Serialization.XmlSerializer.Deserialize(的XmlReader XmlReader中,字符串的encodingStyle,XmlDeserializationEvents事件) 的InnerException:

回答

2

如果XML确实格式不正确,我可以建议的唯一方法是以XML形式获取响应,然后手动解析它。这可能只是.Net序列化不能完全理解它的格式。

+0

你能就如何做到这一点的详细信息? – Samjog 2010-01-06 06:58:09

1

我有同样的问题,收到这个错误耗费了德尔福的WebService与.NET客户端。 我一定要得到这个响应

<message name="CreateCustomerResponse"> 
    <part name="CustomerCode" type="ns1:TFHOCustomerCode" /> 
    <part name="return" type="xs:int" /> 
    </message> 

.NET有反序列化自定义数据类型的问题。 更改为

<message name="CreateCustomerResponse"> 
    <part name="CustomerCode" type="xsd:string" /> 
    <part name="return" type="xs:int" /> 
    </message> 

做了工作,最后失去了问题。 希望这对任何人都有帮助,我肯定整整一个星期都在为这个问题进行挖掘。

问候, 索林