WCF service with 2 or more parameters

237 views Asked by At

I have to create a WCF service that executes a query (no problem at the moment). My problem is that this query needs two parameters that the user types into a web form and submits with a button. How can I pass those 2 parameters from the web form to the service? I have only created services that receive only one parameter, not more than one This is my only problem, I'm be able to read the JSON result and organize it in the form

Thaks a lot

1

There are 1 answers

0
Lan Huang On

I think you can use UriTemplate,
UriTemplate is a class that encapsulates a URI template. The constructor takes a string parameter that defines the template.
like :

[ServiceContract]  
interface ICustomer  
{  
  //"View It" -> HTTP GET  
    [WebGet( UriTemplate="customers/{id}" )]  
  Customer GetCustomer( string id ):  
  
  //"Do It" -> HTTP PUT  
  [WebInvoke( UriTemplate="customers/{id}", Method="PUT" )]  
  Customer UpdateCustomer( string id, Customer newCustomer );  
}  

Useful links:
URI Processing with UriTemplate and UriTemplateTable
How to pass multiple parameters on WCF Restful service using C# in ASP.Net