The soap that I want is like this:
<int:userId>......</int:userId>
This is tested in SoapUI and with this I get the proper response back.
What Ksoap makes is this:
<userId i:type="n0:undefined" xmlns:n0="http://namespace.com">.....</userId>
If I where to paste this code into SoapUI I get an error
'<Message>Error in line 5 position 88. Element 'http://namespace.com:
userId'
contains data of the 'http://namespace.com:undefined' data contract.
The deserializer has no knowledge of any type that maps to this contract.
Add the type corresponding to 'undefined' to the list of known types -
for example, by using the KnownTypeAttribute attribute or by
adding it to the list of known types passed to DataContractSerializer.
</Message>
Maybe I am looking in the wrong direction for the solution but I am now asking how can I make ksoap omit the i:type part. If anyone can provide a different sollution, you will have my thank.
KSoap does have a tendancy to insert its own namespaces into each tag, which can give the output you're seeing.
I had a similar such problem, which was easily resolved using the following :
envelope.implicitTypes = true;
Please also have a look at this other question on SO.
Related
In all the data-binding examples that shows Generic data type handling developer.android.com uses real char < and >.
but when it comes to reality
I am getting below error.
The value of attribute "type" associated with an element type
"variable" must not contain the '<' character.
I've searched the web and found people use > for > and < for < as a fix.
Questions
Is this supposed to happen ? If yes why it's not mentioned in the docs ?
Is there any fix for this, where I can write the layout as given in the official docs? (without using corresponding html entity characters)
There's unlikely to be a change to this because layout files are still XML, this isn't really the fault of Android or DataBinding, you're going to need to use appropriate encoding for HTML entities within an XML document.
Using < isn't that terrible as a fix, as far as resolutions go, but if you'd rather avoid using it, then it may be an option to simplify your binding expressions to move logic away from the layout and into your variables.
The current advised method of doing so is with a ViewModel, which can be bound to the layout and expose observable LiveData values.
I can't give you a reason for it not being in the documentation besides that it's probably just not advised to do so.
Now they've updated the documentation
The screenshot in the link below shows the parameters which I will put to a POST request using Alamofire in Swift.
My question is: How can I do the same thing using OkHttp in Kotlin? How can I add "data" as a key and a whole map of user details as a single value?
I have googled around for a while and everything just ends up adding each key-value pair into a FormBody.
This is my first time asking a question on StackOverflow so if there is anything wrong with my language, please kindly tell me so that I can fix it.
Thank you
Within Retrofit, you can pass an Object as your #Body tag.
For example, you can add a new user with something like this.
#POST("users")
fun add(#Body user: User): Observable<User>
It will use GSON to serialize your data for you, and will make json that matches your model.
I'm sitting there for quite a while now, trying to process my xml file (similar to the one below). I want to check all tags, if is equal to a variable, and if so, then running readEntry() on the tag.
I followed this example: https://developer.android.com/training/basics/network-ops/xml.html
I also found this Article(Difficulty with XML nested tags with XMLPullParser in Android deals with this topic.
I have already tried a few things but get either nothing or XmlPullParserException.
A Example of my XML:
<VpMobil>
<Kopf>
...
</Kopf>
<FreieTage>
...
</FreieTage>
<Klassen>
<Kl>
<Kurz>5</Kurz>
<Pl>
<Std>
<St>1</St>
<Fa>Fa1</Fa>
<Le>NAME</Le>
<Ra>1009</Ra>
<Nr>131</Nr>
<If/>
</Std>
<Std>
<St>2</St>
<Fa>Fa2</Fa>
<Le>NAME</Le>
<Ra>1004</Ra>
<Nr>132</Nr>
<If/>
</Std>
</Pl>
</Kl>
<Kl>
<Kurz>6</Kurz>
<Pl>
<Std>
<St>1</St>
<Fa>Fa2</Fa>
<Le>NAME</Le>
<Ra>1046</Ra>
<Nr>131</Nr>
<If/>
</Std>
<Std>
<St>2</St>
<Fa>Fa3</Fa>
<Le>NAME</Le>
<Ra>1012</Ra>
<Nr>132</Nr>
<If/>
</Std>
</Pl>
</Kl>
</Klassen>
</VpMobil>
I would be very grateful if someone could explain to me how I can achieve this. Thanks in advance
You can use Jackson library to parse XML, it is as easy as parsing Json File. this tuto will help you to figure out.
However, bescause it is is a nested xml, you will need some nested POJOs to achieve parsing.
After a few more unsuccessful attempts, I got the idea to convert the XML into a JSON (Convert XML to JSON object in Android) and continue working with it. That worked then.
How do I pass the arraylist to google cloud endpoint? It doesn't seem to work.
Edit start ----
Here is the signature of the endpoint with arraylist as input
public CollectionResponse<String> listDevices(#Named("devices") ArrayList<String> devices)
However when I iterate over this arraylist, I get all the records condensed into one. So even though I pass 10 strings, I get only one in my endpoint.
Edit end ----
I read somewhere that I should create a wrapper entity for arraylist and then pass it.
Edit start ----
So I created the entity containing the arraylist
#Entity
public class DEviceList {
ArrayList<String> devices;
}
and modified the signature as -
public CollectionResponse<String> listDevices(DeviceList devices)
Is it possible to pass object of DeviceList from client even though it not #Named? Can you provide the syntax?
My understanding is that since it's an entity it cannot be #Named, so while calling I need to inject it.
But google allows only three injected types -
1. com.google.appengine.api.users.User
2. javax.servlet.http.HttpServletRequest
3. javax.servlet.ServletContext
So above signature would not work.
So I changed the signature to -
public CollectionResponse<String> listDevices(HttpServletRequest request)
and inside I could get the entity as
DeviceList deviceList = (DeviceList)request.getAttribute("deviceList");
However I am not sure how to call this endpoint from the android client?
How I do pass the entity object using HTTPServletRequest?
Edit end ----
How do I do that? Can anyone cite an example?
The way you word your question, it seems the call is silently failing. That can't be. You must be receiving some kind of exception or log somewhere which could help you identify your issue better. You could read this article to refresh on cloud endpoint APIs and android.
If you are having trouble passing an arraylist of objects from your client to the API, I would suggest checking some things:
does the argument type in the API match what is being sent from the client? Do they both have access to the class definition?
if the data type inside the arraylist is a primitive, and it still fails, perhaps the advice you read "somewhere" was referring to the need (although I don't think this is the case) to use a wrapper object which simply contains one field - the arraylist, and pass that along the line?
If either the reminder to check your logs/error messages or any other info in this answer helped you resolve the issue, please remember to accept it, but not without first editing your post to explain how you resolved your issue.
I need to get data from an XML file in Android. On the iPhone environment, my code is:
NSURL *thisURL = [[NSURL alloc] initWithString:#"http://www.xxx.com/file.xml"];
NSArray *myArray = [[NSArray alloc] initWithContentsOfURL:providerURL];
myArray is now an array of dictionary items initialized with contents from file.xml.
Is there any way to do this in Android? Can someone point me to doc or sample code?
I'm new to the Android environment and just need some direction.
Thanks,
Kevin
See Working with XML in Android for a variety of methods for dealing with XML. Which method to use depends on how big your XML is, and what you want to do with it. '
I'm not sure how it makes any sense to turn XML into an array, so no, none of the methods do that. If you want something similar to that, use Json instead of XML.
After a bit of research, it appears to me that using the Simple XML Serialization framework is going to be my best bet, especially since I do have a relatively simple XML file to read. The result will be a 'list' class with several 'entry' classes which seems like a viable way to handle this...probably better than having an array of classes as was done in the iPhone app.