【发布时间】:2015-12-29 01:08:26
【问题描述】:
我正在调用 .net Web 服务,我需要传递 16 个参数,其中一个是日期(StrCreatedOn)但是当我将日期传递给它时,它给了我错误 - 服务器无法处理请求。 ---> 将数据类型 nvarchar 转换为日期时间时出错。我是ios新手,不知道如何解决这个问题,请帮助我,有人请回答我。 这是我的代码:
NSString *soapMessage = [NSString stringWithFormat:
@"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n"
"<soap:Body>\n"
"<NI_TDR_QUESTION_ANSWER_SAVE xmlns=\"http://tempuri.org/\">\n"
"<StrEntityId>1</StrEntityId>\n"
"<StrSerialNo>99</StrSerialNo>\n"
"<StrInwardNo>N/10/2013</StrInwardNo>\n"
"<StrQuestionId>2</StrQuestionId>\n"
"<StrMCQAns>होय</StrMCQAns>\n"
"<StrAnsReason>शिफारस आहे</StrAnsReason>\n"
"<StrDeptId>648</StrDeptId>\n"
"<StrFinalTag>null</StrFinalTag>\n"
"<StrCreatedBy>2719</StrCreatedBy>\n"
"<StrCreatedOn>04/04/2015</StrCreatedOn>\n"
"<StrModifiedBy>NULL</StrModifiedBy>\n"
"<StrModifiedOn>NULL</StrModifiedOn>\n"
"<StrSubQuestionId>१</StrSubQuestionId>\n"
"<StrStep>STEP1</StrStep>\n"
"<StrQuestionNo>1</StrQuestionNo>\n"
"<StrMode>I</StrMode>\n"
"</NI_TDR_QUESTION_ANSWER_SAVE>\n"
"</soap:Body>\n"
"</soap:Envelope>\n"];
NSLog(@"%@",soapMessage);
NSURL *url = [NSURL URLWithString:@"<Host URL>"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%ld", [soapMessage length]];
[theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue: @"http://tempuri.org/NI_TDR_QUESTION_ANSWER_SAVE" 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 alloc]init] ;
}
else
{
NSLog(@"theConnection is NULL");
}
【问题讨论】:
标签: ios iphone xcode web-services ios7