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 9317507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T02:53:44+00:00 2026-06-19T02:53:44+00:00

I have one .Net web service and I use it for mobile apps. I

  • 0

I have one .Net web service and I use it for mobile apps. I used it on windows phone and android apps but I didn’t get data from it on iOS yet. For example, there is one method in my web service and it takes one parameter. How can I get data from returning value ? I found one example on internet and I edited it but I can’t get data. All of code is here. In this case I need a sample code. Thanks for attention.

web service’s information:

namespace : http://tempuri.org
url : http://www.example.com/webservice1.asmx
method name : FirmaGetir
parameter name: firID (string)

Web service request:

    POST /webservice1.asmx HTTP/1.1
Host: example.com
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <FirmaGetir xmlns="http://tempuri.org/">
      <firID>string</firID>
    </FirmaGetir>
  </soap12:Body>
</soap12:Envelope>

Returning data:

HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <FirmaGetirResponse xmlns="http://tempuri.org/">
      <FirmaGetirResult>
        <Firma>
          <firma_adi>string</firma_adi>
          <adres>string</adres>
          <telefon>string</telefon>
          <id>string</id>
          <sektor>string</sektor>
          <alt_sektor>string</alt_sektor>
          <alt_sektor_adi>string</alt_sektor_adi>
          <servis>string</servis>
          <map>string</map>
          <slogan>string</slogan>
          <sayfaGosterimi>int</sayfaGosterimi>
          <gpsilce>string</gpsilce>
          <gpssemt>string</gpssemt>
          <gpspk>string</gpspk>
          <duyuru>
            <baslik>string</baslik>
            <icerik>string</icerik>
            <link>string</link>
            <image>string</image>
          </duyuru>
          <firma_link>
            <tam_adi>string</tam_adi>
            <kisa_adi>string</kisa_adi>
            <firma_link>string</firma_link>
          </firma_link>
        </Firma>
      </FirmaGetirResult>
    </FirmaGetirResponse>
  </soap12:Body>
</soap12:Envelope>

SOAPExampleViewController.h

#import <UIKit/UIKit.h>
@interface SOAPExampleViewController : UIViewController 
{
    NSXMLParser *xmlParser;
    NSMutableData *webData;
    NSMutableString *soapResults;
    BOOL recordResults;
}

@property(nonatomic, retain) NSMutableData *webData;
@property(nonatomic, retain) NSXMLParser *xmlParser;
@property(nonatomic, retain) NSMutableString *soapResults;

-(IBAction)buttonClick:(id)sender;

@end

SOAPExampleViewController.m

#import "SOAPExampleViewController.h"

@implementation SOAPExampleViewController
@synthesize xmlParser, webData, soapResults;


-(IBAction)buttonClick:(id)sender
{
    NSString *firid = [NSString stringWithFormat:@"800"];
    recordResults = NO;
    NSString *soapMessage = [NSString stringWithFormat:
                         @"POST /webservice1.asmx HTTP/1.1\n"
                         "Host: example.com\n"
                         "Content-Type: application/soap+xml; charset=utf-8\n"
                         "Content-Length: length\n"

                         "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
                         "<soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\">\n"
                         "<soap12:Body>\n"
                         "<FirmaGetir xmlns=\"http://tempuri.org/\">\n"
                         "<firID>%@</firID>\n"
                         "</FirmaGetir>\n"
                         "</soap12:Body>\n"
                         "</soap12:Envelope>\n",firid];
    NSLog(@"%@", soapMessage);
    NSURL *url = [NSURL URLWithString:@"http://www.example.com/webservice1.asmx?op=FirmaGetir"];
    NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
    NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]];

    [theRequest addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
    [theRequest addValue:@"http://tempuri.org/FirmaGetir" 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 data] retain];
    }
    else 
    {
        NSLog(@"theConnection is null");
    }
}

-(void)connection:(NSURLConnection*)connection didReceiveResponse:(NSURLResponse*)response
{
    [webData setLength:0];
     NSHTTPURLResponse * httpResponse;
    httpResponse = (NSHTTPURLResponse *) response;
    NSLog(@"HTTP error %zd", (ssize_t) httpResponse.statusCode);
}

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

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

-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
    NSLog(@"DONE. Received bytes %d", [webData length]);
    NSString *theXML = [[NSString alloc] initWithBytes:[webData mutableBytes] length:[webData length] encoding:NSUTF8StringEncoding];
    NSLog(@"xml %@",theXML);
    [theXML release];
    NSString *responseString = [[NSString alloc] initWithData:webData encoding:NSUTF8StringEncoding];
    NSLog(@"Respose Data :%@",responseString) ;
    if(xmlParser)
    {
        [xmlParser release];
    }
    xmlParser = [[NSXMLParser alloc] initWithData:webData];
    [xmlParser setDelegate:self];
    [xmlParser setShouldResolveExternalEntities:YES];
    [xmlParser parse];
    [connection release];
    [webData release];
}

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict
{
    if([elementName isEqualToString:@"firma_adi"] || [elementName isEqualToString:@"Firma"] || [elementName isEqualToString:@"adres"] ) //I'm trying
    {
            if(!soapResults)
        {
            soapResults = [[NSMutableString alloc]init];
        }
        recordResults = YES;
    }
}

- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
    if(recordResults)
    {
        [soapResults appendString:string];
    }
}

- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
    if([elementName isEqualToString:@"firma_adi"] || [elementName isEqualToString:@"Firma"] || [elementName isEqualToString:@"adres"] ) // I'm trying
    {
        recordResults = NO;
        NSLog(@"%@", soapResults);
        [soapResults release];
        soapResults = nil;
    }
}
  • 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-19T02:53:46+00:00Added an answer on June 19, 2026 at 2:53 am

    I was trying solve this issue about one week. I don’t search anymore about it. The best way for consuming web service is using WCF services with JSON. I found an excellent example about of it. Please follow this tutorial http://www.codeproject.com/Articles/405189/How-to-access-SQL-database-from-an-iPhone-app-Via

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Interesting one here. I have an ASP.NET 1.1 project that contains a web service
Background: I have a .NET 4.0 web service running on Windows Server 2008 written
I have to use a 3rd party web service implemented in .NET 2.0 (on
I have ASP.NET web apps and 1 wcf web service. I would like to
We have an ASP.net web service (.asmx) up on our server that one of
I have a C# .Net Web Service. I am trying to use nHibernate to
I have a few webservices (.net 2.0/ C#) used by many partners. One of
I have a requirement to pass credentials from one Microsoft .NET Web Application to
I have one question; In my ASP.NET MVC web application have to do certain
I have started upgrading one of our internal software applications, written in ASP.NET Web

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.