0

I'm new to WCF world. i'm having a solution which contains Web App(which has JQuery Ajax call to WCF services application which is another project in the solution. After 2 days of working(cracking) i'm in a state which i able pass request and get response enter image description here

but while try to show that in alert gives me 200 parser Error.enter image description here

Any help will be highly appreciate

Further Ref

$.ajax({
                    async: true,
                    type: 'GET', //GET or POST or PUT or DELETE verb
                    url: 'http://localhost:61057/Service1.svc/GetCustomer', // Location of the service
                    dataType: 'jsonp', //Expected data format from server
                    success: function (data) {//On Successfull service call
                        ServiceSucceeded(data);
                    },
                    error: function () { ServiceFailed(Data); } // When Service call fails
                });

Web.config

  <system.serviceModel>
    <services>
      <service name="FIN.Services.Service1" behaviorConfiguration="DefaultBehavior">
        <endpoint address="http://localhost:61057/service1.svc" binding="webHttpBinding" contract="FIN.Services.IService1" behaviorConfiguration="AjaxBehavior">
          <identity>
            <dns value="locahost"/>
          </identity>
        </endpoint>
        <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex"/>
      </service>
    </services>
    <bindings>
      <webHttpBinding>
        <binding name="webBinding">
          <security mode="None">
          </security>
        </binding>
      </webHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="DefaultBehavior">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="AjaxBehavior">
          <enableWebScript/>
        </behavior>

      </endpointBehaviors>

    </behaviors>
  </system.serviceModel>

service interface :

[WebInvoke(ResponseFormat = WebMessageFormat.Json, Method = "GET", BodyStyle = WebMessageBodyStyle.WrappedRequest, RequestFormat = WebMessageFormat.Json)]
        [OperationContract]
        string GetCustomer();
Balaji Rajan
  • 47
  • 12
  • Since you are jumping ports, take a look here: http://stackoverflow.com/questions/7234599/cors-support-within-wcf-rest-services/7770206#7770206 – granadaCoder May 16 '13 at 19:50

2 Answers2

0

If you need no argument, add following in your ajax call ..

data: "{}",

gunvant.k
  • 1,096
  • 1
  • 10
  • 15
0

You are using jsonp,means you want to call cross domain service. For cross domain service you url should be like below

http://localhost:61057/Service1.svc/GetCustomer?callback=?

and also you have to make some changes in web.config

Check out the following link for complete example

Calling cross domain service in wcf

santosh singh
  • 27,666
  • 26
  • 83
  • 129