WSDL JSON parsen

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • WSDL JSON parsen

    Hallo Leute,
    ich hoffe ich bin hier im richtigen Bereich. Wenn nicht bitte verschieben.

    Also es geht um das folgende Problem:

    Ich schreiben im Rahmen einer Vorlesung eine App, genauer ausgedrückt eine FH-App. Mit der App soll man die Möglichkeit haben sich Stundenpläne, Mensapläne etc. anzeigen zu lassen usw..

    Leider ist die Unterstützung (im ObjC Bereich) sehr gering, ja fast sogar keine. Da wird man von einem zum anderen weitergeleitet.

    Also jetzt aber zum Problem:

    Ich versuche mit WSDL die Daten vom Server zu holen, was auch eigentlich klappt, nur ich weiß nicht was ich mit der Ausgabe genau anfangen soll. WSDL.. Klassen mit Sudzc erstellt. Beispielprojekt klappt wunderbar und bekomme ne ausgabe.

    Quellcode

    1. p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo}
    2. http://ws.inf.fh-dortmund.de/TimeTableBeanService/TimeTableBean
    3. 2011-06-03 11:18:10.594 SudzCExamples[5661:207]
    4. 2011-06-03 11:18:10.779 SudzCExamples[5661:207] {"BRANCHES": [
    5. {
    6. "NAME": "Master Informatik (29.03.2011)",
    7. "ID": 0
    8. },
    9. {
    10. "NAME": "Master Medizinische Inf. (29.03.2011)",
    11. "ID": 1
    12. },
    13. {
    14. "NAME": "Master Wirtschaftsinformatik (08.03.2011)",
    15. "ID": 2
    16. },
    17. {
    18. "NAME": "Medizinische Inf. 2. Sem. (28.01.2011)",
    19. "ID": 3
    20. },
    21. {
    22. "NAME": "Medizinische Inf. 4. Sem. (24.01.2011)",
    23. "ID": 4
    24. },
    25. {
    26. "NAME": "Medizinische Inf. 6. Sem. (25.03.2011)",
    27. "ID": 5
    28. },
    29. {
    30. "NAME": "Praktische Inf. 2. Sem. (08.03.2011)",
    31. "ID": 6
    32. },
    33. {
    34. "NAME": "Praktische Inf. 4. Sem. (10.02.2011)",
    35. "ID": 7
    36. },
    37. {
    38. "NAME": "Praktische Inf. 6. Sem. (25.03.2011)",
    39. "ID": 8
    40. },
    41. {
    42. "NAME": "Softwaretechnik dual 2. Sem. (17.05.2011)",
    43. "ID": 9
    44. },
    45. {
    46. "NAME": "Technische Inf. 2. Sem. (08.03.2011)",
    47. "ID": 10
    48. },
    49. {
    50. "NAME": "Technische Inf. 4. Sem. (10.02.2011)",
    51. "ID": 11
    52. },
    53. {
    54. "NAME": "Technische Inf. 6. Sem. (25.03.2011)",
    55. "ID": 12
    56. },
    57. {
    58. "NAME": "Wirtschaftsinf. 2. Sem. (10.02.2011)",
    59. "ID": 13
    60. },
    61. {
    62. "NAME": "Wirtschaftsinf. 4. Sem. (28.01.2011)",
    63. "ID": 14
    64. },
    65. {
    66. "NAME": "Wirtschaftsinf. 6. Sem. (25.03.2011)",
    67. "ID": 15
    68. }
    69. ]}
    70. 2011-06-03 11:18:10.781 SudzCExamples[5661:207] getCurrentBranches returned the value: {
    71. return = "{\"BRANCHES\": [\n {\n \"NAME\": \"Master Informatik (29.03.2011)\",\n \"ID\": 0\n },\n {\n \"NAME\": \"Master Medizinische Inf. (29.03.2011)\",\n \"ID\": 1\n },\n {\n \"NAME\": \"Master Wirtschaftsinformatik (08.03.2011)\",\n \"ID\": 2\n },\n {\n \"NAME\": \"Medizinische Inf. 2. Sem. (28.01.2011)\",\n \"ID\": 3\n },\n {\n \"NAME\": \"Medizinische Inf. 4. Sem. (24.01.2011)\",\n \"ID\": 4\n },\n {\n \"NAME\": \"Medizinische Inf. 6. Sem. (25.03.2011)\",\n \"ID\": 5\n },\n {\n \"NAME\": \"Praktische Inf. 2. Sem. (08.03.2011)\",\n \"ID\": 6\n },\n {\n \"NAME\": \"Praktische Inf. 4. Sem. (10.02.2011)\",\n \"ID\": 7\n },\n {\n \"NAME\": \"Praktische Inf. 6. Sem. (25.03.2011)\",\n \"ID\": 8\n },\n {\n \"NAME\": \"Softwaretechnik dual 2. Sem. (17.05.2011)\",\n \"ID\": 9\n },\n {\n \"NAME\": \"Technische Inf. 2. Sem. (08.03.2011)\",\n \"ID\": 10\n },\n {\n \"NAME\": \"Technische Inf. 4. Sem. (10.02.2011)\",\n \"ID\": 11\n },\n {\n \"NAME\": \"Technische Inf. 6. Sem. (25.03.2011)\",\n \"ID\": 12\n },\n {\n \"NAME\": \"Wirtschaftsinf. 2. Sem. (10.02.2011)\",\n \"ID\": 13\n },\n {\n \"NAME\": \"Wirtschaftsinf. 4. Sem. (28.01.2011)\",\n \"ID\": 14\n },\n {\n \"NAME\": \"Wirtschaftsinf. 6. Sem. (25.03.2011)\",\n \"ID\": 15\n }\n]}";
    72. }
    Alles anzeigen


    logging aktiviert.

    ich versuche seit tagen die Ausgabe irgendwie mit JSON zu parsen jedoch ohne erfolg.

    Example.m

    Quellcode

    1. - (void)run {
    2. // Create the service
    3. wsTimeTableBeanService* service = [wsTimeTableBeanService service];
    4. service.logging = YES;
    5. // Returns id.
    6. //[service getActivitiesByDay:self action:@selector(getActivitiesByDayHandler:)];
    7. // Returns id.
    8. //[service getActivitiesForWeek:self action:@selector(getActivitiesForWeekHandler:)];
    9. // Returns id.
    10. [service getCurrentBranches:self action:@selector(getCurrentBranchesHandler:)];
    11. // Returns id.
    12. //[service getStaffByAbbreviation:self action:@selector(getStaffByAbbreviationHandler:)];
    13. // Returns id.
    14. //[service getStaffList:self action:@selector(getStaffListHandler:)];
    15. // Returns id.
    16. //[service initialize:self action:@selector(initializeHandler:)];
    17. }
    18. // Handle the response from getActivitiesByDay.
    19. - (void) getActivitiesByDayHandler: (id) value {
    20. // Handle errors
    21. if([value isKindOfClass:[NSError class]]) {
    22. NSLog(@"%@", value);
    23. return;
    24. }
    25. // Handle faults
    26. if([value isKindOfClass:[SoapFault class]]) {
    27. NSLog(@"%@", value);
    28. return;
    29. }
    30. // Do something with the id result
    31. id result = (id)value;
    32. NSLog(@"getActivitiesByDay returned the value: %@", result);
    33. }
    34. // Handle the response from getActivitiesForWeek.
    35. - (void) getActivitiesForWeekHandler: (id) value {
    36. // Handle errors
    37. if([value isKindOfClass:[NSError class]]) {
    38. NSLog(@"%@", value);
    39. return;
    40. }
    41. // Handle faults
    42. if([value isKindOfClass:[SoapFault class]]) {
    43. NSLog(@"%@", value);
    44. return;
    45. }
    46. // Do something with the id result
    47. id result = (id)value;
    48. NSLog(@"getActivitiesForWeek returned the value: %@", result);
    49. }
    50. // Handle the response from getCurrentBranches.
    51. - (void) getCurrentBranchesHandler: (id) value {
    52. // Handle errors
    53. if([value isKindOfClass:[NSError class]]) {
    54. NSLog(@"%@", value);
    55. return;
    56. }
    57. // Handle faults
    58. if([value isKindOfClass:[SoapFault class]]) {
    59. NSLog(@"%@", value);
    60. return;
    61. }
    62. // Do something with the id result
    63. id result = (id)value;
    64. NSLog(@"getCurrentBranches returned the value: %@", result);
    65. }
    66. // Handle the response from getStaffByAbbreviation.
    67. - (void) getStaffByAbbreviationHandler: (id) value {
    68. // Handle errors
    69. if([value isKindOfClass:[NSError class]]) {
    70. NSLog(@"%@", value);
    71. return;
    72. }
    73. // Handle faults
    74. if([value isKindOfClass:[SoapFault class]]) {
    75. NSLog(@"%@", value);
    76. return;
    77. }
    78. // Do something with the id result
    79. id result = (id)value;
    80. NSLog(@"getStaffByAbbreviation returned the value: %@", result);
    81. }
    82. // Handle the response from getStaffList.
    83. - (void) getStaffListHandler: (id) value {
    84. // Handle errors
    85. if([value isKindOfClass:[NSError class]]) {
    86. NSLog(@"%@", value);
    87. return;
    88. }
    89. // Handle faults
    90. if([value isKindOfClass:[SoapFault class]]) {
    91. NSLog(@"%@", value);
    92. return;
    93. }
    94. // Do something with the id result
    95. id result = (id)value;
    96. NSLog(@"getStaffList returned the value: %@", result);
    97. }
    98. // Handle the response from initialize.
    99. - (void) initializeHandler: (id) value {
    100. // Handle errors
    101. if([value isKindOfClass:[NSError class]]) {
    102. NSLog(@"%@", value);
    103. return;
    104. }
    105. // Handle faults
    106. if([value isKindOfClass:[SoapFault class]]) {
    107. NSLog(@"%@", value);
    108. return;
    109. }
    110. // Do something with the id result
    111. id result = (id)value;
    112. NSLog(@"initialize returned the value: %@", result);
    113. }
    114. @end
    Alles anzeigen


    ich hoffe ihr könnt mir hier weiterhelfen. bin echt verzweifelt.


  • A strict JSON parser and generator for Objective-C

    JSON (JavaScript Object Notation) is a lightweight data-interchange
    format. This framework provides two apis for parsing and generating
    JSON. One standard object-based and a higher level api consisting of
    categories added to existing Objective-C classes.

    Learn more on the code.google.com/p/json-framework project site.

    This framework does its best to be as strict as possible, both in what it
    accepts and what it generates. For example, it does not support trailing commas
    in arrays or objects. Nor does it support embedded comments, or
    anything else not in the JSON specification. This is considered a feature.



    Hier findest Du ein Link für Objective-C / JSON: code.google.com/p/json-framework/


    Quellcode

    1. SBJSON *parser = [[SBJSON alloc] init];
    2. NSDictionary *jsonArray = [parser objectWithString:responseString error:&error];
    3. ...


    Wobei responseString die zu parsende Ausgabe ist ...
    Si tacuisses, philosophus mansisses !