1

In the following method, where last parameter is an optional parameter, which works through standard access of the binary. However in the WCF proxy it becomes mandatory, I cannot avoid, is there something that needs to be done to make it optional for the WCF proxy too. Current search suggest that it might not be possible to do so, just keeping my fingers crossed to find a workaround.

public UnifiedDTO GetAllCardTitle(string trainSymbolOrCarLocation, 
                                           DateTime startDate, 
                                           DateTime endDate, 
                                           string procedureName = CardTitle.procedureNameTrainRuns)
Mrinal Kamboj
  • 11,300
  • 5
  • 40
  • 74
  • possible duplicate of [Can't use optional parameters when implementing an interface for a WCF](http://stackoverflow.com/questions/17043134/cant-use-optional-parameters-when-implementing-an-interface-for-a-wcf) – Roman Apr 29 '14 at 13:50
  • Please follow up on your [earlier questions](http://stackoverflow.com/questions/23358743/which-is-better-params-or-list) rather than posting new ones, especially ones that are duplicates of existing questions. – Roman Apr 29 '14 at 13:51

2 Answers2

0

Although it's optional "on the wire" once the data has been serialized to XML, you cannot set default values and you cannot have default values in the code proxies. You could write another wrapper around your code proxy, that looks whatever you want though.

nvoigt
  • 75,013
  • 26
  • 93
  • 142
0

I think there are two solutions:

1-you may create two methods one with optional parameter.

public UnifiedDTO GetAllCardTitle(string trainSymbolOrCarLocation, 
                                           DateTime startDate, 
                                           DateTime endDate)

public UnifiedDTO GetAllCardTitle(string trainSymbolOrCarLocation, 
                                           DateTime startDate, 
                                           DateTime endDate, 
                                           string procedureName)

2-you may create a DTO representing your parameters and assign a default value in the DTO.

daryal
  • 14,643
  • 4
  • 38
  • 54