我想打电话从Android的一个SOAP .NET Web服务上,需要包含一个这样的元素(从.NET Web服务客户端生成)的请求:KSOAP - 请求与属性属性和名称空间的价值
<InputVariable>
<Id>MyVariable</Id>
<Value i:type="a:string" xmlns:a="http://www.w3.org/2001/XMLSchema">Hello</Value>
</InputVariable>
这里有一些奇怪的事情,kSOAP似乎并不直接支持。其一,我在kSOAP中找不到一种方法来生成一个也有属性的属性。我发现this answer能够让我进一步,但仍然不确切。以下是我得到与解决方案:
<InputVariable>
<Id>MyVariable</Id>
<Value i:type="http://www.w3.org/2001/XMLSchema:string">Hello</Value>
</InputVariable>
SoapObject inputVariable = new SoapObject("", "InputVariable");
inputVariable.addProperty("Id", "MyVariable");
AttributeInfo att = new AttributeInfo();
att.setName("type");
att.setNamespace("http://www.w3.org/2001/XMLSchema-instance");
// I need some way to set the value of this to a namespaced string
att.setValue("http://www.w3.org/2001/XMLSchema:string");
ValueSoapObject valueProperty = new ValueSoapObject("", "Value");
valueProperty.setText("Hello");
valueProperty.addAttribute(att);
inputVariable.addSoapObject(valueProperty);
在运行时,服务器因错误而失败,它不能反序列化: Value' contains data from a type that maps to the name '://www.w3.org/2001/XMLSchema:string'. The deserializer has no knowledge of any type that maps to this name.
我怎么能产生这种类型SOAP属性使用kSOAP for Android?
这工作!至少,解析问题。现在我遇到了这个http://stackoverflow.com/questions/10014164/android-ksoap2-nullable-type,但那个答案也有效。谢谢! – Travis