Couple Questions (XML Serialization).

Discussion in 'iOS Programming' started by TeeJayEm, Oct 11, 2010.

  1. TeeJayEm macrumors regular

    Joined:
    Mar 28, 2008
    #1
    I'm working on a RESTful based web service and i'm looking for some tools to make my life easier (please please please).

    First, Is it possible to create a Businiss Object from an XML Schema? (like below):
    Code:
    <xs:schema xmlns:ser="http://schemas.microsoft.com/2003/10/Serialization/" xmlns:tns="http://prospects.entities.roomstogo.rtg/prospect" elementFormDefault="qualified" targetNamespace="http://prospects.entities.roomstogo.rtg/prospect" xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:import namespace="http://schemas.microsoft.com/2003/10/Serialization/" />
      <xs:complexType name="Prospect">
        <xs:sequence>
          <xs:element minOccurs="0" name="Address" nillable="true" type="xs:string" />
          <xs:element minOccurs="0" name="AlternatePhone" nillable="true" type="xs:string" />
          <xs:element minOccurs="0" name="City" nillable="true" type="xs:string" />
          <xs:element minOccurs="0" name="Email" nillable="true" type="xs:string" />
          <xs:element minOccurs="0" name="FirstName" nillable="true" type="xs:string" />
          <xs:element minOccurs="0" name="Id" nillable="true" type="xs:string" />
          <xs:element minOccurs="0" name="LastName" nillable="true" type="xs:string" />
          <xs:element minOccurs="0" name="Phone" nillable="true" type="xs:string" />
          <xs:element minOccurs="0" name="State" nillable="true" type="xs:string" />
          <xs:element minOccurs="0" name="ZipCode" nillable="true" type="xs:string" />
        </xs:sequence>
        <xs:attribute ref="ser:Id" />
        <xs:attribute ref="ser:Ref" />
      </xs:complexType>
      <xs:element name="Prospect" nillable="true" type="tns:Prospect" />
    </xs:schema>
    Also, are there any libraries out there that can serialize/deserialize these Business Objets automatically?

    Can i just go on a rant for a second?
    {rant}
    Apple works hard on enterprise support for end-user technologies (i.e. VPN, printing, etc). But the enterprise development tools (or lack thereof) are ridiculously primitive.

    First, i'm forced to convert my existing soap based web services to REST since there aren't any real tools out there for consuming soap. gSoap hardly works and isn't a tool we can get support on if needed.

    Second, xml serialization/deserialization shouldn't be as painful as it appears to be. I can successfully do this manually but some of these objects have tons of properties and manually implementing this plumbing is annoying and tedious work.

    IMO Apple is missing the point when it comes to enterprise app development. The programming manager wants R.A.D. tools. Executives care about how much it cost to build the app. It doesn't matter that iPad supports printing if there is no Business Data to print.
    {/rant}
     
  2. vocaro macrumors regular

    Joined:
    Mar 5, 2004
    #2
    Yes.

    Depends on how the objects are defined and what you mean by "serialize" and "automatically".

    Exactly what kind of features do you need that are not in Cocoa?
     
  3. TeeJayEm thread starter macrumors regular

    Joined:
    Mar 28, 2008
    #3
    Hey and thanks for the reply. First, let me say that i am not a professional when it comes to XCode. I have one app in the app store and really at the moment my skill level might be someone who is coding in XCode as a hobby.

    Can you point me to a resource that shows me how to create the objects from an xml schema?

    By "serialize" i mean the ability to pass a Business Object (just NSObject really) and return the xml representation.

    By "automatically" i mean the serializer would either look at properties decorated with attributes or it would reference the xml schema to map the xml representation.

    I write windows apps, wcf web services, and asp.net web apps from visual studio.

    What i can do in visual studio is this (this whole process would take about 5 minutes to wire up everything):
    1.) Create a simple web service with one method exposed (let's say Prospect GetProspect()).
    2.) When i "Add a Service Reference", I point to the wsdl url and my business objects and service client is created automatically. In some projects, over 3000+ lines of code can get generated from a wsdl. That is alot of plumbing that i don't have to worry about.
    3.) When i call GetProspect(), the call gets serialized in a soap request then deserialized back into a Prospect object.

    There's no doubt i think cocoa (or cocoa touch) has some great enterprise technologies. But this is all end-user stuff (api's). What i'm really looking for is the proper enterprise dev tools. Like creating business objects and client stubs from a wsdl or create a business object from an xml schema.


    There are two different development strategies here:

    1) Dev's who write apps for customers: These guys have NO choice. If they want to get their business out to customers they are forced to figure out how to support whatever product the customer is using (ie iphone, ipad) no matter what limitations there are. Another example, If you write a web site that real customers use, you better make sure it looks good in firefox and safari or else you could potentially lose business if they visit the web site and it throws up in their browser.

    2) Dev's who write apps for employees (real enterprise): These guys like the technology of the iPad & iPhone. They love the native ui elements. Everything looks pretty!! But you know what, none of that really matters. What the execs want to know is - What is the return on investment. If the app doesn't some how save the company money then it's really a waste. So one thing they look at is development costs. Going back to the web site example. All of our internal web apps support 1 browser and that is IE. We don't really care about firefox or safari. And since our customers are employees, we can lock them into whatever browser (or technology really) that we wish.

    Apple has done a great job making sure the first group is well taken care of. They bring in all this technology for businesses to help customers. The Second group keeps hearing "We Have Enterprise Support" but so far i don't really see it. Apple needs to convince the executives why they should take on their platform. They need to make tools, tools tools. Also the tools need to be supported by Apple and not on some 3rd party forum where support isn't guaranteed. If they could convince the executives (two people measly people) that their platform will bring a great ROI then Apple will have just sold over 1,000 iPads.
     
  4. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
    Hmm, how much of this is done on the server-side and how much would you expect to be done from within a mobile app? Just curious.

    Also, what do you know about WebObjects? I don't know too much about it but I suspect it may be able to address some of your concerns. It's kinda legacy though.
     
  5. vocaro macrumors regular

    Joined:
    Mar 5, 2004
    #5
    Try WSMakeStubs.

    http://macdevcenter.com/pub/a/mac/2003/02/04/omnigene.html?page=2

    If you can't find any built-in code for this, it wouldn't be too hard to do it manually using a DOM-based XML parser such as TouchXML.

    http://github.com/schwa/TouchXML

    Or they can convince executives at a few gaming companies that their platform has a great ROI and they have just sold over 1,000,000 iPads. It's all about what the developers and consumers are asking for, which is why you see frameworks like CoreAnimation, GameKit, etc. on iOS and not a lot of WSDL tools.

    It goes both ways. What would take 3 lines of code in CoreAnimation/iOS would probably take 30 in C#/Windows.
     
  6. TeeJayEm thread starter macrumors regular

    Joined:
    Mar 28, 2008
    #6
    Hey dejo, thanks for the link. On the surface, it looks like a tool to produce web services, not consume them. I will definitely research this further!

    For the first thought, You really only need to write the code once. This includes exposed methods, Business Objects, Business logic (in general).

    This WSDL from amazon (this will download if you click it) is something that could be generated. What clients do is then take this document and use whatever tool (JBossWS for java, WcfSvcUtil for .NET, etc) and creates compatible classes in whatever language.
     
  7. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #7
    So, it sounds to me like you are looking for tools to help you produce web services, server-side. That's not really in the purvey of iPhone/iPad Programming then. And it sounds like you already have those tools. You can use them to create standards-based SOAP or RESTful services and then the client (i.e. the iPad) would consume those services. Or am I barking up the wrong tree?
     
  8. TeeJayEm thread starter macrumors regular

    Joined:
    Mar 28, 2008
    #8
    I tried this before and the result didn't compile. I'll check it out again to be sure.

    WOW thanks for the link on this one. It looks real promising.

    Yeah, i definitely agree with what you're saying but that isn't really enterprise support IMO. Apple really is trying to target companies to create Business Apps for their Employee's - http://www.apple.com/iphone/business/profiles/. In fact, two reps are coming later this week to discuss all these "pretty things" that the iPad can do for the enterprise. And i know, what i'm going to hear is "we can print" and "vpn yeah!!". I just honestly think they are missing the mark.

    I agree with what your saying. I'm not trying to take anything away from API's in iOS. Animation's look tons smoother on an iPad than what a WPF application would look on a pc. I'm really only talking about tools. While i think Visual Studio (.NET) has hit it when it comes to enterprise, it really sucks for serving consumers (unless it's web based development). The .NET framework isn't something that should be considered when developing solutions for real customers. For example, you can't sell your CD Burning software for $49.99 then ask the customer to download a 120mb framework to get it running. But in enterprise world, we can push the framework (through software delivery) directly to the PC and not have to worry about it again.

    Sorry, i don't think i wrote that right. I have the web services out there in production already. I have windows, web apps (asp.net and cold fusion), and java apps are talking through them to an OLD database.

    What i'm talking about is client-side tools to consume a web service. I want to be able to consume those soap services from iPad/iPhone. From what i've read out in google-land, soap support is lacking big time and everyone is suggesting that i use REST based web services. This sucks but it is doable. I can just create a new endpoint on an existing web service to serve up XML documents. The problem is, In XCode, there doesn't seem to be a way to quickly create a Business object that matches an xml schema representation.

    For example if i were to use the xml schema in the original post, the objective-c class representation should look something like this:

    Code:
    @interface Prospect : NSObject {
    
    }
    @property (nonatomic, retain) NSString *Address;
    @property (nonatomic, retain) NSString *AlternamePhone;
    @property (nonatomic, retain) NSString *City;
    @property (nonatomic, retain) NSString *Email;
    @property (nonatomic, retain) NSString *FirstName;
    @property (nonatomic, retain) NSString *LastName;
    @property (nonatomic, retain) NSString *Phone;
    
    //etc.
    
    @end
    Which should be serialized into xml like this:
    Code:
    <Prospect>
    	<FirstName>Alice</FirstName>
    	<LastName>Jenkins</LastName>
    	<!--etc-->
    </Prospect>
    
    Now this example is simple as it only has a few properties but think about an object with over 100 properties. Some of those properties linking to other objects. This plumbing is easy but it's also tedious and time consuming.

    Also what i'd like to do is to be able to convert this object to an xml representation. An early post referred to touchxml. I'll try that one and see what i come up with.
     

Share This Page