c# - Does not return in a json format but instead in a xml format -


i got issue in wcf service library because set webmessegeformat json format, instead returns xml format. how can fix issue? missing something?

thank in advance :)

here code:

public class service : iservice {     [webinvoke(method="get",         requestformat = webmessageformat.json,         uritemplate="{id}/{name}/{age}/{sex}/{address}")]     public response transaction(string id, string name, string age, string sex, string address)     {         return new response()         {             id = id,             name = name,             age = age,             sex = sex,             address = address         };     } }  public class response {     public string id { get; set; }     public string name { get; set; }     public string age { get; set; }     public string sex { get; set; }     public string address { get; set; } } 

here app config

    <?xml version="1.0"?> <configuration>    <system.servicemodel>     <services>       <service name="wcfeservicelibrary.service">         <endpoint address="http://phws13:8732/wcfservicelibrary/"                    binding="webhttpbinding"                    contract="wcfservicelibrary.iservice">         </endpoint>       </service>     </services>     <behaviors>       <endpointbehaviors>         <behavior>           <webhttp />         </behavior>       </endpointbehaviors>     </behaviors>   </system.servicemodel>  <startup><supportedruntime version="v4.0" sku=".netframework,version=v4.0"/></startup></configuration> 

do need set responseformat webmessageformat.json

 [webinvoke(method = "get",          responseformat = webmessageformat.json,          bodystyle = webmessagebodystyle.wrapped,          uritemplate = "{id}/{name}/{age}/{sex}/{address}")] 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -