0

I am getting the data from .net web server like this.

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GenericAndroidMethodResponse xmlns="Mortgage"><GenericAndroidMethodResult>&lt;NewDataSet&gt;
  &lt;Table&gt;
    &lt;LoanOfficerID&gt;3581&lt;/LoanOfficerID&gt;
    &lt;FirstName&gt;Venkat&lt;/FirstName&gt;
    &lt;LastName&gt;Sreenu&lt;/LastName&gt;
    &lt;Address1&gt;d&lt;/Address1&gt;
    &lt;City&gt;d&lt;/City&gt;
    &lt;State&gt;Alabama&lt;/State&gt;
    &lt;WorkPhone&gt;19999999999&lt;/WorkPhone&gt;
    &lt;Country&gt;United States&lt;/Country&gt;
    &lt;EmailAddress&gt;ensisinfo@ensis.com&lt;/EmailAddress&gt;
    &lt;companyName&gt;ensisinfo&lt;/companyName&gt;
    &lt;CompanyURL&gt;www.ensisinfo.com&lt;/CompanyURL&gt;
  &lt;/Table&gt;
&lt;/NewDataSet&gt;</GenericAndroidMethodResult></GenericAndroidMethodResponse></soap:Body></soap:Envelope>  

But I test in browser by passing xml parameters and method name I am getting like this.

<NewDataSet> <Table> <LoanOfficerID>3581</LoanOfficerID> <FirstName>Venkat</FirstName> <LastName>Sreenu</LastName> <Address1>d</Address1> <City>d</City> <State>Alabama</State> <WorkPhone>19999999999</WorkPhone> <Country>United States</Country> <EmailAddress>ensisinfo@ensis.com</EmailAddress> <companyName>ensisinfo</companyName> <CompanyURL>www.ensisinfo.com</CompanyURL> </Table> </NewDataSet>

I am using NSUrlRequest

NSURL *url = [NSURL URLWithString:@"http://173.31.193.92/MobileGenericWebservice/GenericWebService.asmx"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]];

[theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue: @"Mortgage/GenericAndroidMethod" forHTTPHeaderField:@"SOAPAction"];
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];

why I am getting like this?

eglease
  • 2,445
  • 11
  • 18
  • 28
Mahesh Babu
  • 3,395
  • 9
  • 48
  • 97

2 Answers2

1

In the XML are all of those &lt; and other codes visible like in your example?
If they are then the entire element is just getting parsed as one, giant string that is in the <GenericAndroidMethodResult> node.

Walter
  • 5,867
  • 2
  • 30
  • 43
  • then how can i resolve it,i need individual,how can i convert these &lt to – Mahesh Babu Feb 24 '11 at 11:09
  • There is an NSString method "stringByReplacingOccurencesofString" that would let you modify the symbols. You could write a function that goes through the string and "fixes" it. Then you could parse that string. Or you could just scan the string and extract out the data you need. – Walter Feb 24 '11 at 12:35
  • i try stringByReplacingOccurencesofString but no change – Mahesh Babu Feb 25 '11 at 05:25
  • So, you did stringByReplacingOccureencesOfString for both the LT and the GT, BEFORE you fed the string to the parser? At that point I would say you have to just scan the string and pick out your pieces, or get the server to give you properly formed XML. The real issues is that you are not getting good XML to start with. – Walter Feb 25 '11 at 11:36
0

Tell your .NET guy to fix it. What you are getting is not a valid XML.

Vaibhav Tekam
  • 2,344
  • 3
  • 18
  • 27