简体   繁体   中英

How to get javascript proxy from WCF service webHttpBinding

I setup all my endpoint, binding and behavior in order to consume the service using json, but now I can't figure how to generate the javascript proxy in order to access from my client javascript JQuery code through Ajax. Any ideas?

Please, don't try to suggest me to use a server side approach between WCF and the client (for example, asp.net mvc action cosuming the service), thanks.

<?xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <bindings>
      <webHttpBinding>
        <binding name="Binding1" />
      </webHttpBinding>
    </bindings>
    <services>
      <service name="IServiceForJQuery">
        <endpoint behaviorConfiguration="Behavior1"
          binding="webHttpBinding" bindingConfiguration="Binding1" name="Endpoint1"
          contract="IServiceForJQuery" />
      </service>
    </services>
    <behaviors>
      <endpointBehaviors>
        <behavior name="Behavior1">
          <enableWebScript />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>

Rick Strahl has got a blog post on this.

He has created a Script Proxy class you can use to call the service.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM