Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

iPhone how do i retrieve a .net dataset from a webservice

Posted on 2009-07-15
14
Medium Priority
?
1,540 Views
Last Modified: 2012-05-07
Hello,
          I am trying to pull a dataset from an existing webservice but have no clue how or if it can be done in cocoa touch.  I can consume the .net webservices just fine however, when trying to interact with a .net based object type there are obviously some complications.  Any advice would be GREATLY appreciated as i am just breaking the ice in the beautiful world of mac development.

0
Comment
Question by:d34thd34l34r
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
  • 2
  • +1
14 Comments
 
LVL 30

Expert Comment

by:Alexandre Simões
ID: 24867899
0
 
LVL 21

Expert Comment

by:MogalManic
ID: 24878580
So is the .net web service return a DataSet or DataTable object?

What is the method signature (WSDL)?
0
 
LVL 2

Author Comment

by:d34thd34l34r
ID: 24878847
Yes
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 30

Expert Comment

by:Alexandre Simões
ID: 24879932
"Yes" is a pretty good and explaining answer to witch I can just say "Thanks!"
0
 
LVL 2

Author Comment

by:d34thd34l34r
ID: 24880315
I am sorry for being short...  I though i was typing in another posting... I do apologize for being disrespectful.   I will post the WSDL when im not on a phone and i can get to a machine.

0
 
LVL 2

Author Comment

by:d34thd34l34r
ID: 24915474
Method signature basically looks like so:

 DataSet ( string username, string password ){

}

it is WSDL... i have read that many examples in which REST web services are used however if possible i would like to keep the SOAP based.
0
 
LVL 21

Expert Comment

by:MogalManic
ID: 24916078
Since you havn't given complete examples I will create an example.

I created a simple web method (simalar to your sample) :
    [WebMethod]
    public DataSet HelloWorld(string username, string password )
    {
        DataSet data=new DataSet();
        data.ReadXml(new StringReader(@"FredTester"));
        data.AcceptChanges();
        return data;
    }



