TheJediCowboy
TheJediCowboy

Reputation: 9222

WCF SOAP Service

I am working on a WCF SOAP service, and I noticed something weird.

I have the following code in my service contract

[ServiceContract]
public interface IService
{
   [OperationContract]
   int MethodA(int a, int b);

   [OperationContract]
   string MethodB(int a, int b);
}

I am not going to give the implemented service class because the implemented MethodA and MethodB are trivial and could do anything.

When I chose to "Add Web Reference" and create a proxy reference in an ASP.NET application that I am using to consume the services, I noticed that the two methods have different arguments on their signature.

For example:

MethodA has the following signature options

MethodA(int a,bool aSpecified,int b,bool bSpecified)

and MethodB only has the following signature

MethodB(int a,bool aSpecified,int b,bool bSpecified,out int MethodBResult,bool methodBResultSpecified)

Why would they have different options for signatures?

I need MethodB signature to be the same as MethodA.

what would I need to provide for the last two parameters?

Upvotes: 2

Views: 209

Answers (1)

carlosfigueira
carlosfigueira

Reputation: 87228

If you're consuming a WCF service, you should use the "Add Service Reference" (instead of "Add Web Reference" to create a proxy to the service. Those *specified parameters are added for the "old-style" proxies because you could prevent the parameters from being sent to the service (see some answers at the post What are these extra parameters in my ASMX Proxy Methods? for more information)

Upvotes: 3

Related Questions