No Datacontracts are not used so they can consumed outside .NET like JAVA / PHP
1) If enabled, WCF service metadata could be found by opening the http://...svc?wsdl
2) In there, there is a section types, which refers to an xsd for example http://localhost/LMSService/LMSService.svc?xsd=xsd2
3) That xsd has all the data types/structures for input and output.
4) The funny part is, it has all the public properties used in the input/output even if you don’t have DataContract attributes.
So the question is What’s the point of DataContract/DataMember attributes. The above xsd has the datatypes/structures and a PHP/Java client could consume that. The answer is for more control on which properties to be published. So without DataContract/DataMember attribute, its ALL or NONE for all public properties publishing. (Note: You can all together switch off WCF Metadata publishing). With DataContract/DataMember, we have some properties public to be used in our own projects/solution yet not expose it the outside world by not adorning it with DataMember attribute.
Question- ) How to switch off/on WCF metadata publishing
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="metadataBehavior">
<!—The answer is in the comment line below à
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<services>
<service name="SRO.LMS.Services.LMSService" behaviorConfiguration="metadataBehavior">
<host>
<baseAddresses>
<add baseAddress=
"http://localhost/LMSService" />
</baseAddresses>
</host>
<endpoint address="" binding="basicHttpBinding" contract="SRO.LMS.Services.ILMSService"/>
<endpoint address="mex" binding = "mexHttpBinding" contract = "IMetadataExchange"/>
</service>
</services>
</system.serviceModel>
No comments:
Post a Comment