0

I am developing an application in which I am consuming SOAP response using TBXML parser. But the issue I am facing is that the SOAP response in not coming in proper XML format. Following is the SOAP response that I am receiving:

 <?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.or
 /soap/envelope/"><S:Body><ns2:getNotificationCountResponse xmlns:ns2="http://wfnwebservice.oi.com
 /"><return>&lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt;&lt;Results&gt;&lt;Row&gt;&
 lt;MESSAGE_TYPE&gt;REQAPPRV&lt;/MESSAGE_TYPE&gt;&lt;NOTIFICATION_CNT&gt;2&lt;   
 /NOTIFICATION_CNT&gt;&lt;WORKFLOW_NAME&gt;Purchase Requisition&lt;/WORKFLOW_NAME&gt;&lt;
 /Row&gt;&lt;Row&gt;&lt;MESSAGE_TYPE&gt;POAPPRV&lt;/MESSAGE_TYPE&gt;&lt;NOTIFICATION_CNT&gt;4&lt;
 /NOTIFICATION_CNT&gt;&lt;WORKFLOW_NAME&gt;Purchase Order&lt;/WORKFLOW_NAME&gt;&lt;/Row&gt;&lt;
 /Results&gt;</return></ns2:getNotificationCountResponse></S:Body></S:Envelope>

The SOAP request message is as follow,

 NSString *soapMsg = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\
                     <S:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\"   
 xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">\
                     <SOAP-ENV:Header/>\
                     <S:Body>\
                     <ns2:getNotificationCount xmlns:ns2=\"http://wfnwebservice.oi.com/\">\
                     <arg0>CBAKER</arg0>\
                     </ns2:getNotificationCount>\
                     </S:Body>\
                     </S:Envelope>"];

Can any one please let me know what is an issue and how can I solve it????

Shital Tiwari
  • 175
  • 2
  • 3
  • 17

1 Answers1

0

// Pass your url is here

Use NSXml parser first you need to declare the NSXmlParser Delegate in .h. and then try this code

NSString * urlString = [NSString stringWithFormat:@"http://www.webservicex.net/globalweather.asmx/GetCitiesByCountry?CountryName=%@",CountryName];

NSLog(@"%@",urlString);

NSMutableURLRequest * req = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlString]];

NSData * data  = [NSURLConnection sendSynchronousRequest:req returningResponse:nil error:nil];

NSLog(@"%@",data);

xmlResultString = [[NSMutableString alloc]init];

NSLog(@"%@",xmlResultString);

parser = [[NSXMLParser alloc]initWithData:data];
[parser setDelegate:self];
[parser parse];

   // return result;

}

-(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{

    xmlDictionary=[[NSDictionary alloc]init];

    [xmlResultString appendString:[string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]];

    NSLog(@"%@",xmlResultString);

    xmlDictionary = [XMLReader dictionaryForXMLString:xmlResultString error:nil];

}
-(void)parserDidEndDocument:(NSXMLParser *)parser
{

    NSLog(@"%@",xmlDictionary);

    NSArray * City=[[NSArray alloc]init];

    NSString* city =[[[xmlDictionary valueForKey:@"NewDataSet"] valueForKey:@"Table"] valueForKey:@"City"];

    NSLog(@"%@",city);

    City=[[[xmlDictionary valueForKey:@"NewDataSet"] valueForKey:@"Table"] valueForKey:@"City"];

    NSLog(@"%@",City);
}



-(void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError
{
    result = 0;
    NSLog(@"%@",parseError);

}
Jitendra
  • 5,055
  • 2
  • 22
  • 42
  • thank you for your response but it is our requirement to use TBXML for parsing and SOAP message for request... so can you please give me solution – Shital Tiwari Oct 08 '13 at 05:55