Building WCF client applications using a client proxy with programmatic configuration
Before you begin
- Add a reference to the custom channel IBM.XMS.WCF.dll file to the project. The IBM.XMS.WCF.dll is in the WMQInstallDir\bin directory where WMQInstallDir is the directory that IBM MQ is installed in.
- Add a using statement to the IBM.XMS.WCF namespace, for example: using IBM.XMS.WCF
- Create an instance of th' binding element and endpoint of the channel as described in: Creating a WCF custom channel by suppling binding and endpoint information programmatically
If changes to the binding properties of the channel are required, complete the following steps.
- Add the binding properties to transportBindingElement as shown in the following figure:
SoapJmsIbmTransportBindingElement transportBindingElement = new SoapJmsIbmTransportBindingElement(); Binding binding = new CustomBinding(new TextMessageEncodingBindingElement(), transportBindingElement); EndpointAddress address = new EndpointAddress("jms:/queue?destination=SampleQ@QM1&connectionFactory= connectQueueManager(QM1)&initialContextFactory=com.ibm.mq.jms.Nojndi");
- Create the client proxy as shown in the following figure, where binding and endpoint address are the binding and endpoint address configured in step 1 and passed in:
MyClientProxy myClient = new MyClientProxy(binding, endpoint address); try { myClient.myMethod("HelloWorld!"); myClient.Close(); } catch (TimeoutException e) { Console.Out.WriteLine(e); myClient.Abort(); } catch (CommunicationException e) { Console.Out.WriteLine(e); myClient.Abort(); } catch (Exception e) { Console.Out.WriteLine(e); myClient.Abort(); }