c# - Passing complex type to windows service with WCF -
I have a Windows service and winoff front end app, in order to call and pass data roundtrip for services I need to be enabled. I have completed it by defining an interface and can overcome the string without any problems.
[ServiceContract] Public Interface Rating Ruler [[DataContract Formatted] [OperationContract] String Reverse String (String Value); } Now I am trying to return a complex data type and changed the code like this:
[ServiceContract] public Interface IStringReverser {[DataContractFormat] [Operation Contract] DTO reverse string (string value); } [Serialable] public class dto {public id id}; Set; } Public string name {get; Set; }} My implementation is as follows:
public class string reverser: optimizing reverser {public DTO reverse string (string value) {char [] retVal = value ToCharArray (); int idx = 0; For (int i = value.Length - 1; i> = 0; i--) Rated [idx ++] = value [i]; Var DTO = new DTO (); Dto.Name = retVal.ToString (); Dto.Id = 122; Return DTO; }} I do not transfer data specifically: I get an error:
While trying to deserialize the message, the formatter has an exception Throwed: There was an error while trying to deserialize the parameter. Innerexception message '' andaalation '' reverse string result 'is not expected' from namespace. Expected element '_x003C_Id_x003E_k__ backingfield'. Please see InnerException for more information.
I am making a connection with this in Winform:
Private IStringReverser pipeProxy; Public Form 1 () {Initialization (); ChannelFactory & LT; IStringReverser & gt; HttpFactory = New Channel Factoring & lt; IStringReverser & gt; (New basic httbadding (), new endpoint address ("http: // localhost: 8000 / reverse"); ChannelFactory & LT; IStringReverser & gt; Pipfactor = New Channel Factor & lt; IStringReverser & gt; (New NetNamedPipeBinding (), new EndpointEditor ("netpoep: // localhost / pipe rails")); // Istring Reporter httpProxy = httpFactory.CreateChannel (); Pipiproxy = pipefrenchure.createchannel (); } I do not understand the error message or how to correct it. How do I define how to get it deserialized? Is the serialization okay?
Use Data Contracts:
[DataContract] DTO {[Database] Public Entry ID (Receive); Set; } [Datamember] public string name {get; Set; }}
Comments
Post a Comment