C# is the primary programming language of the .NET framework. See our .NET tutorial for an overview of the features of the .NET platform and the development environments.

In this tutorial we look at how to use the EBI Web Services with C# in the Microsoft .NET SDK and Mono development environments.

Microsoft .NET SDK and Mono

Create Service Stubs

From the service WSDL (e.g. generate stub classes using the wsdl tool:

wsdl ""

Use Service

Then in the program create an instance of the service object:

WSDBFetchServerService Dbfetch = new WSDBFetchServerService();

This object provides methods corresponding to those defined in the WSDL so to call the fetchData method of the WSDbfetch service we can use:

string result = Dbfetch.fetchData("UNIPROT:ADH1A_HUMAN", "default", "raw");

The fetchData method returns a string containing the requested database entry, which can be output with:


Compile Program

Once the program has been completed, it need to be compiled. This is slightly different depending on the chosen environment. Assuming the program is in a file called wsdbfetch.cs:

Microsoft .NET SDK

csc wsdbfetch.cs WSDBFetchServerService.cs


mcs wsdbfetch.cs WSDBFetchServerService.cs -r:System.Web.Services

Run the Program

The resulting .exe. file can be run as follows:

MS Windows, assuming the .NET runtime is installed:


Non-Windows Mono environments:

mono wsdbfetch.exe

Note: some non-Windows environments (e.g. Linux) can be configured to support direct execution of .NET programs, allowing the use of the Windows style method.

Using Data Structures

The methods in the WSDbfetch service all use simple string parameters. Many of the other EBI services use more complex input structures. For example WSInterProScan requires a structure containing the various parameters and the input sequence to be passed to the runInterProScan method:

// The input parameters
inputParams input = new inputParams();
// Set the required parameters = "your@email"; // User e-mail address
input.async = true; // Async submission
input.seqtype = "p"; // Protein input sequence
input.crc = true; // Use IprMatches lookup
// The input data
data[] content = new data[1];
content[0] = new data();
// Input type
content[0].type = "seqeunce";
// Input data
content[0].content = @">Q8E5Q5_STRA3
// Submit the job
WSInterProScanService InterProScan = new WSInterProScanService(); 
string jobId = InterProScan.runInterProScan(input, content);

The runInterProScan method returns a job identifier which can be used with the checkStatus method to get the status of the job (e.g. RUNNING, DONE or ERROR) and the poll method to get the results of the job.

string status = "PENDING";
// Check status and wait if not finished
while(status == "RUNNING" || status == "PENDING") {
  status = InterProScan.getStatus(jobId);
  if(status == "RUNNING" || status == "PENDING") {
    // Wait before polling again.
// Get results
Byte[] res = InterProScan.poll(jobId, "toolraw");
// Convert result into a string for output
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
string tempStr = enc.GetString(res);
// Output the result

Sample Clients

Most SOAP Web Services at EMBL-EBI have sample clients which provide command-line access to the service and example code. For .NET most of the clients are implemented in C#, for example:

Document/literal SOAP

RPC/encoded SOAP

Service Sample client
WSDbfetch (SOAP) .NET Executable: wsdbfetch.exe;
Source: wsdbfetch.cs
tutorials/06_programming/dot_net/csharp.txt · Last modified: 2011/07/26 07:44 by hpm