Я пытаюсь отправить комплексный тип через ksoap2-android в сервис wcf.В основном я следовал этому руководству http://seesharpgears.blogspot.de/2010/10/ksoap-android-web-service-tutorial-with.html Мне удалось получить сложный тип данных из веб-службы, но при попытке отправить его я получаю следующую ошибку:
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))]
, как описано в сообщении об ошибке, но это не помогло
Метод в веб-сервисе выглядит так:
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();