SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: AJAX Chapter 7

  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2007
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    AJAX Chapter 7

    Hi,

    In the source code example of chapter 7, the author shows how to use the Ajax object to call a PHP page asynchronously like this:

    proxyURI = '/webservices2_proxy.php' +
    '?search=' + escape(self.searchText) +
    '&service=' + self.service +
    '&dt=' + dt.getTime;

    self.ajax.doGet(proxyURI, self.handleResp, 'xml');

    However, I do not use PHP. I use ASP.NET and decided to create a simple web service to return xml like this:

    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.Web.Script.Services.ScriptService]
    public class Service : System.Web.Services.WebService {

    public Service () {}

    [WebMethod]
    [ScriptMethod(UseHttpGet = false, ResponseFormat = ResponseFormat.Xml)]
    public XmlDocument getXml(string strService)
    {
    //System.Threading.Thread.Sleep(100000);
    XmlDocument xml = new XmlDocument();

    if (strService == "WebDev")
    {
    xml.LoadXml(@"<?xml version=""1.0"" encoding=""UTF-8""?><ItemSearchResponse><OperationRequest><HTTPHeaders><Header Name=""UserAgent"" Value=""""></Header>...");
    }
    else if (strService == "TV")
    {
    xml.LoadXml(@"<?xml version=""1.0"" encoding=""UTF-8""?><ItemSearchResponse><OperationRequest><HTTPHeaders><Header Name=""UserAgent"" Value=""""></Header>....");
    }
    return xml;

    }

    }


    The problem is that I am not sure how to call this web service from the Ajax class and would appreciate if someone could help me to figure out how to do that. This is what I have tried but to no avail:

    proxyURI = 'Service.asmx+
    '?search=' + escape(self.searchText) +
    '&service=' + escape(self.service) +
    '&dt=' + dt.getTime();

    self.ajax.doGet(proxyURI, self.handleResp, 'xml');

    I do not get an error here but the xml in the client is empty.
    +++++

    proxyURI = 'Service.asmx/getXml+
    '?search=' + escape(self.searchText) +
    '&service=' + escape(self.service) +
    '&dt=' + dt.getTime();

    self.ajax.doGet(proxyURI, self.handleResp, 'xml');

    Using the method name in the proxyURI throws an error.

    I would like to give a suggestion to the author. Would it be better if in future you produced source code for both PHP and ASP.NET?

    I am looking forward to your reply.

    Cheers

    C

  2. #2
    SitePoint Enthusiast
    Join Date
    Jul 2007
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I will try to make my question simpler:

    How can I call a .NET web service using the Ajax class provided by the author:

    Cheers

    C


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •