I am using this template to create a web service.
Here is a Web Service Contract I am using:
[<ServiceContract>]
type ISimpleService =
[<OperationContract>]
abstract GetItems: value:int -> Item[]
[<OperationContract>]
abstract InsertItem: composite:Item -> int
- Where can I find
valueandcompositedescription? Is it language feature or something else? - I want to GetItem method doesn't have any imput parameters and InsertItem doesn't return the value (void). Is it possible?
The
valueandcompositesymbols in the code sample are just names of the parameters. This pretty much corresponds to the following C# interface:If you want to change the definition so that
InsertItemdoes not return anything andGetItemdoes not take anything, you need to change their return and input types tounit:The
unittype (roughly) corresponds tovoidin C# when used as a return type and this is also how it will be compiled. When used as input,unitcorresponds to an empty parameter list (and it is compiled as such).This may sound confusing, but the
unittype is an F# type with just one value written as(), so when you callfoo(), you are actually passing the value of typeunitas an argument. This takes some time getting used to, but it makes the language elegantly simple.