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

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.

LVL 2
d34thd34l34rAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Alexandre SimõesManager / Technology SpecialistCommented:
0
MogalManicCommented:
So is the .net web service return a DataSet or DataTable object?

What is the method signature (WSDL)?
0
d34thd34l34rAuthor Commented:
Yes
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Alexandre SimõesManager / Technology SpecialistCommented:
"Yes" is a pretty good and explaining answer to witch I can just say "Thanks!"
0
d34thd34l34rAuthor Commented:
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
d34thd34l34rAuthor Commented:
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
MogalManicCommented:
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
d34thd34l34rAuthor Commented:
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
MogalManicCommented:
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
d34thd34l34rAuthor Commented:
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
MogalManicCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
d34thd34l34rAuthor Commented:
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
MogalManicCommented:
Sorry, I am learning Iphone SDK also and even greener than you!    Try posting another question on that topic.
0
ImperiumDevCommented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Swift Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.