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:
- change return type of operation servicexmlreply or
- abandon use of servicexmlreply. use string in stead on service , client side.
Comments
Post a Comment