Я пытаюсь отправить сложный тип через 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)
{
...
}
Прикрепляю свой код андроида, на случай, если я что-то напортачил.
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();