My WCF service is that collect the server's information and send it to the client. The client has a functionality of visualizing the infomation on the dashboard. Consierations of this solution are as the follow:
- The Server can push data to the client at any time.
- The Client can invoke methods of the server.
PollingDuplexHpptBinding has been introduced since Silverlight 2 Beta. ( I've promgrammed in Silverlight 3.)
The Silverlight SDK states the following about how communication works between a Silverlight client and a duplex service:
"The Silverlight client periodically polls the service on the network layer, and checks for any new messages that the service wants to send on the callback channel. The service queues all messages sent on the client callback channel and delivers them to the client when the client polls the service."
PollingDulexHttpBinding's remkarable features is that communicate with sliverlight client through WCF Message type.
1. You should convert your data or class into Message type
public void send (object data)
{
Message msg = Message.CreateMessage(MessageVersion.Soap11, "Silverlight/IService/Receive", data);
//Method that send data to the client
}
2. It keeps reference of the client on the server.
3. Place crossdomain.xml, clientaccesspolicy.xml on your root domain in IIS server.
Please add a binding on IIS server if you want to run WCF service on multi-host environment which have same IP but different domain name.
e.g.
Suporse there are some hosts run on the same IIS.
Host 1: name: http://www.testserver1.com/ 123.123.123.111 80 port
Host 2: name: http://www.testserver2.com/ 123.123.123.111 80 port
Host 3: name: http://www.alltest.com/ 123.123.123.111 80 port
You want to add WCF service on the port no. 40005
If you not add this on multi host, you encounter an error related crossdoamin in your Silverlight client. you may be confused to meet the error again despite have been added clientaccesspolicy.xml on the root domain.
Following Links are helpful in programming:
http://msdn.microsoft.com/en-us/library/cc645028(VS.95).aspx
http://weblogs.asp.net/dwahlin/archive/2008/06/16/pushing-data-to-a-silverlight-client-with-wcf-duplex-service-part-i.aspx
Message class: http://msdn.microsoft.com/en-us/library/system.servicemodel.channels.message.aspx
댓글 없음:
댓글 쓰기