1

iPhone アプリケーションから SOAP Web サービスを利用しようとしていますが、Charles に確認すると次のエラーが表示されます。

値を null にすることはできません。パラメータ名: s

以下は私のコードです:

NSString *soapMessage = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"utf-8\"?><SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"><SOAP-ENV:Body><updateTimesheet><TimeSheetHourID>222</TimeSheetHourID></updateTimesheet></SOAP-ENV:Body></SOAP-ENV:Envelope>"];

NSURL *url = [NSURL URLWithString:@"http://172.xx.xxx.xx:xxxx/postService.svc/basic"];

NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];


NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]];
NSLog(@"Message Length..%@",msgLength);

[theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue: @"urn:IpostService/updateTimesheet" forHTTPHeaderField:@"SOAPAction"];
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];

NSHTTPURLResponse* urlResponse = nil;
NSError *error = [[NSError alloc] init];
//NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];

NSData *responseData = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:&urlResponse error:&error];
NSString *result = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
NSLog(@"Response Code: %d", [urlResponse statusCode]);
if ([urlResponse statusCode] >= 200 && [urlResponse statusCode] < 300) {
    NSLog(@"Response: %@", result);
    //here you get the response 
}

応答でエラー コード 500 が返されます。誰か助けてくれませんか?

ありがとうござい
ます

4

2 に答える 2

0

エラー 500 は - 内部サーバー エラーです。つまり、サーバーが予期しない状況に遭遇したため、リクエストを実行できませんでした。

サーバーに適切なリクエストを送信していることを確認してください。他の場所で消費できますか?

于 2012-02-08T12:41:03.710 に答える
0

問題はここのコードではありません.. Webサービスコードをトレースすることをお勧めします。

于 2012-02-08T13:31:34.913 に答える