Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    calling of WCf json service in dropdown

    Hi

    i am using smartclient power edition where i am trying to call wcf service hosted on iis (json web service ) and fetching the data of service in dropdown but i am not getting any output,its showing loading but no result.

    Please suggest what is wrong in below mentioned code or any other alternative.It would be really great help from your side.




    isc.DataSource.create({
    ID: "brand",
    dataFormat: "json",
    dataTransport: "scriptInclude",
    dataProtocol: "postMessage",

    callbackParam : "callback",
    recordXPath: "{}",
    dataURL: "http://8080/Service1.svc/GetDatabaseName",
    fields: [
    { name: "namezs"
    }
    ]
    });



    isc.DynamicForm.create({
    ID: "exampleForm",
    width: 300,
    fields: [
    {
    name: "namezs",
    type: "select",
    width: 240,
    title: "Item",
    optionDataSource: "brand",
    valueField: "namezs",
    displayField: "namezs",
    pickListWidth: 450,
    pickListFields: [
    { name: "namezs" }

    ]
    }
    ]
    });

    #2
    Take a look at the data the forums asks you to post every time.

    Comment


      #3
      Asking again in the format:


      calling wcf service hosted on iis (json web service ) and fetching the data of service in dropdown .

      1. "v8.2p_2012-04-18/PowerEdition Deployment"

      2. Internet Explorer

      3. there was no error its showing loading and nothing was loaded.

      [code]
      isc.DataSource.create({
      ID: "brand",
      dataFormat: "json",
      dataTransport: "scriptInclude",
      dataProtocol: "postMessage",

      callbackParam : "callback",
      recordXPath: "{}",
      dataURL: "http://8080/Service1.svc/GetDatabaseName",
      fields: [
      { name: "namezs"
      }
      ]
      });



      isc.DynamicForm.create({
      ID: "exampleForm",
      width: 300,
      fields: [
      {
      name: "namezs",
      type: "select",
      width: 240,
      title: "Item",
      optionDataSource: "brand",
      valueField: "namezs",
      displayField: "namezs",
      pickListWidth: 450,
      pickListFields: [
      { name: "namezs" }

      ]
      }
      ]
      });

      [code]

      sample data:

      [{"databasename":"MetaData"},{"databasename":"Report"}]

      Comment


        #4
        "{}" is not a valid XPath

        Your server's response doesn't make sense with scriptInclude transport, which requires that a JavaScript callback be written out by the server.

        http://www.smartclient.com/smartgwt/javadoc/com/smartgwt/client/types/RPCTransport.html#SCRIPTINCLUDE

        Comment


          #5
          I am facing a similar issue:
          1. "v8.2p_2012-04-18/PowerEdition Deployment"

          2. Internet Explorer

          3. there was no error its showing loading and nothing was loaded.
          4. I have a Restful, WCF service from which i am fetching the data.

          My smartclient code looks like:
          --------------------------------------------------------------------------------
          var serviceResult = isc.DataSource.create({
          ID: "simYahoo",
          dataFormat: "json",
          recordXPath: "/GetDataResult",
          dataURL: "http://localhost:2222/Service1.svc/getdata",
          fields: [
          { name: "Product" }
          ]
          });

          var list = isc.ListGrid.create({
          ID: "imageGrid",
          top: 80,
          width: "100%",
          height: 300,
          wrapCells: true,
          fixedRecordHeights: false,
          showAllRecords: true,
          alternateRecordStyles: true,
          dataSource: simYahoo
          });
          --------------------------------------------------------------------------------
          My WCF service code is like:

          public class Service1 : IService1
          {

          List<dataconnect> list = new List<dataconnect>();

          public List<dataconnect> GetData()
          {
          SqlConnection con = new SqlConnection("Data Source =.\\TFS; Database= SalesDW; User ID = SalesAnalysis; Password = NewDelhi10;");

          con.Open();
          SqlCommand cmd = new SqlCommand("SELECT distinct table_name FROM INFORMATION_SCHEMA.COLUMNS", con);
          SqlDataReader dr;

          dr = cmd.ExecuteReader();

          while (dr.Read())
          {
          dataconnect dc = new dataconnect();
          dc.Product = dr["table_name"].ToString();
          list.Add(dc);
          }
          con.Close();

          return list;
          }
          }

          [ServiceContract]
          public interface IService1
          {
          [WebGet(ResponseFormat = WebMessageFormat.Json, UriTemplate = "GetData", BodyStyle = WebMessageBodyStyle.Wrapped)]
          [OperationContract]
          List<dataconnect> GetData();
          }

          ------------------------------------------------------------------------------------------
          SAMPLE DATA:

          {"GetDataResult":[{"Brand":null,"Month":null,"Product":"AccountingPeriodDates","Year":null,"nameks":null,"namezs":null,"quill":null,"value":0}
          ]}

          Comment


            #6
            You need to call fetchData() on the grid to cause it to actually fetch.

            Comment


              #7
              Thanks SmartClient for your reply.

              I set autoFetchData: true for the grid, but now i get the error as :
              " Transport error - HTTP code: 405 for URL: http://localhost:2222/Service1.svc/getdata (via proxy: http://localhost:2221/isomorphic/HttpProxy) "

              My method in the WCF service contract looks like
              [WebGet(ResponseFormat = WebMessageFormat.Json, UriTemplate = "GetData", BodyStyle = WebMessageBodyStyle.Wrapped)]
              [OperationContract]
              List<dataconnect> GetData();

              The error indicates that the method that I am trying on the service is not allowed. So I changed the method to post, for my web method as below:-
              [WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json, UriTemplate = "GetData", BodyStyle = WebMessageBodyStyle.Wrapped)]
              [OperationContract]
              List<dataconnect> GetData();

              However, still i get the same error. Can you please advise what i am doing wrong ?. Thanks in advance.

              Comment


                #8
                The results window from the developer console shows error like:
                ------------------------------------------
                09:20:00.555:TMR9:WARN:RPCManager:Transport error - HTTP code: 405 for URL: http://localhost:2222/Service1.svc/getdata (via proxy: http://localhost:2221/isomorphic/HttpProxy)undefined - response: {status: -90,
                data: "Transport error - HTTP code: 405 for URL..."[140],
                httpResponseCode: 405,
                transactionNum: 0,
                clientContext: Obj,
                httpHeaders: Obj,
                context: Obj,
                startRow: 0,
                endRow: 0,
                totalRows: 0}
                ------------------------------------------

                Cant provide the server logs from the developer console as i Get error :
                Failed to get log data - error: Transport error - HTTP code: 405 for URL: http://localhost:2221/isomorphic/IDACall?isc_rpc=1&isc_v=8.3&isc_xhr=1&isc_noLog=1&isc_noLog=1

                Comment


                  #9
                  It's your WCF server returning the 405 result, not SmartClient. We can't help you troubleshoot what's wrong with your server configuration.

                  Comment


                    #10
                    I believe its an issue with smartclient because if i use jquery than there is no problem in calling method from the WCF service.

                    Comment


                      #11
                      That's nice, but you still have to actually troubleshoot the issue to find out why the requests are different.

                      Comment

                      Working...
                      X