2013-05-20 2 views
-6

저는 전화 프로그래밍에 익숙하지 않습니다. 웹 서비스와 퍼베이시브 데이터베이스에서 수집 한 레코드를 반환해야하는 함수를 만들었습니다. 하지만 출력이 나오지 않습니다. 어떤 예외적 인 것을 보여줍니다. 어떤 시체가 실수인지 말해 줄 수 있습니까? 문자열 '2013 년 3'은 (는) 유효한 AllXsd 값되지 않습니다아래의 코드에서 실수는 무엇입니까?

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. ---&gt; System.InvalidOperationException: There is an error in XML document (7, 109). ---&gt; 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); 
+7

내가 실수를 발견했습니다! 당신은 "나는 전화한다"라고 철자를 썼다. –

+3

이것은 Stackoverflow 작동 방식이 아닙니다. 코드를 올려 놓고 "고칠 것"이라고 말할 수는 없습니다. 디버깅에 약간의 노력을 보여줘야합니다. –

+0

오류 메시지는 문제의 원인을 알려줍니다. XML 문서 (7, 109)에 오류가 있습니다. --- > System.FormatException : '3/1/2013'문자열이 유효한 AllXsd 값이 아닙니다. –

답변

2

System.FormatException에 어떤 실수가있다. XML Schema Specification에 따르면

, date time 값은 예를 들어

, ISO8601 형식이어야합니다 :

2013-01-03T22:16:00 
관련 문제