Note that there are some explanatory texts on larger screens.

plurals
  1. POCreating a WCF Client Inheriting from ClientBase in F#
    primarykey
    data
    text
    <p>I found the following code on the msdn site here: <a href="http://msdn.microsoft.com/en-us/library/ms733133.aspx#Y380" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms733133.aspx#Y380</a></p> <pre><code>[System.ServiceModel.ServiceContractAttribute(Namespace="http://Microsoft.ServiceModel.Samples", ConfigurationName="ICalculator")] public interface ICalculator { [System.ServiceModel.OperationContractAttribute(Action="http://Microsoft.ServiceModel.Samples/ICalculator/Add", ReplyAction="http://Microsoft.ServiceModel.Samples/ICalculator/AddResponse")] double Add(double n1, double n2); [System.ServiceModel.OperationContractAttribute(Action="http://Microsoft.ServiceModel.Samples/ICalculator/Subtract", ReplyAction="http://Microsoft.ServiceModel.Samples/ICalculator/SubtractResponse")] double Subtract(double n1, double n2); [System.ServiceModel.OperationContractAttribute(Action="http://Microsoft.ServiceModel.Samples/ICalculator/Multiply", ReplyAction="http://Microsoft.ServiceModel.Samples/ICalculator/MultiplyResponse")] double Multiply(double n1, double n2); [System.ServiceModel.OperationContractAttribute(Action="http://Microsoft.ServiceModel.Samples/ICalculator/Divide", ReplyAction="http://Microsoft.ServiceModel.Samples/ICalculator/DivideResponse")] double Divide(double n1, double n2); } public interface ICalculatorChannel : ICalculator, System.ServiceModel.IClientChannel { } public partial class CalculatorClient : System.ServiceModel.ClientBase&lt;ICalculator&gt;, ICalculator { public CalculatorClient() { } public CalculatorClient(string endpointConfigurationName) : base(endpointConfigurationName) { } public CalculatorClient(string endpointConfigurationName, string remoteAddress) : base(endpointConfigurationName, remoteAddress) { } public CalculatorClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : base(endpointConfigurationName, remoteAddress) { } public CalculatorClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : base(binding, remoteAddress) { } public double Add(double n1, double n2) { return base.Channel.Add(n1, n2); } public double Subtract(double n1, double n2) { return base.Channel.Subtract(n1, n2); } public double Multiply(double n1, double n2) { return base.Channel.Multiply(n1, n2); } public double Divide(double n1, double n2) { return base.Channel.Divide(n1, n2); } } </code></pre> <p>Obviously, this is the world famous WCF CalculatorService on msdn. The code I have shown above was generated with svcutil.exe. However, svcutil.exe does not generate F# code so I'm trying to translate CalculatorClient into F# (I can handle the interfaces just fine). I would show you what I have so far, except I only have the first three lines completed and those are probably wrong anyhow (I get that impression from all the red squigglyness decorating it). I'm completely stumped by the combination of inheriting from a base class and an interface at the same time. I don't need the whole class translated, just the class with a few constructors and one of the interface methods, and I'm sure I can work out the rest. Although, if you want to translate the whole thing for posterity please feel free.</p> <p>Thanks,</p> <p>Bob</p> <p>Edit: Here is the interface I am using. Feel free to edit it if it could be improved.</p> <pre><code>[&lt;ServiceContract&gt;] type ICalculator = [&lt;OperationContract&gt;] abstract member Add: float*float -&gt; float [&lt;OperationContract&gt;] abstract member Subtract: float*float -&gt; float [&lt;OperationContract&gt;] abstract member Multiply: float*float -&gt; float [&lt;OperationContract&gt;] abstract member Divide: float*float -&gt; float </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload