Dailycode.info

Short solution for short problems

iOS : passing < (smaller then or less then) as SOAP parameter

I was passing queries from the client to the server to fill up objects. In the queries, sometimes the < sing appeared. when it did, the query string parameter did not reached the server. So I found this solution on stackoverflow. 

Just embed the querystring in CDATA tag like this:

NSString * parsedQuery = [NSString stringWithFormat:@"<![CDATA[\n%@\n]]>",query];

 

So now you can pass a query like this to your web service:


NSString * query = [NSStringstringWithFormat:@"SELECT * FROM PlanOrders AS pl  LEFT OUTER JOIN ERP_Customers AS cu ON pl.Client = cu.Client AND pl.CustomerID = cu.Customer  inner join Orders o on pl.SalesOrder = o.SalesOrder and pl.Client = o.Client and pl.Plant = o.Plant  WHERE pl.Client = '%@' AND pl.Plant = '%@' AND pl.PlanDate IS NOT NULL AND pl.PlanDate >= '%@'  AND pl.PlanDate < dateadd(day,1,'%@') AND (pl.PlanStatus < 100)  ORDER BY pl.PlanDate",store.Client, store.Plant,[formatter stringFromDate:self.dateFrom],[formatter stringFromDate:self.dateTo]];


NSString * parsedQuery = [NSString stringWithFormat:@"<![CDATA[\n%@\n]]>",query];

[service ExecuteQueryForiOS:self action:@selector(getPlanning:) commandText:parsedQuery];