Note that there are some explanatory texts on larger screens.

plurals
  1. POIOS - Same ASIHTTPRequest code doesn't work only one method
    primarykey
    data
    text
    <p>In my project I make the other functions work with this code. But for this method I cannot make it work. I did copy-paste all this code for different methods(changing URL ,Result). The parameters of this methods are only int and string.</p> <p>I always correct the wcf method from SOAP UI and .NET project.It works correct. I only cannot make this code work for this method. </p> <p>The <code>[request responseString]</code> returns a patient's information. Please help me. Thank you.</p> <pre><code> ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:HASTAARAIP]]; NSData *myPostData = [[NSString stringWithFormat:@"{\"kat\":0,\"oda\":0,\"hastaAdi\":\"KAI\",\"protokolNo\":0,\"yatanAyaktan\":1}"] dataUsingEncoding:NSUTF8StringEncoding]; NSMutableData *myMutablePostData = [[NSMutableData alloc]initWithData:myPostData]; [request setPostBody:myMutablePostData]; [request setRequestMethod:@"GET"]; [request addRequestHeader:@"Content-Type" value:@"application/json"]; [request setDelegate:self]; [request startSynchronous]; </code></pre> <p>Here is some things that can make you understand. </p> <p>With this code the <code>[request responseString]</code> and <code>[request responseStatusMessage]</code> is null. But if I remove the line where the addRequestHeader, it says for responseStatusMessage HTML/1.1HTTP/1.1 404 Not Found 404. I didn't understand why it gives this 404 error. This request type works for the other methods. The ıp is like <code>http://.../rest/&lt;methodname&gt;</code></p> <p>Added log for a part of responsestring`:</p> <blockquote> <p>The server encountered an error processing the request. The exception message is 'The incoming message has an unexpected message format 'Raw'. The expected message formats for the operation are 'Xml'; 'Json'. This can be because a WebContentTypeMapper has not been configured on the binding. See the documentation of WebContentTypeMapper for more details.'. See server logs for more details. The exception stack trace is:</p> </blockquote> <p><strong>Updated:</strong></p> <pre><code>ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:HASTAARAIP]]; [request setPostValue:@"0" forKey:@"kat"]; [request setPostValue:@"0" forKey:@"oda"]; [request setPostValue:@"KAI" forKey:@"hastaAdi"]; [request setPostValue:@"0" forKey:@"protokolNo"]; [request setPostValue:@"1" forKey:@"yatanAyaktan"]; [request startSynchronous]; </code></pre> <p>But for responseString the logs:</p> <pre><code>The server encountered an error processing the request. The exception message is 'The incoming message has an unexpected message format 'Raw'. The expected message formats for the operation are 'Xml'; 'Json'. This can be because a WebContentTypeMapper has not been configured on the binding. See the documentation of WebContentTypeMapper for more details.'. See server logs for more details. The exception stack trace is: </code></pre> <p><strong>Trying with AFNetworking:</strong></p> <pre><code>AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; NSDictionary *params = @{@"kat": @"0",@"oda": @"0", @"hastaAdi":hastaAdi, @"protokolNo":@"0",@"yatanAyaktan":@"1"}; [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"]; [manager POST:HASTAARAIP parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { NSLog(@"JSON: %@", responseObject); } failure:^(AFHTTPRequestOperation *operation, NSError *error) { NSLog(@"Error: %@", error); }]; </code></pre> <p>But the log is like this:</p> <pre><code>Error: Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (JSON text did not start with array or object and option to allow fragments not set.) UserInfo=0x8e49ce0 {NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.} </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload