Customized web service deployed OK but no result returned

Oct 12, 2009 at 9:59 PM


I use WSPBuilder to build a web part and a web service (AutoCompleteWebService.asmx). The web part has Ajax functions and there is an Ajax AutoCompleteExtender inside the web part.

1. The AutoCompleteWebService.asmx has these code:

[WebService(Namespace = "")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

public class AutoCompleteWebService : System.Web.Services.WebService

        public AutoCompleteWebService()


        public System.Collections.Generic.List<string> GetSubjects(string prefixText, int count, string contextKey)

            if (count == 0)
                count = 10;

            string[] actors = new string[] {"Takei, George","George Takei","Shatner, William","William Shatner","Doohan, James","James Doohan","Dorn, Michael",
"Michael Dorn","Nichols, Nichelle","Nichelle Nichols"};
            System.Collections.Generic.List<string> actorList =
            new System.Collections.Generic.List<string>();
            int k = 0;
            foreach (string actor in actors)
                if (k == count)
                    if (actor.ToLower().StartsWith(prefixText.ToLower()))
            return actorList;



2. In the web part has these main code:

using AjaxControlToolkit;

protected override void CreateChildControls()



//****This path does not work

//string strPath = "../12/TEMPLATE/LAYOUTS/AutoCompleteWebService.asmx";

/****This path works if making two steps: 1) Copying the AutoCompleteWebService.asmx file to the directory "wss\VirtualDirectories\80" in IIS of the SharePoint server. 2) Define this: string strPath = "http://ServerName:80/AutoCompleteWebService.asmx"


string strPath = "http://ServerName:80/AutoCompleteWebService.asmx";                               

TB_SearchSubject = new TextBox();

TB_SearchSubject.Attributes.Add("id", "TB_SearchSubject");
TB_SearchSubject.ID = "TB_SearchSubject";
TB_SearchSubject.Width = 120;

System.Web.UI.HtmlControls.HtmlGenericControl div = new System.Web.UI.HtmlControls.HtmlGenericControl();
div.ID = "ListPlacement";
div.Attributes["style"] = "height:300px; overflow-y:scroll;";

autoComplete = new AutoCompleteExtender();

autoComplete.ID = "AutoComplete1";
autoComplete.MinimumPrefixLength = 1;
autoComplete.CompletionSetCount = 20;
autoComplete.CompletionInterval = 1000;
autoComplete.DelimiterCharacters = ";, :";
autoComplete.CompletionListElementID = "ListPlacement";
autoComplete.UseContextKey = true;
autoComplete.EnableCaching = true;
autoComplete.ServicePath = strPath;  
autoComplete.ServiceMethod = "GetSubjects";
autoComplete.TargetControlID = "TB_SearchSubject";


3. When deploying the project to SharePoint server, the customized web service file AutoCompleteWebService.asmx is placed to the directory in SharePoint ../12/TEMPLATE/LAYOUTS.  I have checked it is so. As described in step 2, if the web service path for AutoCompleteExtender is "../12/TEMPLATE/LAYOUTS/AutoCompleteWebService.asmx", the web service returns a lot of "undefined" items (no result at all). However, if copying the AutoCompleteWebService.asmx file to the directory "wss\VirtualDirectories\80" in IIS of the SharePoint server and define this: string strPath = "http://ServerName:80/AutoCompleteWebService.asmx", the web service works and returns result.


So, the question is whether WSPBuilder deploys the customized web service file to a correct directory folder in SharePoint or not?