In this post, I'm going to create a new WCFService with basicHTTPBinding and deploy it to IIS. I will mediate the deployed service with WSO2 ESB 3.0.0. For mediating the service, I will use "Pass Through Proxy".
- Pre-requisites
- Visual Studio 2008 or higher to create WCF Service
- wso2 esb 3.0.0 or higher, get it from here
- Install and Start WSO2 ESB 3.0.0
- Extract the downloaded esb files
- Go to command prompt
- locate to bin directory of extracted esb
- write "wso2server.bat" and that will start the wso2 esb server after a few seconds
- Create a new WCF Service
- Start Visual Studio and go to File > New Project
 |
| Create a new WCF Service Application from visual studio |
- That will create a new WCF Service
- Open web.config and go to "system.serviceModel" element:
<service name="xxx" behaviorConfiguration="xxxx">
<!-- Service Endpoints -->
<endpoint address="" binding="basicHttpBinding" contract="xxxx">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
Make sure you change the endpoint element's binding attribute is having value basicHttpBinding
- Just Right click on the service project and click on Build Project
- It show you "Build Success" in status bar
- Right click on project again and click on publish
- Create a new folder called WCFServiceDeployed and select it as output directory
- Go to IIS and Create a new virual directory called "WCFService" and point it to WCFServiceDeployed folder
- right click on Service1.svc (or whatever svc file you have) and click on browse.
- Copy the wsdl url shown in the service page.
- Create Pass through proxy in wso2 esb
- Make sure you have wso2 esb up and running
- Locate your browser to https://localhost:9443/carbon
- use admin/admin as username/password to login to the site
- Click on Services > Add > Proxy Services
- Click on "Pass Through Service"
- enter "WCFService" in "Proxy Service Name" text box
- In "Target Url" add url of WCF Service
- Expand "Publish WSDL" option
- From the Publish WSDL drop down menu, choose "Specify Source Url"
- In the text box of WSDL URI, enter your published svc url suffixed with ?wsdl
- Expand Transport
- Uncheck HTTPS transport
- Click on create
- Go to Services > List
- Click on WCFService
- Copy the endpoint url
- Creating Client for the newly created service in esb
- Start Visual studio
- Create a new console application project (i'm using visual basic)
- Right click on the project and click on add web reference
- enter the url of the endpoint that you get from web esb
- click on ok
- go to module1.vb
- Add following code:
Dim client As New localhost.WCFService
Dim strData As String = client.GetData(100, True)
Console.WriteLine(strData)
Dim cmpType As New localhost.CompositeType
cmpType.BoolValue = True
cmpType.BoolValueSpecified = True
cmpType.StringValue = "It works"
Dim retCmpType As localhost.CompositeType = client.GetDataUsingDataContract(cmpType)
Console.WriteLine(retCmpType.StringValue)
Console.ReadKey()
That's It, you will see the output in console window. Press any key to exit the console application.
Please note that I'm using web reference because I am not able to correcly implement WCF Client for the service yet. In upcoming post, I will cover how to secure WCF service with basicHTTPBinding with wso2esb
0 comments:
Post a Comment
Please add your valuable comments about this post if it helped you. Thanks