1

I have written one wcf Service with netHttpBinding binding and hosted in II8(windows server 2012).The interfaces are like the bellow.

[ServiceContract(CallbackContract = typeof(IDuplexCallbackContract))]
public interface IHelloWebSocket
{
   [OperationContract(IsOneWay = true, Action = "*")] 
   void SayHelloDuplexReceive(string name);
}

[ServiceContract]
public interface IDuplexCallbackContract
{
    [OperationContract(IsOneWay = true, Action = "*")] 
    void SayingHelloSend(string message);
}

now I have the service class implementation like the bellow..

 [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Reentrant)]
public class HelloWebSocket : IHelloWebSocket
{
    /// <summary>
    /// Call back instance called from service to client.
    /// </summary>
    IDuplexCallbackContract _callback = null;

    public HelloWebSocket()
    {
        _callback =
            OperationContext.Current.GetCallbackChannel<IDuplexCallbackContract>();
    }

    public void SayHelloDuplexReceive(string name)
    {
        _callback.SayingHelloSend("Hello " + name + " by WebSockets");

        //return "Hello " + name;
    }
}

and the web config like the bellow..

<system.serviceModel>
     <services>
       <service name="WebSocketUndersranding.HelloWebSocket">
          <endpoint address=""
            binding="netHttpBinding"
            contract="WebSocketUndersranding.IHelloWebSocket"/>
     </service>
    </services>
     <behaviors>
          <serviceBehaviors>
              <behavior name="">
                  <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
                 <serviceDebug includeExceptionDetailInFaults="false" />
             </behavior>
         </serviceBehaviors>
     </behaviors>
      <serviceHostingEnvironment aspNetCompatibilityEnabled="true"
           multipleSiteBindingsEnabled="true" />
   </system.serviceModel>

Now How Can I call the Service from the HTML5 client.??

My Service URL is a link

I am trying to write the client var websocket = new WebSocket(uri); but what should I put in the "uri" to call the service.I am not able to get..???

Thanks, Arijit

Arijit
  • 93
  • 3
  • 13
  • I have posted an answer on the similar topic here: [wcf self hosted websocket service with javascript client][1] [1]: http://stackoverflow.com/questions/24239953/wcf-self-hosted-websocket-service-with-javascript-client/26527058#26527058 – Amid Oct 23 '14 at 11:32