2012-01-19 10 views
1

iOS/Restkitアプリに問題があります。それは正常に動作するために使用されていましたが、現在はもう機能しませんもちろん、私は何百万ものものを扱ってきましたが、私が重要と考えるものは何もありません。問題は、カールした端末から私のサーバと通信することができますが、私のアプリから試してみると、サーバは例外をスローします!私はRestKitで何が間違っていますか?サーバーは、iOS/Restkitとは異なる応答を返します。

まず、アカウントを削除して、ターミナルから新しいアカウントを作成したことがわかります。 (私も行って、ちょうどので、私は試してみて、私のアプリからそれを作成することができ、再びそれを削除した。)(IPアドレスが削除されます。)

$ curl "http://0.0.0.0:8080/registration/rest/users/delete_account" -d "email=paul%40longpointlabs.com&pwd=123456&uname=Paul" 
Success 
$ curl "http://0.0.0.0:8080/registration/rest/users/create_account" -d "email=paul%40longpointlabs.com&pwd=123456&uname=Paul" 
6345b3cedc5935b1dad9863c795c26391326998921644 
$ curl "http://0.0.0.0:8080/registration/rest/users/delete_account" -d "email=paul%40longpointlabs.com&pwd=123456&uname=Paul" 
Success 

予想通り、すべてが行ったこと。だからここに私のアプリのコードです:

{ 
    RKObjectManager* objectManager = [RKObjectManager objectManagerWithBaseURL:baseURL]; 
    objectManager.serializationMIMEType = RKMIMETypeJSON; 

    [CreateAccount setupCreateAccountMapping]; 

    CreateAccount* user = [[CreateAccount alloc] init]; 
    user.email = @"[email protected]"; 
    user.uname = @"Paul"; 
    user.pwd = @"123456"; 

    [[RKObjectManager sharedManager] postObject:user delegate:self]; 
} 

- (void)objectLoader:(RKObjectLoader*)objectLoader didFailWithError:(NSError*)error 
{  
    RKResponse *response = [objectLoader response]; 
    NSLog(@"didFailWithError Code: %d", [response statusCode]); 
    NSLog(@"didFailWithError Body: %@", [response bodyAsString]); 

} 

- (void)request:(RKRequest*)request didLoadResponse:(RKResponse *)response 
{ 
    NSLog(@"idLoadResponse: %@", [response bodyAsString]); 
} 

そして、私はこれを実行すると、私はこの応答を取得します。まず、トレースから:(私はIPアドレスを削除しました...)

2012-01-19 14:04:10.244 test[2703:fb03] T restkit.network:RKRequest.m:310 Prepared POST URLRequest '<NSMutableURLRequest http://0.0.0.0:8080/registration/rest/users/create_account>'. HTTP Headers: { 
    Accept = "application/json"; 
    "Content-Length" = 64; 
    "Content-Type" = "application/json"; 
}. HTTP Body: {"pwd":"123456","uname":"Paul","email":"[email protected]"}. 
2012-01-19 14:04:10.345 test[2703:fb03] D restkit.network:RKResponse.m:196 NSHTTPURLResponse Status Code: 406 
2012-01-19 14:04:10.345 test[2703:fb03] D restkit.network:RKResponse.m:197 Headers: { 
    "Content-Length" = 79; 
    "Content-Type" = "application/json"; 
    Date = "Thu, 19 Jan 2012 19:04:10 GMT"; 
    Server = "Apache-Coyote/1.1"; 
} 
2012-01-19 14:04:10.346 test[2703:fb03] T restkit.network:RKResponse.m:202 Read response body: javax.transaction.RollbackException: ARJUNA-16053 Could not commit transaction. 

そして、私のdidLoadResponse:

2012-01-19 14:07:22.850 test[2750:fb03] didLoadResponse: javax.transaction.RollbackException: ARJUNA-16053 Could not commit transaction. 

そして、不思議なことに、didFailWithErrorとも呼ばれます。

2012-01-19 14:08:23.188 test[2750:fb03] didFailWithError Code: 406 
2012-01-19 14:08:35.250 test[2750:fb03] didFailWithError Body: javax.transaction.RollbackException: ARJUNA-16053 Could not commit transaction. 

私はこれで困惑しています。私のiOSアプリは、どのようにしてカールから戻って別の応答を得ることができますか?私はそれがUser-Agentに応答しているとは思わないので、サーバーの制御権を持っています。ありがとう!

答えて

2

RestKitはPOST JSONに設定されていますが、カールを使用してフォームエンコードされたパラメータをPOSTしています。 RestKitのシリアル化MIMEタイプを変更する必要があります。

+0

これはまさにそれでした、ありがとう! objectManager.serializationMIMEType = RKMIMETypeFormURLEncoded; 私は、私のアプリケーションの他の部分のためにしばらく前にそのコードのセクションで作業していた...変更を忘れてしまった。 –

関連する問題