How to invoke a WSIT endpoint from a WCF client ?

You've developed a reliable, secure transactional and interoperable Web service using Web Services Interoperability Technology (WSIT, aka Project Tango) plug-in in NetBeans 5.5.1 and deployed on GlassFish v2. NetBeans IDE provide a very seamless experience to build such a Web service. The primary goal of WSIT is to provide first-class interoperability with Windows Communication Foundation (WCF), the Web services component of .NET 3.0 framework. Once the Web service is deployed, you'd like to invoke this Web service by writing a client using Visual Studio. It's not straight forward to do so today and this entry highlights the steps required to do that.

  1. If not already done, create a reliable WSIT endpoint and deploy on GlassFish v2 following the screencast #ws3.
  2. For creating a WCF client, install the following software
    1. If not using Vista, then install .NET 3.0 Framework runtime.
    2. Microsoft Visual Studio 2005 Professional Edition (available via MSDN) - There are additional requirements for Express editions (free lightweight versions of Visual Studio)
    3. Microsoft Visual Studio 2005 Professional Edition SP1
    4. Microsoft Visual Studio 2005 Professional Edition SP1 Update
    5. Visual Studio 2005 Extensions for .NET 3.0 Framework (WCF & WPF), Nov 2006 CTP - For Express editions, Windows Vista SDK is required as well for WCF scenarios.
  3. Start Visual Studio
  4. Create a new Visual C#, Windows, Console Application. Program.cs is shown in the main Visual Studio window.
  5. In Solution Explorer, right-click on the project name and select "Add Service Reference ...". This is the big difference. If you select "Add Web Reference ...", then this creates a proxy and app.config for .NET 2.0 framework. But WSIT is about interoperability with .NET 3.0 framework.
  6. Specify the location of the WSIT endpoint, in our case (http://localhost:8080/WebApplication1/NewWebServiceService?wsdl).
  7. In the Main function of Program.cs, add the logic to invoke the generated proxy. The code looks like:
    using System;
    using System.Collections.Generic;
    using System.Text;
    using ConsoleApplication1.localhost;
    namespace ConsoleApplication1
        class Program
            static void Main(string[] args)
                NewWebServiceClient client = new NewWebServiceClient();
  8. Build the solution by selecting "Build", "Build Solution" (default shortcut Ctrl+Shift+B).
  9. Run ConsoleApplication1\\bin\\Debug\\ConsoleApplication1.exe. This will make a request to WSIT endpoint and get a response back.

The generated app.config file looks like:

<?xml version="1.0" encoding="utf-8" ?>
        <binding name="NewWebServicePortBinding">
          <reliableSession acknowledgementInterval="00:00:00.2000000" flowControlEnabled="true"
              inactivityTimeout="00:10:00" maxPendingChannels="4" maxRetryCount="8"
              maxTransferWindowSize="8" ordered="true" />
          <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16" 
              messageVersion="Soap11WSAddressing10" writeEncoding="utf-8">
              <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
                  maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <httpTransport manualAddressing="false" maxBufferPoolSize="524288"
              maxReceivedMessageSize="65536" allowCookies="false" authenticationScheme="Anonymous"
              bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
              keepAliveEnabled="true" maxBufferSize="65536" proxyAuthenticationScheme="Anonymous"
              realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
              useDefaultWebProxy="true" />
      <endpoint address="http://localhost:8080/WebApplication1/NewWebServiceService"
          binding="customBinding" bindingConfiguration="NewWebServicePortBinding"
          contract="ConsoleApplication1.localhost.NewWebService" name="NewWebServicePort" />

Here are the SOAP messages that get exchanged over the wire:

<?xml version="1.0" ?>
<s:Envelope xmlns:s=""
    <a:Action s:mustUnderstand="1"></a:Action>
    <a:To s:mustUnderstand="1">http://localhost:8080/WebApplication1/NewWebServiceService</a:To>
    <CreateSequence xmlns="">
<?xml version="1.0" ?>
<S:Envelope xmlns:S="">
  <To xmlns=""></To>
    <Action xmlns=""></Action>
    <MessageID xmlns="">uuid:b51f92ee-9ab9-4a90-a61e-d5dd3a77a0f9</MessageID>
    <RelatesTo xmlns="">urn:uuid:3429a390-96df-4f26-bd8c-fc85bd8f1858</RelatesTo>
    <ns2:CreateSequenceResponse xmlns:ns6="" xmlns:ns5="" xmlns:ns4="" xmlns:ns3="" xmlns:ns2="">
<?xml version="1.0" ?>
<s:Envelope xmlns:s="" xmlns:r="" xmlns:a="">
    <r:Sequence s:mustUnderstand="1">
    <a:Action s:mustUnderstand="1">sayHello</a:Action>
    <a:To s:mustUnderstand="1">http://localhost:8080/WebApplication1/NewWebServiceService</a:To>
    <sayHello xmlns="http://test/" xmlns:i="">
      <name xmlns="">Duke</name>
<?xml version="1.0" ?>
<S:Envelope xmlns:S="">
    <To xmlns=""></To>
    <Action xmlns="">http://test/NewWebService/sayHelloResponse</Action>
    <MessageID xmlns="">uuid:9091661c-c817-4411-b8aa-7f4f937162da</MessageID>
    <RelatesTo xmlns="">urn:uuid:d9c8b864-f236-40ad-a4c0-72c42565855f</RelatesTo>
    <ns2:Sequence xmlns:ns4="" xmlns:ns3="" xmlns:ns2="">
    <ns2:AckRequested xmlns:ns4="" xmlns:ns3="" xmlns:ns2="">
    <ns2:SequenceAcknowledgement xmlns:ns4="" xmlns:ns3="" xmlns:ns2="">
    <ns2:AcknowledgementRange Upper="1" Lower="1"></ns2:AcknowledgementRange>
    <ns2:sayHelloResponse xmlns:ns2="http://test/">
      <return>Hello Duke</return>

The same programming model will work for creating a WCF client if you add security or transactions support on the WSIT endpoint.

Technorati: wsit glassfish webservices vista wcf visualstudio


Hi I saw your screencasts and they are very good. can you please create a zip archive of your screencaset ? I really need to download them and study them during my trips and i have no internet access in train . looking for your comment. Thanks

Posted by legolas wood on April 30, 2007 at 07:02 AM PDT #

Hi Arun, Have you try to encrypt the response body in this simple scenario? Thanks, Phil

Posted by Phil on July 03, 2007 at 10:49 PM PDT #

Legolas, I'll work on providing an offline version of the screencasts later this week. Thanks, -Arun

Posted by Arun on July 04, 2007 at 08:52 AM PDT #

Phil, Yes, we've tried much more complex scenario and they worked like a charm. Read more about our participation at Microsoft's plugfest at:

Posted by Arun on July 04, 2007 at 08:53 AM PDT #

All the screencasts are now available for off-line viewing at:

Posted by Arun Gupta on August 21, 2007 at 06:54 AM PDT #

Hi! i created a web service as explained in the screencast ws3. Next i tried creating the WCF client. I am able to view the app.config file. However im unaable to get the response as "Hello Duke" back from the web service. It will be great if you could tell me how to. Thanks a lot!

Posted by DSK on October 12, 2008 at 05:35 PM PDT #

DSK, are you getting some error ?

Posted by Arun Gupta on October 13, 2008 at 02:19 AM PDT #

I got the following error:

The type or namespace name 'localhost' does not exist in the namespace 'ConsoleApplication1' (are you missing an assembly reference?)

I was prompted to enter the header as:
"using ConsoleApplication1.ServiceReference1" by default. When i tried this there was no error but im not getting the response back from the web service. Please tell me what i should do.
Thanks a lot for your help!

Posted by DSK on October 13, 2008 at 02:43 AM PDT #

Ive bee anxiously awaiting your response to my query. It would be great if you could help me out! Please give me a solution to my problem.Thanks!

Posted by DSK on October 20, 2008 at 02:06 AM PDT #

DSK, please post your question to for a wider audience.

Posted by Arun Gupta on October 24, 2008 at 08:26 AM PDT #

Post a Comment:
Comments are closed for this entry.

profile image
Arun Gupta is a technology enthusiast, a passionate runner, author, and a community guy who works for Oracle Corp.

Java EE 7 Samples

Stay Connected


« July 2016