WCF (Windows Communication Foundation ) tool is used to implement and deploy a service-oriented architecture (SOA) . It uses WSDL to communicate with the WCF client over SOAP. In this article , we explained step by step process to call C# .Net WCF web service in java SOAP client.

Steps to create C# .Net WCF web service :

Step 1 :

Create a C# .Net project in visual studio . For that , go to File -> New -> Project.

If you want , you can create a Web Site .

Step 2 :

Select WCF sub menu from the Visual C# ( left side ). Select WCF Service Application from the right side. Give any name for your project . In our example, the name is FirstWCFServiceExe .

So, the project will creare in the Solution Explorer .

Step 3 :

Add a new Item to the project like below (Right click on the project , select Add -> New Item).

Step 4 :

From the New Item window , select Web -> WCF Service . Give any name to the service .

Step 5 :

So the New Item added to the project.

Step 6 :

Copy the below code to FirstService.svc.cs and IFirstService.cs files .

FirstService.svc.cs

Java

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

using System;

using System.Collections.Generic;

using System.Linq;

using System.Runtime.Serialization;

using System.ServiceModel;

using System.Text;

namespaceFirstWCFServiceExe

{

// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "FirstService" in code, svc and config file together.

// NOTE: In order to launch WCF Test Client for testing this service, please select FirstService.svc or FirstService.svc.cs at the Solution Explorer and start debugging.

publicclassFirstService:IFirstService

{

publicstringDoWork()

{

return"hellow world";

}

}

}

IFirstService.cs

Java

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

using System;

using System.Collections.Generic;

using System.Linq;

using System.Runtime.Serialization;

using System.ServiceModel;

using System.Text;

namespaceFirstWCFServiceExe

{

// NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IFirstService" in both code and config file together.