Click here to Skip to main content
15,891,942 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I swear, I am putting as small a snippet of my code in here as I can. I have also Googled the heck out of this skanker. I am really befuddled as to why the above is happening. I have a .asmx files such as this:

ASP
<%@ WebService Language="C#" CodeBehind="MakeModelWebService.asmx.cs" Class="BSA.UI.Web.C8.TireAdvisor.MakeModelWebService" %>


And the codebehind is thus:

C#
<pre>    
    /// <summary>
    /// Summary description for MakeModelWebService
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.Web.Script.Services.ScriptService]
    public class MakeModelWebService : System.Web.Services.WebService
    {
        IAdvisorModelRepository advisorModelRepository = new AdvisorModelRepository();
        // TODO: TCL - Should Do - remove use of language and brand code from web service
        const string TESTLANGUAGE = "English";
        const string TESTBRANDCODE = "BR";
        [WebMethod]
        [ScriptMethod]
        public CascadingDropDownNameValue[] GetYears(string knownCategoryValues, string category)
        {
            try
            {
                var values = new List<CascadingDropDownNameValue>();
                foreach (string year in advisorModelRepository.GetYears(TESTLANGUAGE, TESTBRANDCODE))
                {
                    values.Add(new CascadingDropDownNameValue { name = year, value = year });
                }
                return values.ToArray();
            }
            catch (Exception ex)
            {
                File.WriteAllText(
                    Server.MapPath("~/TireAdvisor/ErrorLog.txt"),
                    ex.Message + "\r\n\r\n" + ex.Source + "\r\n\r\n" + ex.StackTrace);
                File.WriteAllText(
                    Server.MapPath("~/~/TireAdvisor/ErrorLog2.txt"),
                                        ex.InnerException.Message + "\r\n\r\n" + ex.InnerException.Source + "\r\n\r\n" + ex.InnerException.StackTrace);
                return null;
            }
        }
    }


No error logs are written on the server, so an exception did not happen. Here is the cascading drop down in my ASPX:

<tr>
  <td>
    <cm:ContentLabel ID="ContentLabel4" runat="server" ContentTag="TS-Wizard-Year" Text="Select Year" />
  </td>
  <td>
      <asp:DropDownList ID="ddlYear" runat="server" AutoPostBack="false" Font-Names="Tahoma" />
      <cm:ContentLabel ID="lblYearRequired" runat="server" ContentTag="RequiredError" Visible="false"  Width="0px" />
      <!-- JSON Drop down. Set autopostback to false and remove onselected index. Remove asyc triggers -->
      <ajaxToolkit:CascadingDropDown ID="ccdYear" runat="server" TargetControlID="ddlYear" Category="Year"  ServicePath="MakeModelWebService.asmx" EnableViewState="true" />
  </td>
</tr>


In the codebehind the cascading drop down is configured thus:

private void ConfigureCascadingDropDowns()
 {
     ccdYear.PromptText = ccdYear.EmptyText = DropDownTextDriver.GetChooseYearText(
         this.LanguageString);
     ccdMake.PromptText = ccdMake.EmptyText = DropDownTextDriver.GetChooseMakeText(
         this.LanguageString);
     ccdModel.PromptText = ccdModel.EmptyText = DropDownTextDriver.GetChooseModelText(
         this.LanguageString);
     ccdYear.PromptValue = ccdYear.EmptyValue = string.Empty;
     ccdMake.PromptValue = ccdMake.EmptyValue = string.Empty;
     ccdModel.PromptValue = ccdModel.EmptyValue = string.Empty;
     switch (UserState.SearchMode)
     {
         default:
             ccdYear.ServiceMethod = "GetYearsPageMethod";
             ccdYear.TargetControlID = ddlYear.ID;
             ccdMake.ServiceMethod = "GetMakes";
             ccdMake.TargetControlID = ddlMake.ID;
             ccdMake.ParentControlID = ddlYear.ID;
             ccdModel.ServiceMethod = "GetModelsForYearAndMake";
             ccdModel.ParentControlID = ddlMake.ID;
             ccdModel.TargetControlID = ddlModel.ID;
             break;
         case QuickSearchMode.MakeOnly:
         case QuickSearchMode.MakeAndModelOnly:
             ccdMake.ParentControlID = string.Empty;
             ccdMake.ServiceMethod = "GetAllMakes";
             ccdMake.TargetControlID = ddlMake.ID;
             ccdModel.ParentControlID = ddlMake.ID;
             ccdModel.ServiceMethod = "GetModelsByMake";
             ccdModel.TargetControlID = ddlModel.ID;
             ccdYear.ParentControlID = ddlModel.ID;
             ccdYear.ServiceMethod = "GetYearsByMakeAndModel";
             ccdYear.TargetControlID = ddlYear.ID;
             break;
     }
 }


When the drop down displays, it should display a "Choose Year:" item (the value of the ) and then the years 2011-1983. It displays "Choose Year:" and then [Method Error 500].

What am I doing wrong? How does our server need to be configured to allow this?

I've tried adding the text

<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
  <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
    <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
    <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
      <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere"/>
      <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
      <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
    </sectionGroup>
  </sectionGroup>
</sectionGroup>


to the web.config but this makes the whole site break with a 500 - Internal Server Error. What are we doing wrong? We've tried everything and this has been going on for a week.

Any hints would be greatly appreciated.
Posted

1 solution

The things you done so far is fine for me except one thing. You didn't provide the web.config section part of the consumer application. In deployment server you may have to change the url for the web service locator server. Here is one way to do so.
XML
<system.serviceModel>
   <bindings>
     <basicHttpBinding>
       <binding name="Service1Soap" closeTimeout="00:01:00" openTimeout="00:01:00"
         receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
         bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
         maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
         messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
         useDefaultWebProxy="true">
         <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
           maxBytesPerRead="4096" maxNameTableCharCount="16384" />
         <security mode="None">
           <transport clientCredentialType="None" proxyCredentialType="None"
             realm="" />
           <message clientCredentialType="UserName" algorithmSuite="Default" />
         </security>
       </binding>
     </basicHttpBinding>
   </bindings>
   <client>
     <endpoint address="http://localhost:65106/Service1.asmx" binding="basicHttpBinding"
       bindingConfiguration="Service1Soap" contract="ServiceReference1.Service1Soap"
       name="Service1Soap" />
   </client>
 </system.serviceModel>

So in the endpoint section the address is pointing to localhost:65106. You have to point to the qualified server name with the actual service url. i.e http://testserver1/Service1.asmx

Hope this will help you well.
 
Share this answer
 
Comments
Member 8724016 8-Apr-12 15:00pm    
Please can You specify exactely where to add this code because i have try it but without any good result( i'm beginner so if you can give more details please)

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900