Showing posts with label url. Show all posts
Showing posts with label url. Show all posts

Wednesday, March 21, 2012

URL parameters within Atlas enabled Web Service

I was able to test my Web Service by passing in the parameters via an URL string. (i.e. localhost/service.asmx/GetNames?id=1) But since I "Atlas enabled" my Web Service, this functionality no longer works. I receive the error,Request format is unrecognized for URL unexpectedly ending in...

I would like to have the flexibility of passing in URL parameters to some of the methods. Is this just not possible?

Thanks in advance.

Juan

Juan,

You could try a different approach. Check out a tool called Web Service Studio. You give it the url to your service, http://localhost/service.asmx, and it will discover all of the methods available at that service and what their parameters are. Then, type your test parameters into the text boxes and click the Invoke button. That will call the web service and display the results.

One advantage of using this tool is that you can test a web service even if its web.config is set up to disallow GETs and POSTs.

Here is a link to the tool:

http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=65a1d4ea-0f7a-41bd-8494-e916ebc4159c

Mindreef SOAPscope is another, more sophisticated tool, but it is not free:

http://www.mindreef.com/

- Brandon


Thanks! This will do just fine.

Juan

URL rewriting not working with ATLAS ( AJAX 1.0 )

Hello All,

I am doing a URL rewrite with help of Scott Mitchell's URL rewrite module. I am redircting all requests from abc.aspx to abc.html. This is working fine for me on normal aspx pages.

But when I am using AJAX v 1.0 on one page. I am not getting the AJAX behavior when page is request by URL rewrite .

Example I have a updatepanel on xyz.aspx. When I access that page bu url http://mysite/xyz.aspx all is working fine. But when I access page by URL http://mysite/xyz.html (for URL rewrite to work ) . AJAX is not working.

Any Ideas ??

Thanks

An ASPX page only works when served through the appropriate ISAPI filter. By changing the filetype, you're actually changing how the server will handle the file. Open IIS, right click your application and choose "Properties" Click on the "Configuration" button under Application Settings section. Add an entry for .html that mirrors the settings found for .aspx. That should force IIS to treat your renamed .html file as an ASPX page.

Hope this helps,

-Tony


Hello Tony,

We are doing that. All extensions are configured to be handled by ASP.NET worker process.

I think I need to check web.config for Ajax web services.

Thanks for reply

URL WebRequest & cross domain web services

Initially, I would like make a web services call with cross domain (ajax). Since RC doesnt support it at the moment. So, I'm looking for an alternative.

- One is a bridge method,http://forums.asp.net/thread/1510827.aspx
But when will CTP support it?

- Another way to use WebRequest. However, there is an error "Access is denied" when I trying to access standard URL. ( change L17 to L16)

Please take a look at L16, L17

1<%@dotnet.itags.org. Page Language="C#" %>23<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">45<html xmlns="http://www.w3.org/1999/xhtml" >6<head runat="server">7 <title>Web Request</title>8 <script type="text/javascript">9 function MakeWebRequest()10 {11 var displayElement = document.getElementById("ResultId");12 displayElement.innerHTML = "";13 wRequest = new Sys.Net.WebRequest();14 Sys.Net.WebRequestManager.add_completedRequest(On_WebRequestCompleted);1516 wRequest.set_url("http://www.asp.net");17 //wRequest.set_url("getTarget.htm");1819 Sys.Net.WebRequestManager.executeRequest(wRequest);20 }2122 function On_WebRequestCompleted(executor, eventArgs)23 {24 var displayElement = document.getElementById("ResultId");2526 if(executor.get_responseAvailable())27 {28 displayElement.innerHTML = "";29 displayElement.innerHTML += executor.get_responseData();30 }31 }32 </script>33</head>34<body>35 <form id="form1" runat="server">36 <asp:ScriptManager runat="server" ID="scriptManagerId"/>37 </form>3839 <h1>Make a Web request:</h1>40 <button id="Button1" title="adds and remove handlers, too" onclick="MakeWebRequest();">Web Request</button>41 <hr />42 <div id="ResultId" style="background-color:Aqua;"></div>43</body>44</html>45
Unfortunately, webrequest internally uses XmlHttpRequest which does not work for cross-domain calls for security reasons. BTW The web service proxy layer internally uses WebRequest so it does not work for that too. The CTP versions used to have an IFrameExecutor which mysteriously got removed in the latest CTP. The IFrameExecutor allowed cross-domain calls. Now as far as handling cross-domain calls you can do it from the server. For instance you can develop an Generic HTTP handler which will take the URL of the target cross-domain page and return its contents. Save the code of the following examples in Delegate.ashx in your web site. The you can invoke the request to the following url:

delegate.ashx?url=www.asp.net

The server will then download the contents ofwww.asp.net and return it. Here is the code of the handler:

------

<%@. WebHandler Language="C#" Class="LoadRssFeed" %>using System;using System.Web;using System.Net;public class LoadRssFeed : IHttpHandler{ private HttpContext _context; public HttpContext Context { get { return _context; } } public HttpResponse Response { get { return Context.Response; } } public HttpRequest Request { get { return Context.Request; } } public void ProcessRequest(HttpContext context) { this._context = context; string url = Request.QueryString["url"]; if (String.IsNullOrEmpty(url)) { Response.StatusCode = (int)HttpStatusCode.NotFound; return; } try { WebRequest request = WebRequest.Create(url); HttpWebResponse webResponse = (HttpWebResponse)request.GetResponse(); if (!String.IsNullOrEmpty(webResponse.ContentEncoding)) { try { Response.ContentEncoding = System.Text.Encoding.GetEncoding(webResponse.ContentEncoding); } catch (ArgumentException ex) { System.Diagnostics.Trace.WriteLine(ex.ToString()); } } Response.ContentType = webResponse.ContentType; Response.StatusCode = (int)webResponse.StatusCode; Response.StatusDescription = webResponse.StatusDescription; byte[] buffer = new byte[4096]; System.IO.Stream stream = webResponse.GetResponseStream(); for (; ; ) { int read = stream.Read(buffer, 0, buffer.Length); if (read == 0) break; if (read > 0) Response.OutputStream.Write(buffer, 0, read); } } catch (ArgumentNullException ex) { Response.StatusCode = (int)HttpStatusCode.NotFound; System.Diagnostics.Trace.WriteLine(ex.ToString()); } catch (System.Security.SecurityException ex) { Response.StatusCode = (int)HttpStatusCode.Forbidden; System.Diagnostics.Trace.WriteLine(ex.ToString()); } catch (UriFormatException ex) { Response.StatusCode = (int)HttpStatusCode.BadRequest; System.Diagnostics.Trace.WriteLine(ex.ToString()); } catch (Exception ex) { Response.StatusCode = (int)HttpStatusCode.InternalServerError; System.Diagnostics.Trace.WriteLine(ex.ToString()); } } public bool IsReusable { get { return false; } }}

Thanks Rama Krishna, I would like to ask if there exists any methods so that

"the page sends some data to an external aspx page (using post and get method) and get result page in client side only using js or atlas client"