What the reported WSDL looks like the attached HelloWorld.WSDL.txt.  When you call the web service, the results are a string that matches the DataSet XML (see attachement WSResults.txt
 
WSResults.txt
HelloWorld.WSDL.txt
0
 
LVL 2

Author Comment

by:d34thd34l34r
ID: 24916083
Would it be easier if i just used the .net xml serializer and serialized the data so objective c could pick it up a little easier.  Obviously this would expose the values being passed back to the iphone but, as with any language you could write some AES encryption methods relatively easily that could take care of that exposure... What do you think?
0
 
LVL 21

Expert Comment

by:MogalManic
ID: 24916119
Once you register your Web service using the  /usr/bin/WSMakeStubs command, the stubs will show how it registered the Return type.  It will either be a NSDocument object or a NSString object.
0
 
LVL 2

Author Comment

by:d34thd34l34r
ID: 24916138
MogalManic, guess we were posting at the same time...  Thats interesting... Im going to look into that a little further as it seems, by your example, i should be able to consume it relatively easily!  Im going to try that today and get back to you... Thanks...
0
 
LVL 21

Accepted Solution

by:
MogalManic earned 2000 total points
ID: 24916153
You don't have to use the .Net xml serializer because it is already being done.  If you look at the sample I created, the WSDL says it will return a XML object

See lines 13-26:
      <s:element name="HelloWorldResponse">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="HelloWorldResult">
              <s:complexType>
                <s:sequence>
                  <s:element ref="s:schema" />
                  <s:any />
                </s:sequence>
              </s:complexType>
            </s:element>
          </s:sequence>
        </s:complexType>
      </s:element>

Open in new window

0
 
LVL 2

Author Comment

by:d34thd34l34r
ID: 24920914
Followed you instructions and am tracking so far however, do you know of any reason why the WSMakeStubs would create files with errors in them... Normally if this wasnt such a new language to me i would be able to figure it out however, im still a noob @ objective c... See the attached file and i will also attach the code for your review.... Thank you...
/*-
 * WSDL stubs for:  http://localhost/bla/HHU_Authorization.asmx?wsdl
 *   Generated by:  d34thd34l3r
 *           Date:  Wed Jul 22 18:58:20 2009
 *        Emitter:  Objective-C
 */
 
#ifndef __HHU_Authorization__
#define __HHU_Authorization__
 
#import <CoreServices/CoreServices.h>
#import <Foundation/Foundation.h>
#import "WSGeneratedObj.h"
 
/*-
 *   Web Service:  HHU_Authorization
 * Documentation:  <not documented>
 */
/*-
 *   Method Name:  Authorize_Device
 * Documentation:  <no documentation>
 */
 
@interface Authorize_Device : WSGeneratedObj
 
// update the parameter list for the invocation.
- (void) setParameters:(CFTypeRef /* Complex type http://localhost/bla|Authorize_Device */) in_parameters;
 
// result returns an id from the reply dictionary as specified by the WSDL.
- (id) resultValue;
 
@end; /* Authorize_Device */
 
 
/*-
 *   Method Name:  Login
 * Documentation:  <no documentation>
 */
 
@interface Login : WSGeneratedObj
 
// update the parameter list for the invocation.
- (void) setParameters:(CFTypeRef /* Complex type http://localhost/bla/|Login */) in_parameters;
 
// result returns an id from the reply dictionary as specified by the WSDL.
- (id) resultValue;
 
@end; /* Login */
 
 
/*-
 *   Method Name:  Authorize_Device
 * Documentation:  <no documentation>
 */
 
@interface Authorize_Device : WSGeneratedObj
 
// update the parameter list for the invocation.
- (void) setParameters:(CFTypeRef /* Complex type http://localhost/bla/|Authorize_Device */) in_parameters;
 
// result returns an id from the reply dictionary as specified by the WSDL.
- (id) resultValue;
 
@end; /* Authorize_Device */
 
 
/*-
 *   Method Name:  Login
 * Documentation:  <no documentation>
 */
 
@interface Login : WSGeneratedObj
 
// update the parameter list for the invocation.
- (void) setParameters:(CFTypeRef /* Complex type http://localhost/bla/|Login */) in_parameters;
 
// result returns an id from the reply dictionary as specified by the WSDL.
- (id) resultValue;
 
@end; /* Login */
 
 
/*-
 * Web Service:  HHU_Authorization
 */
@interface HHU_AuthorizationService : NSObject 
 
+ (id) Authorize_Device:(CFTypeRef /* Complex type http://localhost/bla/|Authorize_Device */) in_parameters;
+ (id) Login:(CFTypeRef /* Complex type http://localhost/bla/|Login */) in_parameters;
 
@end;
 
 
#endif /* __HHU_Authorization__ */
/*-
 * End of WSDL document at http://localhost/bla/HHU_Authorization.asmx?wsdl
 */
 
 
 
 
/*-
 * WSDL stubs for:  http://localhost/bla/HHU_Authorization.asmx?wsdl
 *   Generated by:  d34thd34l3r
 *           Date:  Wed Jul 22 18:58:20 2009
 *        Emitter:  Objective-C
 */
 
#import "HHU_Authorization.h"
 
/*-
 *   Method Name:  Authorize_Device
 * Documentation:  <no documentation>
 */
@implementation Authorize_Device
- (void) setParameters:(CFTypeRef /* Complex type http://localhost/bla/|Authorize_Device */) in_parameters
{
    id _paramValues[] = {    
        in_parameters,        
    };    
    NSString* _paramNames[] = {    
        @"parameters",        
    };    
    [super setParameters:1 values: _paramValues names: _paramNames];    
}
 
- (id) resultValue
{
    return [[super getResultDictionary] objectForKey: @"parameters"];    
}
 
- (WSMethodInvocationRef) genCreateInvocationRef
{
    return [self createInvocationRef    
               /*endpoint*/: @"http://localhost/bla/HHU_Authorization.asmx"            
                 methodName: @"Authorize_Device"            
                 protocol: (NSString*) kWSSOAP2001Protocol            
            // missing encoding style - defaulting to RPC            
                      style: (NSString*) kWSSOAPStyleRPC            
                 soapAction: @"http://localhost/bla/Authorize_Device"            
            methodNamespace: NULL /* No Method Namespace specified */            
        ];        
}
 
@end; /* Authorize_Device */
 
 
/*-
 *   Method Name:  Login
 * Documentation:  <no documentation>
 */
@implementation Login
- (void) setParameters:(CFTypeRef /* Complex type http://localhost/bla/|Login */) in_parameters
{
    id _paramValues[] = {    
        in_parameters,        
    };    
    NSString* _paramNames[] = {    
        @"parameters",        
    };    
    [super setParameters:1 values: _paramValues names: _paramNames];    
}
 
- (id) resultValue
{
    return [[super getResultDictionary] objectForKey: @"parameters"];    
}
 
- (WSMethodInvocationRef) genCreateInvocationRef
{
    return [self createInvocationRef    
               /*endpoint*/: @"http://localhost/bla/HHU_Authorization.asmx"            
                 methodName: @"Login"            
                 protocol: (NSString*) kWSSOAP2001Protocol            
            // missing encoding style - defaulting to RPC            
                      style: (NSString*) kWSSOAPStyleRPC            
                 soapAction: @"http://localhost/bla/Login"            
            methodNamespace: NULL /* No Method Namespace specified */            
        ];        
}
 
@end; /* Login */
 
 
/*-
 *   Method Name:  Authorize_Device
 * Documentation:  <no documentation>
 */
@implementation Authorize_Device
- (void) setParameters:(CFTypeRef /* Complex type http://localhost/bla/|Authorize_Device */) in_parameters
{
    id _paramValues[] = {    
        in_parameters,        
    };    
    NSString* _paramNames[] = {    
        @"parameters",        
    };    
    [super setParameters:1 values: _paramValues names: _paramNames];    
}
 
- (id) resultValue
{
    return [[super getResultDictionary] objectForKey: @"parameters"];    
}
 
- (WSMethodInvocationRef) genCreateInvocationRef
{
    return [self createInvocationRef    
               /*endpoint*/: @"http://localhost/bla/HHU_Authorization.asmx"            
                 methodName: @"Authorize_Device"            
                 protocol: (NSString*) kWSSOAP2001Protocol            
            // missing encoding style - defaulting to RPC            
                      style: (NSString*) kWSSOAPStyleRPC            
                 soapAction: @"http://localhost/bla/Authorize_Device"            
            methodNamespace: NULL /* No Method Namespace specified */            
        ];        
}
 
@end; /* Authorize_Device */
 
 
/*-
 *   Method Name:  Login
 * Documentation:  <no documentation>
 */
@implementation Login
- (void) setParameters:(CFTypeRef /* Complex type http://localhost/bla/|Login */) in_parameters
{
    id _paramValues[] = {    
        in_parameters,        
    };    
    NSString* _paramNames[] = {    
        @"parameters",        
    };    
    [super setParameters:1 values: _paramValues names: _paramNames];    
}
 
- (id) resultValue
{
    return [[super getResultDictionary] objectForKey: @"parameters"];    
}
 
- (WSMethodInvocationRef) genCreateInvocationRef
{
    return [self createInvocationRef    
               /*endpoint*/: @"http://localhost/bla/HHU_Authorization.asmx"            
                 methodName: @"Login"            
                 protocol: (NSString*) kWSSOAP2001Protocol            
            // missing encoding style - defaulting to RPC            
                      style: (NSString*) kWSSOAPStyleRPC            
                 soapAction: @"http://localhost/bla/Login"            
            methodNamespace: NULL /* No Method Namespace specified */            
        ];        
}
 
@end; /* Login */
 
 
 
@implementation HHU_AuthorizationService
 
+ (id) Authorize_Device:(CFTypeRef /* Complex type http://localhost/bla/|Authorize_Device */) in_parameters
{
    id result = NULL;    
    Authorize_Device* _invocation = [[Authorize_Device alloc] init];    
    [_invocation setParameters: in_parameters];    
    result = [[_invocation resultValue] retain];    
    [_invocation release];    
    return result;    
}
 
 
+ (id) Login:(CFTypeRef /* Complex type http://localhost/bla/|Login */) in_parameters
{
    id result = NULL;    
    Login* _invocation = [[Login alloc] init];    
    [_invocation setParameters: in_parameters];    
    result = [[_invocation resultValue] retain];    
    [_invocation release];    
    return result;    
}
 
 
 
@end;
 
 
/*-
 * End of WSDL document at
http://localhost/bla/HHU_Authorization.asmx?wsdl
 */

Open in new window

Error.jpg
0
 
LVL 21

Expert Comment

by:MogalManic
ID: 24924126
Sorry, I am learning Iphone SDK also and even greener than you!    Try posting another question on that topic.
0
 

Expert Comment

by:ImperiumDev
ID: 25650983
I have actually made a Dataset object / class for pulling down from web services, maybe it will save some people some time?

http://grabalife.com/2009/10/19/using-net-web-services-and-dataset-objects-in-your-iphone-app/
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question