I've created service with several methods in it (svc file).
public class PartService : IPartService, IPolicyService
{
public RLPL.CDM2.Parts.PartAddResponse AddPart(RLPL.CDM2.Parts.PartAddRequest input)
{
if (input == null)
{
throw new ArgumentNullException("Null input parameter");
}
return new RLPL.CDM2.Parts.PartAddResponse();
}
public RLPL.CDM2.Insurance.PolicyAddResponse AddPolicy(RLPL.CDM2.Insurance.PolicyAddRequest input)
{
if (input == null)
{
throw new ArgumentNullException("Null input parameter");
}
return new RLPL.CDM2.Insurance.PolicyAddResponse();
}
}
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.
Question is this: can I block one of these two methods in service in Web.config or by adding custom config for svcutil?
Web.Config in service looks like this:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="EsbService.PartService.svc">
<endpoint address="PolicyService" binding="basicHttpBinding" name="PolicyService" contract="EsbService.IPolicyService" />
<endpoint address="PartService" binding="basicHttpBinding" name="PartService" contract="EsbService.IPartService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- 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" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
Any methods that do not have a OperationContractAttribute 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.
Toystoy
Member
16 Points
12 Posts
WCF Service, not all methods in service
May 31, 2012 08:06 PM|LINK
Hi,
I've created service with several methods in it (svc file).
public class PartService : IPartService, IPolicyService { public RLPL.CDM2.Parts.PartAddResponse AddPart(RLPL.CDM2.Parts.PartAddRequest input) { if (input == null) { throw new ArgumentNullException("Null input parameter"); } return new RLPL.CDM2.Parts.PartAddResponse(); } public RLPL.CDM2.Insurance.PolicyAddResponse AddPolicy(RLPL.CDM2.Insurance.PolicyAddRequest input) { if (input == null) { throw new ArgumentNullException("Null input parameter"); } return new RLPL.CDM2.Insurance.PolicyAddResponse(); } }first Interface class:
[ServiceContract(Name = "PartService", Namespace = "http://rl.com.pl/esb/PartService")] public interface IPartService { [OperationContract] RLPL.CDM2.Parts.PartAddResponse AddPart(RLPL.CDM2.Parts.PartAddRequest AddPartRequest); }Second interface class:
[ServiceContract(Name = "PolicyService", Namespace = "http://rl.com.pl/esb/PolicyService")] public interface IPolicyService { [OperationContract] RLPL.CDM2.Insurance.PolicyAddResponse AddPolicy(RLPL.CDM2.Insurance.PolicyAddRequest AddPolicyRequest); }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.
Question is this: can I block one of these two methods in service in Web.config or by adding custom config for svcutil?
Web.Config in service looks like this:
<?xml version="1.0"?> <configuration> <system.web> <compilation debug="true" targetFramework="4.0" /> </system.web> <system.serviceModel> <services> <service name="EsbService.PartService.svc"> <endpoint address="PolicyService" binding="basicHttpBinding" name="PolicyService" contract="EsbService.IPolicyService" /> <endpoint address="PartService" binding="basicHttpBinding" name="PartService" contract="EsbService.IPartService" /> </service> </services> <behaviors> <serviceBehaviors> <behavior> <!-- 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" /> </system.serviceModel> <system.webServer> <modules runAllManagedModulesForAllRequests="true"/> </system.webServer> </configuration>config methods WCF svcutil
mm10
Contributor
6455 Points
1187 Posts
Re: WCF Service, not all methods in service
Jun 01, 2012 12:44 PM|LINK
Do you want to have two separate services (interfaces) which uses the same implementation (class) or what are you trying to accomplish?
Peter pi - M...
Star
12871 Points
1786 Posts
Re: WCF Service, not all methods in service
Jun 05, 2012 02:46 AM|LINK
Not sure what is the meaning of the above sentence? Could you describe it in details?
config methods WCF svcutil
If you have any feedback about my replies, please contact msdnmg@microsoft.com
Microsoft One Code Framework
christiandev
Star
8607 Points
1841 Posts
Re: WCF Service, not all methods in service
Jun 05, 2012 09:34 AM|LINK
Can't you just remove OperationContract from method you want to hide?
config methods WCF svcutil
Regards, Christiandev (@chrisdev80), MCPD Web (2 & 4) & MCTS Windows (www.ScoreDonkey.com)
nijhawan.sau...
All-Star
16460 Points
3178 Posts
Re: WCF Service, not all methods in service
Jun 05, 2012 11:32 AM|LINK
I agree with christiandev
Details here:
Any methods that do not have a OperationContractAttribute 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.
christiandev
Star
8607 Points
1841 Posts
Re: WCF Service, not all methods in service
Jun 07, 2012 07:38 AM|LINK
So, what did you actually do to solve it ?
Regards, Christiandev (@chrisdev80), MCPD Web (2 & 4) & MCTS Windows (www.ScoreDonkey.com)