Customized web service deployed OK but no result returned

Oct 12, 2009 at 8:59 PM

Hi,

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 = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]

public class AutoCompleteWebService : System.Web.Services.WebService
    {

        public AutoCompleteWebService()
        {

        }

        [WebMethod]
        [System.Web.Script.Services.ScriptMethod]
        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)
                {
                    break;
                }
                else
                    if (actor.ToLower().StartsWith(prefixText.ToLower()))
                    {
                        actorList.Add(actor);
                        k++;
                    }
            }
            return actorList;

        }

    }

2. In the web part has these main code:

using AjaxControlToolkit;

protected override void CreateChildControls()

{

base.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;
this.Controls.Add(TB_SearchSubject);

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

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";
this.Controls.Add(autoComplete);

}

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?

Thanks

Stock