the server method '' failed

8 posts, 0 answers
  1. Ekjot
    Ekjot avatar
    24 posts
    Member since:
    Dec 2011

    Posted 08 Apr 2012 Link to this post

    Hello

    I am using a web service like the demo to populate the items in the RadComboBox on demand. This is all working find when i am running the program through VS2010 but is failing when I try through IIS.

    Also it works for Http and does not work for Https so I think the solution lies there somewhere. 

    Here is my .aspx:

    <telerik:RadComboBox AutoPostBack="true" ID="txtGelPackProdCode" runat="server" EnableLoadOnDemand="true" ShowMoreResultsBox="true" EnableVirtualScrolling="true" EmptyMessage="Enter here..." onselectedindexchanged="txtGelPackProdCode_SelectedIndexChanged">
    <WebServiceSettings Path="MasterFormulaWebService.svc" Method="LoadProductData" />
    </telerik:RadComboBox>

    this is the svc method:

    public RadComboBoxData LoadProductData(RadComboBoxContext context)
           {
               string text = context.Text.Trim() + '%';
     
               DataTable data = ProductDAO.ViewData2(text, "RadCombo");
     
               List<RadComboBoxItemData> result = new List<RadComboBoxItemData>(context.NumberOfItems);
               RadComboBoxData comboData = new RadComboBoxData();
     
               try
               {
                   int itemsPerRequest = 10;
                   int itemOffset = context.NumberOfItems;
                   int endOffset = itemOffset + itemsPerRequest;
                   if (endOffset > data.Rows.Count)
                   {
                       endOffset = data.Rows.Count;
                   }
                   if (endOffset == data.Rows.Count)
                   {
                       comboData.EndOfItems = true;
                   }
                   else
                   {
                       comboData.EndOfItems = false;
                   }
                   result = new List<RadComboBoxItemData>(endOffset - itemOffset);
                   for (int i = itemOffset; i < endOffset; i++)
                   {
                       RadComboBoxItemData itemData = new RadComboBoxItemData();
                       itemData.Text = data.Rows[i]["prod_code"].ToString().Trim();
                       itemData.Value = data.Rows[i]["name"].ToString().Trim();
                       result.Add(itemData);
                   }
                   if (data.Rows.Count > 0)
                   {
                       comboData.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), data.Rows.Count.ToString());
                   }
                   else
                   {
                       comboData.Message = "No matches";
                   }
               }
               catch (Exception e)
               {
                   comboData.Message = e.Message;
               }
               comboData.Items = result.ToArray();
               return comboData;
           }


    and this is the webconfig:

    <system.serviceModel>
        <behaviors>
          <endpointBehaviors>
            <behavior name="Reena.Master.MasterFormulaWebServiceAspNetAjaxBehavior">
              <enableWebScript />
            </behavior>
          </endpointBehaviors>
        </behaviors>
          <serviceHostingEnvironment aspNetCompatibilityEnabled="true"
            multipleSiteBindingsEnabled="true"
              
     
          />
           
        <services>
          <service name="Reena.Master.MasterFormulaWebService">
            <endpoint address="" behaviorConfiguration="Reena.Master.MasterFormulaWebServiceAspNetAjaxBehavior"
              binding="webHttpBinding" contract="Reena.Master.MasterFormulaWebService" />
          </service>
        </services>
          <bindings>
              <webHttpBinding>
                  <binding name="webBinding">
                      <security mode="None">
                      </security>
                  </binding>
              </webHttpBinding>
          </bindings>
      </system.serviceModel>


    What am I doing wrong? Thanks
  2. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 11 Apr 2012 Link to this post

    Hi,

    Probably the problem is caused by an authentication issue In general the web service consumed by the RadComboBox should allow anonymous access. Please try to add the following lines to your web config file:
    <location path="Reena.Master.MasterFormulaWebService.svc">  
        <system.web>      
            <authorization>
                <allow users="*" />      
            </authorization>  
        </system.web>
    </location>

    Regards,
    Dimitar Terziev
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ekjot
    Ekjot avatar
    24 posts
    Member since:
    Dec 2011

    Posted 16 Apr 2012 Link to this post

    Hi!

    Thanks for the reply. I tried this and it still causes the error. Any other suggestions?
  5. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 19 Apr 2012 Link to this post

    Hi,

    After inspecting the code snippet from your web config file I've noticed that you are missing a setting in your service configuration:
    <service name="Reena.Master.MasterFormulaWebService">
            <endpoint address="" behaviorConfiguration="Reena.Master.MasterFormulaWebServiceAspNetAjaxBehavior"
              binding="webHttpBinding" contract="Reena.Master.MasterFormulaWebService" />
            <endpoint address="" behaviorConfiguration="Reena.Master.MasterFormulaWebServiceAspNetAjaxBehavior"
                    binding="webHttpBinding" bindingConfiguration="secureBinding contract="Reena.Master.MasterFormulaWebService" />
          </service>

    Please add the above suggested setting to your configuration and let us know of the results.

    Greetings,
    Dimitar Terziev
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  6. Ekjot
    Ekjot avatar
    24 posts
    Member since:
    Dec 2011

    Posted 20 Apr 2012 Link to this post

    I added the lines you asked in the Web.Config and it is still giving me that error. Http stopped working too now when I added that line :/. 


    <system.serviceModel>
        <behaviors>
          <endpointBehaviors>
            <behavior name="Reena.Master.MasterFormulaWebServiceAspNetAjaxBehavior">
              <enableWebScript />
            </behavior>
          </endpointBehaviors>
        </behaviors>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
     
        <services>
          <service name="Reena.Master.MasterFormulaWebService">
            <endpoint address="" behaviorConfiguration="Reena.Master.MasterFormulaWebServiceAspNetAjaxBehavior" binding="webHttpBinding" bindingConfiguration="secureBinding" contract="Reena.Master.MasterFormulaWebService" />
          </service>
        </services>
        <bindings>
          <webHttpBinding>
            <binding name="webBinding">
              <security mode="None">
              </security>
            </binding>
          </webHttpBinding>
        </bindings>
      </system.serviceModel>
    </configuration>
  7. Cat Cheshire
    Cat Cheshire avatar
    128 posts
    Member since:
    Jun 2010

    Posted 25 Apr 2012 Link to this post

    You can try the configuration settings described in this article:
    http://www.telerik.com/help/aspnet-ajax/combobox-load-on-demand-wcf-service.html
  8. Tad
    Tad avatar
    15 posts
    Member since:
    Jul 2007

    Posted 23 Jan 2013 Link to this post

    I realize this thread is very old, but I have run into very similar problems with "Server Methox X failed", and found a workaround.

    I discovered that the problem was related to having multiple address bindings on the same web site on the server (e.g. www.mydomain.com and mydomain.com bound to the same site).

    I worked around the problem (kludgey, but it worked) by replicating the web site in IIS for each binding, so that each site was only bound once (but each pointing to the same code directory).

    Forgive me if this has already been reported elsewhere on this support site, but I never found it.  Not sure what the problem in IIS is, or why it was throwing an error, but this workaround got me back in business.

    --Tad 
  9. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 28 Jan 2013 Link to this post

    Hi Tad,

    The reason for this problem with the web service invocation is indeed related to the settings defined in the web config file as well as the IIS settings. Thank you for sharing your solution with the community.

    Regards,
    Dimitar Terziev
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017