How to invoke a WSIT endpoint from a WCF client ?
Posted by arungupta on April 26, 2007 at 9:05 AM EDT
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.
- Start Visual Studio
- Create a new Visual C#, Windows, Console Application.
Program.csis shown in the main Visual Studio window. - 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 andapp.configfor .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:
usingSystem; using System.Collections.Generic; using System.Text; using ConsoleApplication1.localhost;namespaceConsoleApplication1 { class Program { static void Main(string[] args) { NewWebServiceClient client = new NewWebServiceClient(); Console.WriteLine(client.sayHello("Duke")); } } } - Build the solution by selecting "
Build", "Build Solution" (default shortcut Ctrl+Shift+B). - 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" ?>
<configuration>
<system.serviceModel>
<bindings>
<customBinding>
<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" />
</textMessageEncoding>
<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" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://localhost:8080/WebApplication1/NewWebServiceService"
binding="customBinding" bindingConfiguration="NewWebServicePortBinding"
contract="ConsoleApplication1.localhost.NewWebService" name="NewWebServicePort" />
</client>
</system.serviceModel>
</configuration>
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="http://schemas.xmlsoap.org/soap/envelope/" 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 visualstudio
Related Topics >>
Blog Links >>
- Login or register to post comments
- Printer-friendly version
- arungupta's blog
- 1173 reads






Comments
Hi Arun This is very
by metro_01 - 2010-12-03 03: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