我尝试通过ksoap2-android将复杂类型发送到wcf服务。 Basicly我遵循的指导http://seesharpgears.blogspot.de/2010/10/ksoap-android-web-service-tutorial-with.html 我能够收到来自Web服务的复杂数据类型,但是当我尝试发送一个我得到以下错误:如何通过ksoap2-android发送复杂类型到wcf服务? - 如何配置wcf服务?
a:DeserializationFailed
The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:es.
The InnerException message was 'Error in line 1 position 373. Element 'http://tempuri.org/:es' contains data from a type that maps to the name 'http://tempuri.org/:EventSeries'.
The deserializer has no knowledge of any type that maps to this name.
Consider using a DataContractResolver or add the type corresponding to 'EventSeries' 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.'.
Please see InnerException for more details.
的问题是如何解决这个?该错误在信封中返回。 由于我完成了本教程中描述的所有工作,并且接受了复杂类型的工作,我认为错误是在服务器端产生的,但不幸的是我对wcf服务一无所知。我必须改变wcf服务才能使其工作?
我们试图像
[ServiceKnownType(typeof(EventSeries))]
的错误消息进行确认,但并没有帮助
的方法对Web服务看起来像
public int InsertEventSeriesForAndroidVIntES(EventSeries es)
{
...
}
我附上我的android代码,以防万一我搞砸了。
SoapObject request = new SoapObject("http://tempuri.org/, "InsertEventSeriesForAndroidVIntES");
EventSeries es = new EventSeries(10, "call Test");
PropertyInfo propertyInfo = new PropertyInfo();
propertyInfo.setName("es");
propertyInfo.setNamespace("http://tempuri.org");
propertyInfo.setValue(es);
propertyInfo.setType(EventSeries.class);
request.addProperty(propertyInfo);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
envelope.addMapping(request.getNamespace(), "EventSeries", EventSeries.class);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call("http://tempuri.org/IDiversityService/InsertEventSeriesForAndroidVIntES", envelope);
SoapPrimitive result = (SoapPrimitive) envelope.getResponse();