c# - What does adding Name and Namespace to DataContract do? -
i tried calling webinvoke method called register returns takes in user object , returns object. looks following:
user register(user user) { return user; }
i not sure name , namespace attributes datacontract attribute when calling http://localhost:8081/user/register example?
the reason ask because had class decorated datacontract attribute this:
[datacontract] public class user { // properties }
when opened fiddler, , sent post request, said method not allowed, when changed datacontract to:
[datacontract(name="user", namespace="")]
it worked.
these properties control namespace , name of element in wsdl. important part in code namespace=""
: override default namespace (http://tempuri.org) , set value empty url.
in end, user class renamed in wsdl http://tempuri.org/user user.
Comments
Post a Comment