c# - xml deserialization <string> tag -


i wrote web service using system.servicemodel system.servicemodel.web system.servicemodel.activation namespaces.

[xmlserializerformat]         [operationcontract]         [webget(uritemplate = routing.getclientroute, bodystyle = webmessagebodystyle.bare)]         string getclientnamebyid(string id);            

i described data class:

[xmlroot("servicexmlreply")]     public class servicexmlreply     {         [xmlelement]         public string name;     } 

problem respond, receive service. looks this:

"<?xml version=\"1.0\" encoding=\"utf-8\"?> <string> <servicexmlreply xmlns:xsd=\"http://www.w3.org/2001/xmlschema\" xmlns:xsi=\"http://www.w3.org/2001/xmlschema-instance\"> <name>igor<name> <servicexmlreply> </string>" 

as can see there not supposed "string" tag, is. because of can't deserialize respond , data.

class same on server , client's side.

your operation contract defines response of getclientnamebyid of type string. happens contents of return type string serialized xml.

to working, should is:

  1. change return type of operation servicexmlreply or
  2. abandon use of servicexmlreply. use string in stead on service , client side.

Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -