Version of google-http-java-client (e.g. 1.15.0-rc)?
1.16.0-rc
Java environment (e.g. Java 6, Android 2.3, App Engine)?
Java 7
Describe the problem.
Executing the main method of the following class gives a:
java.lang.IllegalArgumentException: unrecognized alias: (default)
(see below for relevant bits of stacktrace)
public class HttpClientNoNamespace {
private static class Foo {
@Key String bar;
}
public static void main(String[] args) throws IOException {
Foo foo = new Foo();
foo.bar = "test";
final HttpTransport trans = new NetHttpTransport();
final HttpRequestFactory fact = trans.createRequestFactory();
final XmlNamespaceDictionary namespaceDictionary = new XmlNamespaceDictionary();
final GenericUrl url = new GenericUrl("http://example.com/rest/api");
fact.buildPutRequest(url, new XmlHttpContent(namespaceDictionary, "Foo", foo)).execute();
}
}
Exception in thread "main" java.lang.IllegalArgumentException: unrecognized
alias: (default)
at com.google.api.client.repackaged.com.google.common.base.Preconditions.checkArgument(Preconditions.java:119)
at com.google.api.client.util.Preconditions.checkArgument(Preconditions.java:69)
at com.google.api.client.xml.XmlNamespaceDictionary.getNamespaceUriForAliasHandlingUnknown(XmlNamespaceDictionary.java:296)
at com.google.api.client.xml.XmlNamespaceDictionary.startDoc(XmlNamespaceDictionary.java:243)
at com.google.api.client.xml.XmlNamespaceDictionary.serialize(XmlNamespaceDictionary.java:229)
at com.google.api.client.xml.XmlNamespaceDictionary.serialize(XmlNamespaceDictionary.java:208)
at com.google.api.client.http.xml.XmlHttpContent.writeTo(XmlHttpContent.java:78)
at com.google.api.client.http.xml.AbstractXmlHttpContent.writeTo(AbstractXmlHttpContent.java:58)
How would you expect it to be fixed?
Well, I don't *want* to provide a namespace. The REST service I'm calling
simply spits the dummy if there are any namespace shenanigans in the root
element of the request entity. Various combinations of:
namespaceDictionary.set("","");
namespaceDictionary.set(null,"");
namespaceDictionary.set("", null);
namespaceDictionary.set(null, null);
don't seem to help me get anywhere.
Either I need more control over how namespaces are treated, or some
factory-level control over the Serializer which an XmlHttpContent passes to
NamespaceDictionary. I don't want to have to extend AbstractHttpContent just
so that I can effectively override AbstractXmlHttpContent#writeTo(OutputStream)
and call writeTo(Serializer) with my own Serializer.
Hope that's clear. Am happy to provide more info.
Original issue reported on code.google.com by david.bu...@machaira.com.au on 5 Sep 2013 at 4:00
Original issue reported on code.google.com by
david.bu...@machaira.com.au
on 5 Sep 2013 at 4:00