开发者

Consuming a WCF service from Javascript - getting HTTP 400 on requests for jsdebug

开发者 https://www.devze.com 2023-03-20 09:34 出处:网络
I\'m trying to create a simple JavaScript test front-end for my WCF service, but the front-end isn\'t working.I\'ve traced the problem back to where the web page asks the service for http://..../myser

I'm trying to create a simple JavaScript test front-end for my WCF service, but the front-end isn't working. I've traced the problem back to where the web page asks the service for http://..../myservice.svc/jsdebug (which, as I understand it, returns the JavaScript code for the proxy client that the web page can use to access the service) - this request is returning HTTP 400 -Bad Request.

In an effort to reduce the problem 开发者_Go百科to its essentials, I've found I can replicate the problem simply:

  • Open Visual Studio 2010
  • Create a new project of type WCF Service Application
  • Build
  • Run
  • In a browser navigate to http://localhost:portnumber/Service1.svc/jsdebug

The result is that the server returns HTTP 400 - Bad Request

What's going on here?

UPDATE: The .svc file in is:

<%@ ServiceHost Language="C#" Debug="true" Service="WebDataProxy.WebDataProxy" CodeBehind="WebDataProxy.svc.cs" %>

The service interface looks like:

namespace WebDataProxy
{
    [ServiceContract(Namespace = "http://example.com/WebDataProxy")]
    public interface IWebDataProxy
    {
        [OperationContract]
        List<DataResponse> GetDataEx(List<DataRequest> requests);

        [OperationContract]
        DataResponse GetDataTest(DataRequest request);

        [OperationContract]
        string Hello(string input);
    }
}


Hi you can check this post will help you

Article is about calling cross domain wcf service but it also works for same domain

http://pranayamr.blogspot.com/2011/06/calling-cross-domain-wcf-service-using.html

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号