Add CDATA Section in Existing XML String in Swift 3.0/ObjectiveC - ios

I have xml/xml string as response that I am getting from one API, Now I need to send this xml in another API with CDATA section. So my question is, How Can I add CDATA section in existing XML or XML String.
This scenario is in Soap API in Swift 3.0.

Below is the xml
Code
<tem:InputSTR><![CDATA[ This is where you put your xml ]]></tem:InputSTR>
Please provide some code next time you post some question it will be more easy others to help you.

Related

How can I bold part of a string from JSON in Swift?

I have a JSON file like this. I have to make bold part of string which is shown in JSON. How can I make parse this JSON?
It looks to me like you would first want to use NSJSONSerialization (Or just JSONSerialization in Swift 3) to convert your JSON to an object graph. Once you've done that, you should be able to navigate to the interestLabel keys in your data and fetch those strings.
You'll then need to parse those tagged strings somehow. If the only thing you need to do is to find <b> and </b> bold tags, and no other tags will ever appear in your data then you could probably write your own code. If the strings might have other tags and/or more complex HTML structure then you might want to use an XML/HTML parser. I suggest taking a look at this tutorial: https://www.raywenderlich.com/14172/how-to-parse-html-on-ios

iPhone - How to post and get xml data to server?

I want to get xml string from url "http://test.php?value=xxx",here xxx shall be in XML format,for example:<request><command>test</command></request>.After I post this,the server will give me a result with xml string.But i don't know how to do that.Anyone has a solution?Thanks.
http://www.raywenderlich.com/30445/afnetworking-crash-course
That website gives you a step by step exactly what you need with AFNetworking. The question you are asking is very vague. If you get more specific then I can give direct code. Otherwise that crash course website is very informative.

Returning JSON format from ASP.NET web API

I know this question is been discussed many times but for me those solutions are not working. I want to return JSON data from my ASP.NET web API. I am hitting the end point using Firefox REST client plugin.
What I have tried:
I have specific accept header : Accept: application/json. Use accept header
Removed the XML formatter on Application_Start method
var formatters = GlobalConfiguration.Configuration.Formatters;
formatters.Remove(formatters.XmlFormatter);
This is how I return data at the end
return myModel.OrderBy(d => d.SortOrder);
Where myModel is just a class with few public property. I am not decorating this class or its property with any attribute.
But these two approach's are not working. I am still getting data in XML format :(
Please provide your suggestions.
I would like to introduce you to http://www.servicestack.net/
This is rest API framework that hooks up with .net.
It does everything what you require .
https://docs.google.com/presentation/d/16ey0MrpHOSz5N5sjctAliOgYWO3ZYeJe070fLZlPdrE/present#slide=id.i27
FROM COMMENT
Check that the application/json header is the first header and has a q=1 quality attribute: "application/json;q=1".
You can read more about quality attributes in the specs. Basically they are a way for a client of providing a preference system on the returned datatype.
To answer your other question (when I have explicitly removed the XML format in the code, why I was getting the data in XML format?), I can only guess what was going on: either the header was not setup correctly or the client was defaulting the other header to a different quality value.
Another guess could be that your way of removing the formatter is wrong: you can check this answer on SO or this article for alternative methods and see if they do the trick for you as well.

JSoup does not post data in ISO 8859 encoding

Is there any way to tell JSoup to post data using iso-8859-1 rather than utf-8 ?
I tried posting a parameter that contains the letter 'è' the my webserver receives the character with hex code C3A8 but I want to send E8.
The code I wrote is
Document document = Jsoup.connect("https://somesite.com/test") .data("parameter1","\u00E8").
header("Content-Type","application/x-www-form-urlencoded;charset=UTF-8")
.method(Method.POST)
.execute()
.parse();
As already said, on the other hand I get a 2 bytes data (C3A8) rather than a single byte with E8 inside.
Thanks in advance for your help.
Trying to replicate a successful POST request with JSoup - data posted to server does not get decoded
Has an accepted answer, saying it is not possible to do it. You will have to find a way to post your code into utf-8. If you do not succeed in that, just open a new question about it.

Assembling SOAP Header manually with Savon

I've been dealing with a "soap message header incorrect" error message when submiting a SOAP request using Savon.
I copy/pasted the exact same xml generated by Savon into SOAPUI and I don't get that error and I get the expected response.
So, since I'm tired of trying different things, I want to assemble my own header without Savon help on that.
What I want to do is something like:
soap.header = "<wbs:Session><wbs:SessionId></wbs:SessionId><wbs:SequenceNumber></wbs:SequenceNumber></wbs:Session>"
However I get this error from Savon:
can't convert Symbol into String
Why?
Thank you in advance.
Its likely caused by the fact you havent set any values.
I was getting this error when I had a hash containing just one custom object on return, as it was trying to access parts of the hash that had automatically been removed. (it removed unnesscary layer of hash for me :#)
I believe the header will only accept a Hash - from the savon.rb page:
Besides the body element, SOAP requests can also contain a header with
additional information. Savon sees this header as just another Hash following
the same conventions as the SOAP body Hash.
soap.header = { "SecretKey" => "secret" }

Resources