Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to send complex type via ksoap2-android to wcf service ? - how to configure wcf service?
    text
    copied!<p>I try to send a complex type via ksoap2-android to a wcf service. Basicly I followed that guide <a href="http://seesharpgears.blogspot.de/2010/10/ksoap-android-web-service-tutorial-with.html" rel="nofollow">http://seesharpgears.blogspot.de/2010/10/ksoap-android-web-service-tutorial-with.html</a> I was able to recieve a complex data type from the web service, but when I try to send one I get the following error:</p> <pre><code>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. </code></pre> <p>The question is how can I solve this ? The error is returned in the envelope. As I did everything as described in the tutorial and receieving complex types work, I think the error is produced on the server side, but unfortunatelly I don't know anything about wcf services. What must I change on the wcf service to get it work ?</p> <p>We tried something like</p> <pre><code>[ServiceKnownType(typeof(EventSeries))] </code></pre> <p>as described in the error message but it didn't help</p> <p>The Method on the web service looks like that</p> <pre><code>public int InsertEventSeriesForAndroidVIntES(EventSeries es) { ... } </code></pre> <p>I attach my android code, just in case I screwed something up.</p> <pre><code>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(); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload