WCF Service support file jsdebug fails to load

眉间皱痕 提交于 2019-12-21 17:49:12

问题


I have a WCF service that gets called from client side JavaScript. The call fails with a Service is null JavaScript error. WebDevelopment helper trace shows that the calls to load the jsdebug support file results in a 404 (file not found) error.

Restarting IIS or clearing out the Temp ASP.Net files or setting batch="false" on the compilation tag in web.config does not resolve the problem

From the browser

https://Myserver/MyApp/Services/MyService.svc displays the service metadata

however

https://Myserver/MyApp/Services/MyService.svc/jsdebug results in a 404.

The issue seems to be with the https protocol. With http /jsdebug downloads the supporting JS file.

Any ideas?

TIA


回答1:


Figured it out!

Here is the services configuration section from web.config

Look at the bindingConfiguration attribute on the endpoint. The value "webBinding" points to the binding name="webBinding" tag in the bindings and that is what tells the service to use Transport level security it HTTPS. In my case the attribute value was empty causing the webservice request to the /js or /jsdebug file over HTTPS to fail and throw a 404 error.

<services>
      <service name="MyService">
        <endpoint address="" behaviorConfiguration="MyServiceAspNetAjaxBehavior" binding="webHttpBinding" bindingConfiguration="webBinding" contract="Services.MyService" />
      </service>
    </services>
    <bindings>
      <webHttpBinding>
        <binding name="webBinding">
          <security mode="Transport">
          </security>
        </binding>
      </webHttpBinding>
    </bindings>

Note that the bindingConfiguration attribute should be empty ("") if the service is accessed via http instead of https (when testing on local machine with no certs)

Hope this helps someone.




回答2:


If you still get the same error after all your possible work done. Just add a "AJAX Enabled WCF-Service".




回答3:


For me the issue was the following; we added MVC to a solution with routing. Our WCF services were not being ignored. I resolved this by adding the following rule (where "WCF" is the folder we keep our services in).

routes.IgnoreRoute("WCF/{*pathInfo}");

Hope that saves somebody a few hours.



来源:https://stackoverflow.com/questions/59181/wcf-service-support-file-jsdebug-fails-to-load

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!