WCF Service, not all methods in servicehttp://forums.asp.net/t/1809576.aspx/1?WCF+Service+not+all+methods+in+serviceThu, 07 Jun 2012 07:38:53 -040018095765006649http://forums.asp.net/p/1809576/5006649.aspx/1?WCF+Service+not+all+methods+in+serviceWCF Service, not all methods in service <p>Hi,</p> <p>I've created service with several methods in it (svc file).</p> <pre class="prettyprint">public class PartService : IPartService, IPolicyService { public RLPL.CDM2.Parts.PartAddResponse AddPart(RLPL.CDM2.Parts.PartAddRequest input) { if (input == null) { throw new ArgumentNullException(&quot;Null input parameter&quot;); } return new RLPL.CDM2.Parts.PartAddResponse(); } public RLPL.CDM2.Insurance.PolicyAddResponse AddPolicy(RLPL.CDM2.Insurance.PolicyAddRequest input) { if (input == null) { throw new ArgumentNullException(&quot;Null input parameter&quot;); } return new RLPL.CDM2.Insurance.PolicyAddResponse(); } }</pre> <p>first Interface class:</p> <pre class="prettyprint"> [ServiceContract(Name = "PartService", Namespace = "http://rl.com.pl/esb/PartServic&zwnj;e")] public interface IPartService { [OperationContract] RLPL.CDM2.Parts.PartAddResponse AddPart(RLPL.CDM2.Parts.PartAddRequest AddPartRequest); }</pre> <p><br />Second interface class:</p> <pre class="prettyprint"> [ServiceContract(Name = "PolicyService", Namespace = "http://rl.com.pl/esb/PolicyService")] public interface IPolicyService { [OperationContract] RLPL.CDM2.Insurance.PolicyAddResponse AddPolicy(RLPL.CDM2.Insurance.PolicyAddRequest AddPolicyRequest); }</pre> <p>Now I'm thinking how to block one or several methods in service. I'm using svcutil to generate wsdl and xsd files. But svcutil generates all methods in those files. Sure, I can use excludeType in svcutil and there is one solution for me.&nbsp;</p> <p><strong>Question is this:</strong> can I block one of these two methods in service in Web.config or by adding custom config for svcutil?&nbsp;</p> <p>Web.Config in service looks like this:</p> <pre class="prettyprint">&lt;?xml version="1.0"?&gt; &lt;configuration&gt; &lt;system.web&gt; &lt;compilation debug="true" targetFramework="4.0" /&gt; &lt;/system.web&gt; &lt;system.serviceModel&gt; &lt;services&gt; &lt;service name="EsbService.PartService.svc"&gt; &lt;endpoint address="PolicyService" binding="basicHttpBinding" name="PolicyService" contract="EsbService.IPolicyService" /&gt; &lt;endpoint address="PartService" binding="basicHttpBinding" name="PartService" contract="EsbService.IPartService" /&gt; &lt;/service&gt; &lt;/services&gt; &lt;behaviors&gt; &lt;serviceBehaviors&gt; &lt;behavior&gt; &lt;!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --&gt; &lt;serviceMetadata httpGetEnabled="true"/&gt; &lt;!-- 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 --&gt; &lt;serviceDebug includeExceptionDetailInFaults="false"/&gt; &lt;/behavior&gt; &lt;/serviceBehaviors&gt; &lt;/behaviors&gt; &lt;serviceHostingEnvironment multipleSiteBindingsEnabled="true" /&gt; &lt;/system.serviceModel&gt; &lt;system.webServer&gt; &lt;modules runAllManagedModulesForAllRequests="true"/&gt; &lt;/system.webServer&gt; &lt;/configuration&gt; </pre> <p><br> <br> </p> 2012-05-31T20:06:05-04:005007725http://forums.asp.net/p/1809576/5007725.aspx/1?Re+WCF+Service+not+all+methods+in+serviceRe: WCF Service, not all methods in service <p>Do you want to have two separate services (interfaces)&nbsp;which uses the same implementation (class) or what are you trying to accomplish?</p> 2012-06-01T12:44:36-04:005011166http://forums.asp.net/p/1809576/5011166.aspx/1?Re+WCF+Service+not+all+methods+in+serviceRe: WCF Service, not all methods in service <p></p> <blockquote><span class="icon-blockquote"></span> <h4>Toystoy</h4> <p></p> <p><strong>Question is this:</strong> can I block one of these two methods in service in Web.config or by adding custom config for svcutil?&nbsp;</p> <p></p> </blockquote> <p></p> <p>Not sure what is the meaning of the above sentence? Could you describe it in details?</p> 2012-06-05T02:46:11-04:005011776http://forums.asp.net/p/1809576/5011776.aspx/1?Re+WCF+Service+not+all+methods+in+serviceRe: WCF Service, not all methods in service <p>Can't you just remove OperationContract from method you want to hide?</p> 2012-06-05T09:34:48-04:005011975http://forums.asp.net/p/1809576/5011975.aspx/1?Re+WCF+Service+not+all+methods+in+serviceRe: WCF Service, not all methods in service <p>I agree with&nbsp;<a title="christiandev" href="http://forums.asp.net/members/christiandev.aspx">christiandev</a></p> <p>Details here:</p> <p><span>Any methods that do not have a&nbsp;</span><strong>OperationContractAttribute</strong><span>&nbsp;attribute are not service operations and are not exposed for use by clients of WCF services. Like any managed method, they can only be called by objects within their declared access scope.</span></p> 2012-06-05T11:32:00-04:005015169http://forums.asp.net/p/1809576/5015169.aspx/1?Re+WCF+Service+not+all+methods+in+serviceRe: WCF Service, not all methods in service <p>So, what did you actually do to solve it ?</p> 2012-06-07T07:38:53-04:00