Defining binding and endpoint information programmatically: SOAP/JMS interface

For the SOAP/JMS interface, we can define an endpoint and binding programmatically directly from the application code.


To supply binding and endpoint information programmatically, add the required code to the application by completing the following steps.


Procedure

  1. Create an instance of the transport binding element of the channel by adding the following code to the application:
    SoapJmsIbmTransportBindingElement transportBindingElement = new SoapJmsIbmTransportBindingElement();
    
  2. Set any required binding properties, for example, by adding the following code to the application to set the ClientConnectionMode:
    transportBindingElement.ClientConnectionMode = XmsWCFBindingProperty.AS_URI;
    
  3. Create a custom binding that pairs the transport channel with a message encoder by adding the following code to the application:
    Binding binding = new CustomBinding(new TextMessageEncodingBindingElement(), transportBindingElement);
    
  4. Create the SOAP/JMS URI. The SOAP/JMS URI that describes the IBM MQ connection details required to access the service, must be provided as the endpoint address. The address that you specify depends on whether the channel is being used for a service application or a client application.

    • For client applications, the SOAP/JMS URI must be created as an EndpointAddress as follows:
      EndpointAddress address = new EndpointAddress("jms:/queue?destination=SampleQ@QM1&connectionFactory
      =connectQueueManager(QM1)&initialContextFactory=com.ibm.mq.jms.Nojndi");
      
    • For service applications, the SOAP/JMS URI must be created as a URI as follows:
      Uri address = new Uri("jms:/queue?destination=SampleQ@QM1&connectionFactory=
      connectQueueManager(QM1)&initialContextFactory=com.ibm.mq.jms.Nojndi");
      

      For more information about endpoint addresses, see IBM MQ custom channel for WCF endpoint URI address format.

Parent topic: Create a WCF custom channel by suppling binding and endpoint information programmatically