调用.net webService时出错

时间:2015-10-01 05:01:05

标签: ios iphone xcode web-services ios7

我正在调用.net web服务,我需要传递16个参数,其中一个是date(StrCreatedOn)但是当我将日期传递给它时,它给了我错误 - 服务器无法处理请求。 --->将数据类型nvarchar转换为datetime时出错。我是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");
    }

1 个答案:

答案 0 :(得分:0)

您的代码没有任何问题。这似乎是一个服务器代码问题。您可以要求您的服务人员纠正此问题。