Click here to Skip to main content
13,050,429 members (79,269 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I am trying to return a generic list from a WCF. But return an "unknown" error. Can anyone help me out to solve this.

in IService.cs
public interface IServiceLP18
[WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
List<lp18wcf.servicelp18.statecls> GetAllStates();

in ServiceLP18
public class ServiceLP18 : IServiceLP18
  public class StateCls
            public string StateID;           
            public string StateName;
        public List<StateCls> GetAllStates()
            List<StateCls> StateList = new List<StateCls>();
            for (int i = 0; i < 10; i++)
                StateCls tempRow = new StateCls();               
                tempRow.StateID = i.ToString();
                tempRow.StateName = "Sate " + i.ToString();
            return StateList;


In calling.html page
function CallGetStates() {
               Type : "POST",
               url: "http://localhost:50609/ServiceLP18.svc/GetAllStates", 
               data: "{}", 
               contentType: "application/json; charset=utf-8", 
               dataType: "jsonp", 
               processdata: true, 
               success: function (response) {
                   var statess = response.d;
                   $.each(statess, function (index, LpStates) {
               error: ServiceFailed// When Service call fails
Posted 6-May-13 4:20am
ryanb31 6-May-13 10:31am
Where is the error occurring?

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

The JSON version doesn't work because it's a cross-origin call (see: Same Origin Policy:[^]). Does the Google URL shortener have a JSON-P API? It has to explicitly support it. (Also, JSON-P can't be POST; by its nature it's a GET.)

Update: Looks like they don't support it yet, but there's an open enhancement request.[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 8 May 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100