WCF Serialization Error Using NetTCP -
using vs2012 , nettcpbinding. getting following error when call servicecontract client - service hosted in iis:
there error while trying serialize parameter cs.servicecontracts.zzzzzz.common:getzipcodesresult. innerexception message 'type 'system.delegateserializationholder+delegateentry' data contract name 'delegateserializationholder.delegateentry:http://schemas.datacontract.org/2004/07/system' not expected. consider using datacontractresolver or add types not known statically list of known types - example, using knowntypeattribute attribute or adding them list of known types passed datacontractserializer.'. please see innerexception more details.
here servicecontract:
[servicecontract(sessionmode = sessionmode.allowed, namespace = "cs.servicecontracts.zzzzzz.common", name = "izzzzzzcommonservice")] public interface izzzzzzcommonservice { [operationcontract] getzipcodesresponse getzipcodes(getzipcodesrequest request); }
here datacontract:
[datacontract] [serializable] public class getzipcodesresponse : responsebase { [datamember(isrequired = true)] public list<zipcodes> zipcodes { get; set; } }
and here responsebase:
[datacontract] [serializable] [knowntype(typeof(getzipcodesresponse)), xmlinclude(typeof(getzipcodesresponse))] public class responsebase { [datamember(isrequired = true)] public int responsecode { get; set; } [datamember(isrequired = false)] public int reasoncode { get; set; } [datamember(isrequired = false)] public string reasontext { get; set; } }
here implementation of servicecontract interface:
public class zzzzzzcommonservice : izzzzzzcommonservice { public getzipcodesresponse getzipcodes(getzipcodesrequest request) { var response = new getzipcodesresponse(); try { response.zipcodes = zipcodes.getcustom(request.zipcode, request.city, request.state); } catch (exception ex) { this.buildexceptionresponse(response, ex); } return response; // line ok, here error occurs } }
and here client code calling service:
public void zipcodes() { var endpoint = new endpointaddress( "net.tcp://localhost/cs.webservice.zzzzzz.common/zzzzzzcommonservice.svc"); var binding = new nettcpbinding { transfermode = transfermode.buffered, sendtimeout = timespan.maxvalue, receivetimeout = timespan.maxvalue, maxreceivedmessagesize = 100000000, maxbuffersize = 100000000 }; using (var channel = new channelfactory<izzzzzzcommonservice>(binding, endpoint)) { try { channel.endpoint.contract.sessionmode = sessionmode.allowed; var proxy = channel.createchannel(); var request = new getzipcodesrequest(); request = new getzipcodesrequest { zipcode = "32701" }; response = proxy.getzipcodes(request); } } }
i have debugged code , getting entity , dataset populated appropriate rows when sends dataset when errors.
not sure missing. believe have servicecontract , datacontract members decorated correctly not sure why having problems serializing list.
the problem zipcode class. entity class , not able serialized. deconstructed class , able send client.
Comments
Post a Comment