从Web服务读取响应时出现异常 [英] Exception while reading the response from web service

查看:142
本文介绍了从Web服务读取响应时出现异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从我的Windows移动应用程序调用Java Web Service,从服务中有一些字段的值可以为null,架构在reference.cs文件中是这样的

Am making a call to Java Web Service from my windows mobile application, from the service there are some fields whose value can be null, the schema is like this in the reference.cs file

  [System.Xml.Serialization.XmlElementAttribute(" field-Name",IsNullable = true)]

  &NBSP; &NBSP; &NBSP; public System.Nullable< bool>提起

  &NBSP; &NBSP; &NBSP; {

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;获取

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; return this.FieldNameValue;

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;设置

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; this.FieldNameValue = value;

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }

  &NBSP; &NBSP; &NBSP; }

 [System.Xml.Serialization.XmlElementAttribute("field-Name", IsNullable = true)]
        public System.Nullable<bool> Filed
        {
            get
            {
                return this.FieldNameValue;
            }
            set
            {
                this.FieldNameValue= value;
            }
        }

来自网络服务的响应xml包含 

and the response xml from the web service contains 

< field-name xmlns:xsi =" ; HTTP://www.w3.org/2001/XMLSchema-instance" xsi:nil =" true">< / field-name>

即使将nullable设置为true,它也会将异常视为 

even though the nullable is set to true, it is throwing me the exception as 

The string '' is not a valid AllXsd value."

堆栈跟踪显示

  at System.Xml.Schema.XsdDateTime..ctor(String text, XsdDateTimeFlags kinds)
  at System.Xml.XmlConvert.ToDateTime(String s, XmlDateTimeSerializationMode dateTimeOption)
  at System.Xml.Serialization.XmlCustomFormatter.ToDateTime(String value)
  at System.Xml.Serialization.XmlSerializationReader.ToDateTime(String value)
  at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read19_ShipmentInfo(Boolean isNullable, Boolean checkType)
  at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read23_AWBInfo(Boolean isNullable, Boolean checkType)
  at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read25_TrackingResponse(Boolean isNullable, Boolean checkType)
  at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read29_TrackingResponse()
  at Microsoft.Xml.Serialization.GeneratedAssembly.TrackingResponseSerializer.Deserialize(XmlSerializationReader reader)
  at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)

相同代码适用于桌面应用程序。但是在紧凑的框架中,我是否需要对架构进行任何更改。

The same code works fine for desktop application. but not in compact framework, do I need to make any changes in the schema.

提前致谢

Julian B

推荐答案

您好,

As据我所知,.NET Compact Framework与XML Web Services支持一起使用存在一些限制。您可以查看此文档。

http://msdn.microsoft。 com / zh-CN / library / aa446549.aspx #net_vs_netcf_topic11

As far as I know, there are some limitations for .NET Compact Framework to work with XML Web Services Support. You can check this document.
http://msdn.microsoft.com/en-us/library/aa446549.aspx#net_vs_netcf_topic11

在您的问题中,我们无法获得有关错误的更多信息。我建议你检查前面限制的代码。

In your question, we cannot get more information about the error. I would suggest you to check your codes with the front limitation.

最好的问候,

Jesse

Best regards,
Jesse


这篇关于从Web服务读取响应时出现异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