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.
- If not already done, create a reliable WSIT endpoint and deploy on GlassFish v2 following the
screencast #ws3. - For creating a WCF client, install the following software
- If not using Vista, then install
.NET 3.0 Framework runtime. - Microsoft Visual Studio 2005 Professional Edition (available via MSDN)
- There are additional requirements for Express editions (free
lightweight versions of Visual Studio) - Microsoft Visual Studio 2005 Professional Edition SP1
- Microsoft Visual Studio 2005 Professional Edition SP1 Update
-
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.
- If not using Vista, then install
- Start Visual Studio
- Create a new Visual C#, Windows, Console Application.
Program.cs
is shown in the main Visual Studio window. - In Solution Explorer, right-click on the project name and select "
". This is the big difference. If you select "Add
Service Reference ...
", then this creates a proxy andAdd
Web Reference ...app.config
for .NET 2.0 framework. But WSIT is about interoperability with .NET 3.0
framework. - Specify the location of the WSIT endpoint, in our case (
http://localhost:8080/WebApplication1/NewWebServiceService?wsdl). - In the Main function of Program.cs, add the logic to invoke the
generated proxy. The code looks like:<font COLOR="#0000ff">[prettify]using</font>System; <font COLOR="#0000ff">using</font> System.Collections.Generic;<font COLOR="#0000ff"> using</font> System.Text; <font COLOR="#0000ff">using</font> ConsoleApplication1.localhost;<font COLOR="#0000ff">[/prettify]
namespace</code></font>[prettify] ConsoleApplication1 { <font COLOR="#0000ff">class</font> <font COLOR="#2b91af">Program </font>{ <font COLOR="#0000ff">static</font> <font COLOR="#0000ff">void</font> Main(<font COLOR="#0000ff">string</font>[] args) { <font COLOR="#2b91af">NewWebServiceClient</font> client = <font COLOR="#0000ff">new</font> <font COLOR="#2b91af">NewWebServiceClient</font>(); <font COLOR="#2b91af">Console</font>.WriteLine(client.sayHello(<font COLOR="#a31515">&quot;Duke&quot;</font>)); } } }</pre> </li> <li>Build the solution by selecting &quot;<code>Build", "Build Solution" (default shortcut Ctrl+Shift+B).</li> <li>RunConsoleApplication1\bin\Debug\ConsoleApplication1.exe.This will make a request to WSIT endpoint and get a response back.</li> </ol> <p>The generatedapp.configfile looks like:</p> <font COLOR="#0000ff"> <pre><?</code></font><font COLOR="#a31515">xml</font><font COLOR="#0000ff"> </font><font COLOR="#ff0000">version</font><font COLOR="#0000ff">=</font>&quot;<font COLOR="#0000ff">1.0</font>&quot;<font COLOR="#0000ff"> </font><font COLOR="#ff0000">encoding</font><font COLOR="#0000ff">=</font>&quot;<font COLOR="#0000ff">utf-8</font>&quot;<font COLOR="#0000ff"> ?&gt; &lt;</font><font COLOR="#a31515">configuration</font><font COLOR="#0000ff">&gt; &lt;</font><font COLOR="#a31515">system.serviceModel</font><font COLOR="#0000ff">&gt; &lt;</font><font COLOR="#a31515">bindings</font><font COLOR="#0000ff">&gt; &lt;</font><font COLOR="#a31515">customBinding</font><font COLOR="#0000ff">&gt; &lt;</font><font COLOR="#a31515">binding</font><font COLOR="#0000ff"> </font><font COLOR="#ff0000">name</font><font COLOR="#0000ff">=</font>&quot;<font COLOR="#0000ff">NewWebServicePortBinding</font>&quot;<font COLOR="#0000ff">&gt; &lt;</font><font COLOR="#a31515">reliableSession</font><font COLOR="#0000ff"> </font><font COLOR="#ff0000">acknowledgementInterval</font><font COLOR="#0000ff">=</font>&quot;<font COLOR="#0000ff">00:00:00.2000000</font>&quot;<font COLOR="#0000ff"> </font><font COLOR="#ff0000">flowControlEnabled</font><font COLOR="#0000ff">=</font>&quot;<font COLOR="#0000ff">true</font>&quot; <font COLOR="#ff0000"> inactivityTimeout</font><font COLOR="#0000ff">=</font>&quot;<font COLOR="#0000ff">00:10:00</font>&quot;<font COLOR="#0000ff"> </font><font COLOR="#ff0000">maxPendingChannels</font><font COLOR="#0000ff">=</font>&quot;<font COLOR="#0000ff">4</font>&quot;<font COLOR="#0000ff"> </font><font COLOR="#ff0000">maxRetryCount</font><font COLOR="#0000ff">=</font>&quot;<font COLOR="#0000ff">8</font>&quot; <font COLOR="#ff0000"> maxTransferWindowSize</font><font COLOR="#0000ff">=</font>&quot;<font COLOR="#0000ff">8</font>&quot;<font COLOR="#0000ff"> </font><font COLOR="#ff0000">ordered</font><font COLOR="#0000ff">=</font>&quot;<font COLOR="#0000ff">true</font>&quot;<font COLOR="#0000ff"> /&gt; &lt;</font><font COLOR="#a31515">textMessageEncoding</font><font COLOR="#0000ff"> </font><font COLOR="#ff0000">maxReadPoolSize</font><font COLOR="#0000ff">=</font>&quot;<font COLOR="#0000ff">64</font>&quot;<font COLOR="#0000ff"> </font><font COLOR="#ff0000">maxWritePoolSize</font><font COLOR="#0000ff">=</font>&quot;<font COLOR="#0000ff">16</font>&quot;<font color="#0000FF"> </font><font COLOR="#ff0000">messageVersion</font><font COLOR="#0000ff">=</font>&quot;<font COLOR="#0000ff">Soap11WSAddressing10</font>&quot;<font COLOR="#0000ff"> </font><font COLOR="#ff0000">writeEncoding</font><font COLOR="#0000ff">=</font>&quot;<font COLOR="#0000ff">utf-8</font>&quot;<font COLOR="#0000ff">&gt; &lt;</font><font COLOR="#a31515">readerQuotas</font><font COLOR="#0000ff"> </font><font COLOR="#ff0000">maxDepth</font><font COLOR="#0000ff">=</font>&quot;<font COLOR="#0000ff">32</font>&quot;<font COLOR="#0000ff"> </font><font COLOR="#ff0000">maxStringContentLength</font><font COLOR="#0000ff">=</font>&quot;<font COLOR="#0000ff">8192</font>&quot;<font COLOR="#0000ff"> </font><font COLOR="#ff0000">maxArrayLength</font><font COLOR="#0000ff">=</font>&quot;<font COLOR="#0000ff">16384</font>&quot;<font color="#0000FF"> </font><font COLOR="#ff0000">maxBytesPerRead</font><font COLOR="#0000ff">=</font>&quot;<font COLOR="#0000ff">4096</font>&quot;<font COLOR="#0000ff"> </font><font COLOR="#ff0000">maxNameTableCharCount</font><font COLOR="#0000ff">=</font>&quot;<font COLOR="#0000ff">16384</font>&quot;<font COLOR="#0000ff"> /&gt; &lt;/</font><font COLOR="#a31515">textMessageEncoding</font><font COLOR="#0000ff">&gt; &lt;</font><font COLOR="#a31515">httpTransport</font><font COLOR="#0000ff"> </font><font COLOR="#ff0000">manualAddressing</font><font COLOR="#0000ff">=</font>&quot;<font COLOR="#0000ff">false</font>&quot;<font COLOR="#0000ff"> </font><font COLOR="#ff0000">maxBufferPoolSize</font><font COLOR="#0000ff">=</font>&quot;<font COLOR="#0000ff">524288</font>&quot; <font COLOR="#ff0000">maxReceivedMessageSize</font><font COLOR="#0000ff">=</font>&quot;<font COLOR="#0000ff">65536</font>&quot;<font COLOR="#0000ff"> </font><font COLOR="#ff0000">allowCookies</font><font COLOR="#0000ff">=</font>&quot;<font COLOR="#0000ff">false</font>&quot;<font COLOR="#0000ff"> </font><font COLOR="#ff0000">authenticationScheme</font><font COLOR="#0000ff">=</font>&quot;<font COLOR="#0000ff">Anonymous</font>&quot; <font COLOR="#ff0000">bypassProxyOnLocal</font><font COLOR="#0000ff">=</font>&quot;<font COLOR="#0000ff">false</font>&quot;<font COLOR="#0000ff"> </font><font COLOR="#ff0000">hostNameComparisonMode</font><font COLOR="#0000ff">=</font>&quot;<font COLOR="#0000ff">StrongWildcard</font>&quot; <font COLOR="#ff0000"> keepAliveEnabled</font><font COLOR="#0000ff">=</font>&quot;<font COLOR="#0000ff">true</font>&quot;<font COLOR="#0000ff"> </font><font COLOR="#ff0000">maxBufferSize</font><font COLOR="#0000ff">=</font>&quot;<font COLOR="#0000ff">65536</font>&quot;<font COLOR="#0000ff"> </font><font COLOR="#ff0000">proxyAuthenticationScheme</font><font COLOR="#0000ff">=</font>&quot;<font COLOR="#0000ff">Anonymous</font>&quot; <font COLOR="#ff0000"> realm</font><font COLOR="#0000ff">=</font>&quot;&quot;<font COLOR="#0000ff"> </font><font COLOR="#ff0000">transferMode</font><font COLOR="#0000ff">=</font>&quot;<font COLOR="#0000ff">Buffered</font>&quot;<font COLOR="#0000ff"> </font><font COLOR="#ff0000">unsafeConnectionNtlmAuthentication</font><font COLOR="#0000ff">=</font>&quot;<font COLOR="#0000ff">false</font>&quot; <font COLOR="#ff0000"> useDefaultWebProxy</font><font COLOR="#0000ff">=</font>&quot;<font COLOR="#0000ff">true</font>&quot;<font COLOR="#0000ff"> /&gt; &lt;/</font><font COLOR="#a31515">binding</font><font COLOR="#0000ff">&gt; &lt;/</font><font COLOR="#a31515">customBinding</font><font COLOR="#0000ff">&gt; &lt;/</font><font COLOR="#a31515">bindings</font><font COLOR="#0000ff">&gt; &lt;</font><font COLOR="#a31515">client</font><font COLOR="#0000ff">&gt; &lt;</font><font COLOR="#a31515">endpoint</font><font COLOR="#0000ff"> </font><font COLOR="#ff0000">address</font><font COLOR="#0000ff">=</font>&quot;<a href="http://localhost:8080/WebApplication1/NewWebServiceService"><font COLOR="#0000ff">http://localhost:8080/WebApplication1/NewWebServiceService</font></a>&quot; <font COLOR="#ff0000"> binding</font><font COLOR="#0000ff">=</font>&quot;<font COLOR="#0000ff">customBinding</font>&quot;<font COLOR="#0000ff"> </font><font COLOR="#ff0000">bindingConfiguration</font><font COLOR="#0000ff">=</font>&quot;<font COLOR="#0000ff">NewWebServicePortBinding</font>&quot; <font COLOR="#ff0000"> contract</font><font COLOR="#0000ff">=</font>&quot;<font COLOR="#0000ff">ConsoleApplication1.localhost.NewWebService</font>&quot;<font COLOR="#0000ff"> </font><font COLOR="#ff0000">name</font><font COLOR="#0000ff">=</font>&quot;<font COLOR="#0000ff">NewWebServicePort</font>&quot;<font COLOR="#0000ff"> /&gt; &lt;/</font><font COLOR="#a31515">client</font><font COLOR="#0000ff">&gt; &lt;/</font><font COLOR="#a31515">system.serviceModel</font><font COLOR="#0000ff">&gt; &lt;/</font><font COLOR="#a31515">configuration</font><font COLOR="#0000ff"><code>>[/prettify]
Here are the SOAP messages that get exchanged over the wire:
====[com.sun.xml.ws.assembler.server:request]====
<?xml version="1.0" ?>
<s:Envelope xmlns:s="<a href="http://schemas.xmlsoap.org/soap/envelope/">http://schemas.xmlsoap.org/soap/envelope/</a>"
xmlns:a="http://www.w3.org/2005/08/addressing">
<s:Header>
<a:Action s:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequence</a:Action>
<a:MessageID>urn:uuid:3429a390-96df-4f26-bd8c-fc85bd8f1858</a:MessageID>
<a:To s:mustUnderstand="1">http://localhost:8080/WebApplication1/NewWebServiceService</a:To>
</s:Header>
<s:Body>
<CreateSequence xmlns="http://schemas.xmlsoap.org/ws/2005/02/rm">
<AcksTo>
<a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
</AcksTo>
<Offer>
<Identifier>urn:uuid:402432c9-b191-4912-a04a-69bbdbd1b2d3</Identifier>
</Offer>
</CreateSequence>
</s:Body>
</s:Envelope>
============
====[com.sun.xml.ws.assembler.server:response]====
<?xml version="1.0" ?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Header>
<To xmlns="http://www.w3.org/2005/08/addressing">http://www.w3.org/2005/08/addressing/anonymous</To>
<Action xmlns="http://www.w3.org/2005/08/addressing">http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequenceResponse</Action>
<MessageID xmlns="http://www.w3.org/2005/08/addressing">uuid:b51f92ee-9ab9-4a90-a61e-d5dd3a77a0f9</MessageID>
<RelatesTo xmlns="http://www.w3.org/2005/08/addressing">urn:uuid:3429a390-96df-4f26-bd8c-fc85bd8f1858</RelatesTo>
</S:Header>
<S:Body>
<ns2:CreateSequenceResponse xmlns:ns6="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:ns5="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:ns4="http://www.w3.org/2005/08/addressing" xmlns:ns3="http://schemas.microsoft.com/ws/2006/05/rm" xmlns:ns2="http://schemas.xmlsoap.org/ws/2005/02/rm">
<ns2:Identifier>uuid:d01cff2f-9192-4672-942b-2ec284a93802</ns2:Identifier>
<ns2:Accept>
<ns2:AcksTo>
<ns4:Address>http://localhost:8080/WebApplication1/NewWebServiceService</ns4:Address>
</ns2:AcksTo>
</ns2:Accept>
</ns2:CreateSequenceResponse>
</S:Body>
</S:Envelope>
============
====[com.sun.xml.ws.assembler.server:request]====
<?xml version="1.0" ?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:r="http://schemas.xmlsoap.org/ws/2005/02/rm" xmlns:a="http://www.w3.org/2005/08/addressing">
<s:Header>
<r:Sequence s:mustUnderstand="1">
<r:Identifier>uuid:d01cff2f-9192-4672-942b-2ec284a93802</r:Identifier>
<r:MessageNumber>1</r:MessageNumber>
</r:Sequence>
<a:Action s:mustUnderstand="1">sayHello</a:Action>
<a:MessageID>urn:uuid:d9c8b864-f236-40ad-a4c0-72c42565855f</a:MessageID>
<a:ReplyTo>
<a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
</a:ReplyTo>
<a:To s:mustUnderstand="1">http://localhost:8080/WebApplication1/NewWebServiceService</a:To>
</s:Header>
<s:Body>
<sayHello xmlns="http://test/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<name xmlns="">Duke</name>
</sayHello>
</s:Body>
</s:Envelope>
============
====[com.sun.xml.ws.assembler.server:response]====
<?xml version="1.0" ?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Header>
<To xmlns="http://www.w3.org/2005/08/addressing">http://www.w3.org/2005/08/addressing/anonymous</To>
<Action xmlns="http://www.w3.org/2005/08/addressing">http://test/NewWebService/sayHelloResponse</Action>
<MessageID xmlns="http://www.w3.org/2005/08/addressing">uuid:9091661c-c817-4411-b8aa-7f4f937162da</MessageID>
<RelatesTo xmlns="http://www.w3.org/2005/08/addressing">urn:uuid:d9c8b864-f236-40ad-a4c0-72c42565855f</RelatesTo>
<ns2:Sequence xmlns:ns4="http://www.w3.org/2005/08/addressing" xmlns:ns3="http://schemas.microsoft.com/ws/2006/05/rm" xmlns:ns2="http://schemas.xmlsoap.org/ws/2005/02/rm">
<ns2:Identifier>urn:uuid:402432c9-b191-4912-a04a-69bbdbd1b2d3</ns2:Identifier>
<ns2:MessageNumber>1</ns2:MessageNumber>
</ns2:Sequence>
<ns2:AckRequested xmlns:ns4="http://www.w3.org/2005/08/addressing" xmlns:ns3="http://schemas.microsoft.com/ws/2006/05/rm" xmlns:ns2="http://schemas.xmlsoap.org/ws/2005/02/rm">
<ns2:Identifier>urn:uuid:402432c9-b191-4912-a04a-69bbdbd1b2d3</ns2:Identifier>
</ns2:AckRequested>
<ns2:SequenceAcknowledgement xmlns:ns4="http://www.w3.org/2005/08/addressing" xmlns:ns3="http://schemas.microsoft.com/ws/2006/05/rm" xmlns:ns2="http://schemas.xmlsoap.org/ws/2005/02/rm">
<ns2:Identifier>uuid:d01cff2f-9192-4672-942b-2ec284a93802</ns2:Identifier>
<ns2:AcknowledgementRange Upper="1" Lower="1"></ns2:AcknowledgementRange>
</ns2:SequenceAcknowledgement>
</S:Header>
<S:Body>
<ns2:sayHelloResponse xmlns:ns2="http://test/">
<return>Hello Duke</return>
</ns2:sayHelloResponse>
</S:Body>
</S:Envelope>
============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
visualstudioRelated Topics >>Blog Links >>- Login or register to post comments
- Printer-friendly version
- arungupta's blog
- 1275 reads






Comments
Hi Arun This is very
by metro_01 - 2010-12-03 02:14
Hi Arun
This is very useful article w.r.to interoperability with .net. At the end you wrote "The same programming model will work for creating a WCF client if you add security or transactions support on the WSIT endpoint". I have tried this but getting problem.
The problem is that i have developed a secure web service in java using metro. It's working fine. I have developed a client (Console Application) using Visual Studio .Net 2010 to consume the secure java service. But i am getting the exception of "No Security Header Found" . The following is the stack trace of this error:
System.ServiceModel.FaultException was unhandled
Message=ERROR: No security header found in the message
Source=mscorlib
StackTrace:
Server stack trace:
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at test_java_client.ServiceReference1.test_VSnet_WS.Add(AddRequest request)
at test_java_client.ServiceReference1.test_VSnet_WSClient.test_java_client.ServiceReference1.test_VSnet_WS.Add(AddRequest request) in E:\.NET Programs\test_java_client\test_java_client\Service References\ServiceReference1\Reference.cs:line 91
at test_java_client.ServiceReference1.test_VSnet_WSClient.Add(Int32 a, Int32 b) in E:\.NET Programs\test_java_client\test_java_client\Service References\ServiceReference1\Reference.cs:line 98
at test_java_client.Program.Main(String[] args) in E:\.NET Programs\test_java_client\test_java_client\Program.cs:line 13
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
I think i have to set configuration of metro in VS .net . But i don't know how? I googled for a tutorial for dealing such kind of situation and trying to open articles from your blog link http://blogs.sun.com/arungupta/entry/web_services_javaone but no link available. May be more time passed.
Please tell me what should i do and if there is any useful link of a tutorial, kindly tell me.
If this is not exact place to post the question then kindly guide me where i should post my this problem.
Need urgent reply.
Thanks in advance.
Regards