Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9284165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T18:50:09+00:00 2026-06-18T18:50:09+00:00

I have a simple asp.net web service which returns json format data. I want

  • 0

I have a simple asp.net web service which returns json format data. I want to send http post request with parameter for getting json data. How can I send request and get data ?

post request:

POST /JsonWS.asmx/FirmaGetir HTTP/1.1
Host: localhost
Content-Type: application/x-www-form-urlencoded
Content-Length: length

firID=string

answer:

HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length    
<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://tempuri.org/">string</string>

I’m trying some codes but they didn’t work.

NSString *firmadi =@"";
NSMutableData *response;


-(IBAction)buttonClick:(id)sender
{
    NSString *firid = [NSString stringWithFormat:@"800"];

    response = [[NSMutableData data] retain];

    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://192.168.1.23/testService/JsonWS.asmx?op=FirmaGetir"]];

    NSString *params = [[NSString alloc] initWithFormat:@"firID=%@",firid];
    [request setHTTPMethod:@"POST"];
    [request setHTTPBody:[params dataUsingEncoding:NSUTF8StringEncoding]];
    [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    [[NSURLConnection alloc] initWithRequest:request delegate:self];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];

    if(theConnection)
    {
        response = [[NSMutableData data] retain];

    }
    else 
    {
        NSLog(@"theConnection is null");
    }

}

-(void)connection:(NSURLConnection*)connection didReceiveResponse:(NSURLResponse*)responsed
{
    [response setLength:0];
     NSURLResponse * httpResponse;

    httpResponse = (NSURLResponse *) responsed;

}

-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData*)data
{
    [response appendData:data];
    //NSLog(@"webdata: %@", data);

}

-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError*)error
{
    NSLog(@"error with the connection");
    [connection release];
    [response release];
}

-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{

    response = [[NSMutableData data] retain];

 NSString *responseString = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];
    NSLog(@"%@",responseString);

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T18:50:10+00:00Added an answer on June 18, 2026 at 6:50 pm

    What are you doing here:

    [[NSURLConnection alloc] initWithRequest:request delegate:self];
    

    This line returns a NSURLConnection but you are not storing it. This is doing nothing for you.

    You are clearing your data before you read it:

    -(void)connectionDidFinishLoading:(NSURLConnection *)connection
    {
        response = [[NSMutableData data] retain]; // This line is clearing your data get rid of it
        NSString *responseString = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];
        NSLog(@"%@",responseString);
    
    }
    

    Edit

    -(IBAction)buttonClick:(id)sender {
    
        NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://192.168.1.23/testService/JsonWS.asmx?op=FirmaGetir"]
                                                               cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData
                                                           timeoutInterval:15];
        [request setHTTPMethod:@"POST"];
        [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
        [request setHTTPBody:[@"firID=800" dataUsingEncoding:NSUTF8StringEncoding]];
        self.connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
        [self.connection start];
    
    }
    
    
    #pragma NSURLConnection Delegates
    
    - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
    
        if (!self.receivedData){
            self.receivedData = [NSMutableData data];
        }
        [self.receivedData appendData:data];
    }
    
    - (void)connectionDidFinishLoading:(NSURLConnection *)connection {
    
         NSString *responseString = [[NSString alloc] initWithData:self.receivedData encoding:NSUTF8StringEncoding];
         NSLog(@"%@",responseString);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a simple ASP.Net WCF Ajax enabled web service which is called via
What I have created a very simple asp.net web service using .NET framework 3.5,
A simple question. I have an ASP.NET web application which contains several assemblies and
I have a ASP.NET web service decorated with System.Web.Script.Services.ScriptService() so it can return json
I have a simple ASP.NET web app which uses a WCF Client to talk
I have an ASP.NET MVC 3 / .NET Web Application, which is heavily data-driven,
I have a pretty simple ASP.NET Web Form that looks a bit like the
We have a very simple ASP.NET web application comprising mostly static content and a
I have a simple web app built in asp.net webforms c# where and how
I created a simple ASP.NET MVC version 1.0 application. I have a ProductController which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.