我是手机编程的新手。我已经创建了一个Web服务和一个函数,它应该返回从普及数据库中检索到的记录。 但我没有得到输出。它显示出这样的例外情况。可以告诉我什么是错误。
2013-05-20 18:54:36.502 NewC Newcafezee[1743:11303] <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>System.Web.Services.Protocols.SoapException: Server was unable to read request. ---> System.InvalidOperationException: There is an error in XML document (7, 109). ---> System.FormatException: The string '3/1/2013' 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.Read1_OnlineStatus()
at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer.Deserialize(XmlSerializationReader reader)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
--- End of inner exception stack trace ---
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle)
at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
--- End of inner exception stack trace ---
at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()</faultstring><detail /></soap:Fault></soap:Body></soap:Envelope>
此代码中是否有任何错误
NSString *soapMessage=[NSString stringWithFormat:
@"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
"<soap:Envelope \n"
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" \n"
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"\n"
"xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n"
"<soap:Body>\n"
"<OnlineStatus xmlns=\"http://tempuri.org/\"><CafeName>Cyber Cafe Name</CafeName><FromDate>3/1/2013</FromDate><ToDate>5/6/2013</ToDate></OnlineStatus>\n"
"</soap:Body>\n"
"</soap:Envelope>"];
NSLog(@"%@",soapMessage);
NSURL *url = [NSURL URLWithString:@"http://www.ebidmanagerdemo.com/gjHouseOnline/xml/XMLDataService.asmx"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]];
[theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue: @"http://tempuri.org/OnlineStatus" forHTTPHeaderField:@"Soapaction"];
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if(theConnection) {
webData = [NSMutableData data];
}
else {
NSLog(@"theConnection is NULL");
NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]];
NSLog(@"%@",msgLength);
答案 0 :(得分:2)
System.FormatException:字符串'3/1/2013'不是有效的AllXsd 值。
根据 XML Schema Specification ,date time
值应采用ISO8601
格式,
对于Eg:
2013-01-03T22:16:00