asp.net - WCF - call same service from client and server side -


I have a simple WCF service that I call server side from the code back through service context Used for work and was automatically setup by Visual Studio and using SOAP because I think that is the compulsive WSHttpBinding.

I want to use the same WCF service, but it's AJAX (). I am trying to implement this by them.

But if I make changes to work on behalf of the client, then I have to add the decoration below which I think that will break the work on the server side and also the system.serviceModel in web.config Sections change.

  [WebInvoke (method = "post", bodystyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)]  

I How can I use a WCF service that can be called both from server side and client side (jQuery / AJAX)?

Or in any other way, it may be in the wrong words, can there be several bindings in one endpoint?

  • contract
  • hence a closing point in WCF ABC

    • Address
    • binding
    • contract
    • therefore: no, a single endpoint No can have multiple bindings but you can have several end points for the same contract!

      So if you want to basically expose two methods with SAP and the same functionality on the rest, you will need two endpoints.

      You can define your own service method that you made both SOAP and REST callable as shown in that link.

      Then you need two different points:

         & Lt; Endpoint address = "http: //YourServer/YourVirtualDir/YourService2.svc" binding = "WebHttpBinding" behaviorConfiguration = "webCallable" contract = "IYourService" /> & Lt; / Services & gt; & Lt; / Services & gt;  

      You must define a finale behavior in which & lt; WebHttp / & gt; Behavior is included - or you need to use an * .svc file

      As you can see , Now you have two separate endpoint (two different * .svc files in a rare directory), two separate addresses - but both share the same contract (defined by the same operation).


    Comments

    Popular posts from this blog

    windows - Heroku throws SQLITE3 Read only exception -

    lex - Building a lexical Analyzer in Java -

    python - rename keys in a dictionary -