PDA

View Full Version : WebService w/ AutoCompleteExtender - HELP



shadowboxer
02-25-2009, 12:03 PM
Hi everyone,

I'm using Spring.Net WebServices as described in SpringAir example.
My webservice name is AutoCompleteWebService. When I evoke the url directly (Spring.QA.Web/AutoCompleteWebService.asmx) it works properly.

I am trying to use it with AutoCompleteExtender from AjaxControlToolkit:

<asp:ScriptManager runat="server" ID="scriptManager" EnablePartialRendering="true" >
<Services>
<asp:ServiceReference Path = "../AutoCompleteWebService.asmx"></asp:ServiceReference>
</Services>
</asp:ScriptManager>

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>

<asp:TextBox id="txtClientAcronym" runat="server" CssClass="inputNormal" width="70px" AutoCompleteType="Disabled">*</asp:TextBox>

<cc1:AutoCompleteExtender id="AutoCompleteExtender1" runat="server" MinimumPrefixLength="1"
TargetControlID="txtClientAcronym" ServicePath = "../AutoCompleteWebService.asmx" ServiceMethod = "FindClientByAcronym" EnableCaching="true">

</ContentTemplate>
</asp:UpdatePanel>

Here's my Services.xml file:


<?xml version="1.0" encoding="utf-8" ?>
<objects>

<object id="autoCompleteWebService" name="/AutoComplete.asmx" type="Spring.Web.Services.WebServiceExporter, Spring.Web">
<property name="TargetName" value="autoComplete"/>
<property name="Name" value="AutoComplete"/>
<property name="Namespace" value="http:Spring.QA.Web/WebServices"/>
<property name="Description" value="Spring QA AutoComplete Web Service"/>
<property name="TypeAttributes">
<list>
<object type="System.Web.Script.Services.ScriptServiceAttribute, System.Web.Extensions"/>
<object type="System.Web.Services.Protocols.SoapRpcServiceAttrib ute, System.Web.Services">
<property name="Use" value="Literal" />
</object>
</list>
</property>
<property name="MemberAttributes">
<dictionary>
<entry key="FindClientByAcronym">
<object type="System.Web.Services.WebMethodAttribute, System.Web.Services">
<property name="Description" value="Return a collection of all clients"/>
</object>
</entry>
</dictionary>
</property>
</object>

<!-- Production service definitions -->
<object id="autoComplete" type="Spring.QA.Services.DefaultAutoComplete, Spring.QA.Dao">
<description>
The main service interface for the SpringAir application.
</description>
<constructor-arg name="clientDao" ref="clientDao" />
</object>

</objects>

And my service class:


public class DefaultAutoComplete : IAutoComplete
{
private IClientDao clientDao;

public DefaultAutoComplete(IClientDao clientDao)
{
#region Sanity Checks

if (clientDao == null)
{
throw new ArgumentNullException("clientDao", "The 'clientDao' argument is required.");
}

#endregion

this.clientDao = clientDao;
}

public string[] FindClientByAcronym(string acronym)
{
string value = acronym.ToLower() + "%";

ArrayList results = (ArrayList)clientDao.Load("from Client where lower(sigla) like ?", new object[] { value });
int count = results.Count;
string[] clients = new string[count];
for (int i = 0; i < count; i++ )
{
clients[i] = ((Client)results[i]).Acronym;
}
return clients;
}

}

What am I doing wrong?

Erich Eichinger
03-02-2009, 02:04 PM
Hi,

what exactly is the problem you are facing (error message, stacktrace, ...)? Did you try to debug your issue e.g. using Firefox+FireBug to nail down any Ajax issue? Are you sure the relative path "../AutoCompleteWebService.asmx" really points to your service?

just a few thoughts...

-Erich

shadowboxer
04-06-2009, 12:24 PM
Hi Erich,

Yes, i'm sure the path and service work, cause if I call the webservice directly it's working properly.
I've changed my code a bit, but still it doesn't work:



<asp:TextBox id="txtClientAcronym" runat="server" AutoPostBack="true" CssClass="inputNormal" width="70px" AutoCompleteType="Disabled" OnTextChanged="txtClientAcronym_TextChanged" >*</asp:TextBox>
<cc1:AutoCompleteExtender id="AutoCompleteExtender1" runat="server" MinimumPrefixLength="1" TargetControlID="txtClientAcronym" ServicePath="AutoCompleteWebService.asmx" ServiceMethod="FindClientByAcronym" EnableCaching="true"></cc1:AutoCompleteExtender>


Code-behind:


protected void txtClientAcronym_TextChanged(object sender, EventArgs e)
{
this.AutoCompleteExtender1.DataBind();
}

Bruno Baia
10-14-2009, 05:24 PM
hi,

You have to use ASP.NET AJAX 1.0 Spring integration (Spring.Web.Extensions) to expose your web service to javascript clients.(AjaxControlToolKit uses ASP.NET AJAX 1.0).

Documentation is here :
http://www.springframework.net/doc-latest/reference/html/ajax.html

Example is here :
Spring.Web.Extensions.Example.


Better late than never,
Bruno