WCF Client User

This guide provides information on how to install a WCF user in Ozeki NG SMS Gateway. With the help of this WCF user you will be able to forward incoming messages to a WCF service (WCF: Windows Communication Foundation) that will process the messages.

Requirements:

You need an installed Ozeki NG SMS Gateway: Download Ozeki NG SMS Gateway

System architecture

If you create a WCF user in Ozeki NG SMS Gateway, the system will work as follows: This created WCF user will be able to forward all incoming messages to a WCF service. As Figure 1 demonstrates, messages from mobile phones are received and processed by the WCF user of Ozeki NG SMS Gateway. This WCF user then forwards messages to the WCF service using WSHttpBinding binding. Finally, the WCF service returns a response with the same type (OZmessage object) and also via WSHttpBinding binding.

system architecture
Figure 1 - System architecture

Configuration steps

  1. Start Ozeki NG SMS Gateway
  2. Create a new SMS WCF user in Ozeki NG SMS Gateway. To do so click on Add new user or application and select SMS WCF user in the list (Figure 2).

    install wcf user
    Figure 2 - Install WCF user

  3. Set the URL of the WCF service by clicking on WCF service settings and on General tab define the Service URL. In our example it is http://localhost:1165/WCFServiceForNG.svc (Figure 3).

    provide service url
    Figure 3 - Provide service URL

If you specified the proper parameter, the connection has been created with the WCF service you wish to use. From that time all the incoming messages of the user will be forwarded to the WCF service.

Ozeki NG SMS Gateway communicates via WSHttpBinding binding with the WCF service and it uses Windows Authentication.

Ozeki NG SMS Gateway's requirements for WCF service of third parties:

The service needs to be described with IWCFServiceForNG interface. This interface has to include the operation contract defined by Ozeki Informatics Ltd:

[OperationContract]
OZmessage OnMessageReceived(OZmessage msg );

The operation contract receives an OZmessage object as a parameter. It contains the message ID, the phone number of sender and recipient, the text of the message, and the message type. Finally, it saves the received message. In our example the message has been saved to Driver C into test.txt file.

public OZmessage OnMessageReceived(OZmessage msg )
            {
                FileStream file = new FileStream("C:\\test.txt",
                FileMode.OpenOrCreate | FileMode.Append, FileAccess.Write);

                StreamWriter sw = new StreamWriter(file);

                sw.WriteLine(msg.Recipient + ": " + msg.MessageData);
                sw.Close();
                file.Close();
                return msg;
            }  

The operation contract can be used for arbitrary functions in this way users can modify the body of the function. Please note that further operation contracts are not supported by Ozeki.

To operate properly you need to create OZmessage that takes part in the communication process:

Source code

[DataContract]
public class OZmessage
{
    string messageID;
    string sender;
    string recipient;
    string messageData;
    string messageType;

    [DataMember]
    public string MessageID
    {
        get { return messageID; }
        set { messageID = value; }
    }

    [DataMember]
    public string Sender
    {
        get { return sender; }
        set { sender = value; }
    }

    [DataMember]
    public string Recipient
    {
        get { return recipient; }
        set { recipient = value; }
    }

    [DataMember]
    public string MessageData
    {
        get { return messageData; }
        set { messageData = value; }
    }

    [DataMember]
    public string MessageType
    {
        get { return messageType; }
        set { messageType = value; }
    }

 }

Please note that any discrepancy from this code will result in errors.

You can also download an operating example for WCF service: WCFServiceForNG.rar

More information