Adding WCF service as web reference creates additional parameters on methods

Ive created a WCF service that works correctly when I create a proxy using svcutil.

If i add the service as a web reference, additional parameters are added to the methods available through the service.

For example, i have a method GetEntity(int entityId, bool FullObject), however when it is made available through the webservice its signiture is

GetEntity(int entityId, bool entityIdSpecified, bool FullObject, bool FullObjectSpecified).

If i sent that additional parameters to true, the call still works and returns the expected result, but i was wondering why these params are added, and can i avoid the need to specify them

Thanks


Answer this question

Adding WCF service as web reference creates additional parameters on methods

  • TheFreeman

    This is the solution: put XmlSerializerFormat attribute
    Example:

    <ServiceContract()> _
    Public Interface IService

    <OperationContract(), XmlSerializerFormat(Style:=OperationFormatStyle.Document)> _
    Function operation(ByVal n1 As Integer, ByVal n2 As Integer) As Double

    End Interface


  • radrevere

    WCF uses svcutil.exe tool to create proxy, while VS2005 uses "Add web reference" feature to generate proxy. These tool/feature are created and maintained by totally different teams so their default behavior might be different. In your case, svcutil.exe is doing the right thing, so you will need to play with the "Add Web Reference" feature in VS2005 to get the correct settings you want.
  • Adding WCF service as web reference creates additional parameters on methods