Showing posts with label service. Show all posts
Showing posts with label service. 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

urlrewriter and Microsoft Ajax gives me a Web Service call failed: 405

I'm using the Dynamic Populate Extender

And it gives me a

Web Service call failed: 405

Error if I'm accessing the page through a rewritten URL

featureD_properties.html
is
index.aspx?PageID=featured&agent=11

rewritten

the html one throws that error the other one doesn't...

why?

I'm using
http://www.urlrewriter.net/

you cannot use "HTML" or anything except "ASPX" as a suffix for your url when you are abut urlredirecting ,

read the PDF available on the http://www.urlrewriter.net/ it is mentioned there .


what?

I have no idea what you're talking about

The Server URL is ASPX and HTML is the URL being rewritten

The Client URL is

featureD_properties.html

and it gets rewritten to without incident

~/index.aspx?PageID=featured

That's what URLrewriting is... I think I completely missed your point or what you're trying to say....


I guess you use visual studio dev server so you can map anything but in the real world we use IIS , and IIS sends only "ASPX" files to asp.net to manage so other things (including HTML ) won't be managed by asp.net so you cannot use any other " extension " except "ASPX". Read the "readme" file on URLrewriting.net website it is clearly motioned there, though you can config your IIS to manage HTML extensions as well so you can map your addresses on HTML extensions(or anything else like .ME ! ) but usually you cannot config your hosting server !


I'm not using the dev server I'm using IIS
URLRewriting HTML extensions to a server extension on the web site is a really common practice especially in SEO scenarios

I could make the extension .Imuhhappymonkey

It doesn't matter it's just some random assortment of letters that you map to something that's it ASPX is just the default that it uses I could map ASPX to anything i want

I'm operating with dedicated Windows 2003 Servers so I can do whatever I want to to the hosting server...

The problem is that the webservices and the asmx files don't want to play nicely with the urlrewriting package...


Hi,

Please refer to this post for the explanations about why ajax extension usually has problem with URL rewriting. http://forums.asp.net/p/1153763/1890972.aspx#1890972

Use Atlas profile service to persist layout between sessions

This sample use Atlas profile service to persist the position of a drag and drop panel between browse sessions.

Send me a private message if you like to have a zip file includes everything for this sample.


<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<atlas:ScriptManager runat="server" ID="ScriptManager1">
<Scripts>
<atlas:ScriptReference ScriptName="AtlasUIDragDrop" />
</Scripts>
</atlas:ScriptManager>
</head>
<body>
<form id="form1" runat="server">
<span id="msg"></span>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td width="200px" height="400px"> </td>
<td>
<div id="imagePanel" style="background-color:Navy;padding:1px">
<div id="dragHandler" style="background-color:Navy;width:100%;"></div>
<img src="http://pics.10026.com/?src=http://www.google.com/intl/en/images/logo.gif" />
</div>
</td>
</tr>
</table>
</form>

<script type="text/xml-script">
<page xmlns:script="http://schemas.microsoft.com/xml-script/2005">
<components>
<control id="imagePanel">
<behaviors>
<floatingBehavior handle="dragHandler" move="OnMove" />
</behaviors>
</control>
</components>
</page>
</script>

<script type="text/javascript">
function pageLoad()
{
Sys.Profile.set_autoSave(false);
Sys.Profile.loaded.add(onProfileLoadComplete);
Sys.Profile.saved.add(onProfileSaveComplete);
Sys.Profile.load();
}

function onProfileLoadComplete()
{
var objStyle = $object('imagePanel').element.style
objStyle.posTop = Sys.Profile.properties.poxTop;
objStyle.posLeft = Sys.Profile.properties.poxLeft;
}

function onProfileSaveComplete()
{
//alert('profile saved.');
}

function OnMove(sender, cancelArgs)
{
var ele = sender.control.element
Sys.Profile.properties.poxTop = ele.offsetTop;
Sys.Profile.properties.poxLeft = ele.offsetLeft;
Sys.Profile.save();
}
</script>
</body>
</html>

Your web.config must include something similar to the following. also you need a database to host the asp.net AppService.

<configSections>
<sectionGroup name="microsoft.web" type="Microsoft.Web.Configuration.MicrosoftWebSectionGroup">
<section name="profileService" type="Microsoft.Web.Configuration.ProfileServiceSection" requirePermission="false"/>
</sectionGroup>
</configSections>

<microsoft.web>
<profileService enabled="true"
setProperties="poxTop;poxLeft"
getProperties="poxTop;poxLeft">
</profileService>
</microsoft.web>

<connectionStrings>
<remove name="LocalSqlServer" />
<add name="LocalSqlServer" connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|aspnetdb.mdf" />
</connectionStrings>

<system.web>
<anonymousIdentification enabled="true" />
<profile>
<properties>
<add name="poxTop" type="integer"/>
<add name="poxLeft" type="integer"/>
</properties>
</profile>
</system.web>

I'm getting javascript errors trying to use this.

Sys.Profile.loaded.add(onProfileLoadComplete);
Sys.Profile.saved.add(onProfileSaveComplete);

should be

Sys.Profile.loaded.add(onProfileLoadComplete());
Sys.Profile.saved.add(onProfileSaveComplete());

then

Sys.Profile.properties.poxTop is null or not an object.


oh...

Sys.Profile.loaded.add(onProfileLoadComplete);
Sys.Profile.saved.add(onProfileSaveComplete);

is correct. this is demo, ignore the javascript error and the second try will let you go i think.


Great Example, thanks!

2 things:

1. I changed the example slighlty to display the Profile-Save-Event Time to the StatusBar with this
Script:

window.status = Date();

Does work well, but the Date is formatted this strange way:

Fri, May 19 09:26:32 2006

So the time is in the middle of the date-part !?

2. Does anybody have the same example but working more with the Server-Side Atlas-Framework?

Thanks


please send me zip file includes everything for this sample

Hi Xiyuan Shen

Can you send me the zip file so that I can implement this...I have been partially sucessfull. It seems as though I am missing a step though.

Justin


Did you actually get this working?

I have the example loaded and it seem to initially work, however, the drag N drop page moves once the page is completely loaded, to the top left of the screen. Any ideas why?


Hi there

Here is my code. He will do the job.

You get the error "Sys.Profile... length is null" if your database, which is responsible to save and where you get the position-values, is not running or not accessible.

Good luck.

Patrick

Web.Config

<?xmlversion="1.0"?>

<configuration>

<configSections>

<sectionGroupname="microsoft.web"type="Microsoft.Web.Configuration.MicrosoftWebSectionGroup">

<sectionname="webServices"type="Microsoft.Web.Configuration.WebServicesSection"requirePermission="false"/>

<sectionname="profileService"type="Microsoft.Web.Configuration.ProfileServiceSection"requirePermission="false"/>

</sectionGroup>

</configSections>

<microsoft.web>

<!-- Enable WebServices because Profile-Service ASP.NET is accessible thru WS-->

<webServicesenableBrowserAccess="true"/>

<profileService

enabled="true"

setProperties="poxTop;poxLeft;FloatingLabelLocation"

getProperties="poxTop;poxLeft;FloatingLabelLocation">

</profileService>

</microsoft.web>

<system.web>

<authenticationmode="Windows"/>

<anonymousIdentificationenabled="true"/>

<profileenabled="true">

<properties>

<addallowAnonymous="true"name="FloatingLabelLocation"/>

<addname="poxTop"type="integer"/>

<addname="poxLeft"type="integer"/>

</properties>

</profile>

<pages>

<controls>

<addnamespace="Microsoft.Web.UI"assembly="Microsoft.Web.Atlas"tagPrefix="atlas"/>

<addnamespace="Microsoft.Web.UI.Controls"assembly="Microsoft.Web.Atlas"tagPrefix="atlas"/>

</controls>

</pages>

<compilationdebug="true" />

<httpHandlers>

<removeverb="*"path="*.asmx"/>

<!-- ASMX is mapped to a new handler so that proxy javascripts can also be served.-->

<!-- Otherwise, you get the following error-->

<!-- The HTTP verb POST used to access path '/ProfileWithAtlas/ScriptServices/Microsoft/Web/Services/Standard/ProfileWebService.asmx' is not allowed.-->

<addverb="*"path="*.asmx"type="Microsoft.Web.Services.ScriptHandlerFactory"validate="false"/>

</httpHandlers>

</system.web>

</configuration>

------------

<%@.PageLanguage="C#"AutoEventWireup="true" %>

<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">

<headrunat="server">

<title>Atlas Profiling</title>

</head>

<body>

<formid="form1"runat="server">

<atlas:ScriptManagerrunat="server"ID="ScriptManager1">

<Scripts>

<atlas:ScriptReferenceScriptName="AtlasUIDragDrop"/>

</Scripts>

</atlas:ScriptManager>

<spanid="msg"></span>

<tablecellpadding="0"cellspacing="0"border="0">

<tr>

<!-- This fixed Size is important. Without it, your d&d will not snapp-in -->

<tdstyle="width:200px;height:600px"></td>

<td>

<divid="imagePanel">

<imgid="dragHandler"src="smile.gif"alt="Smile!"/>

</div>

</td>

</tr>

</table>

<scripttype="text/xml-script">

<page xmlns:script="http://schemas.microsoft.com/xml-script/2005">

<components>

<control id="imagePanel">

<behaviors>

<floatingBehavior handle="dragHandler" move="OnMove" />

</behaviors>

</control>

</components>

</page>

</script>

<scripttype="text/javascript">

function pageLoad()

{

Sys.Profile.set_autoSave(false);

Sys.Profile.loaded.add(onProfileLoadComplete);

Sys.Profile.saved.add(onProfileSaveComplete);

Sys.Profile.load();

}

function onProfileLoadComplete()

{

var objStyle = $object('imagePanel').element.style;

if (Sys.Profile.properties.poxTop !=null)

objStyle.posTop = Sys.Profile.properties.poxTop;

if (Sys.Profile.properties.poxLeft !=null)

objStyle.posLeft = Sys.Profile.properties.poxLeft;

}

function onProfileSaveComplete()

{

window.status ="Profile saved: " + Date();

}

function OnMove(sender, cancelArgs)

{

var ele = sender.control.element;

Sys.Profile.properties.poxTop = ele.offsetTop;

Sys.Profile.properties.poxLeft = ele.offsetLeft;

Sys.Profile.save();

}

</script>

</form>

</body>

</html>

Use Class instead of Web Service?

Hello,

Can I use a class instead of a web service? If I communicated with only my page I would like to speed up the process by not using a web service.

TIA,

Clank

Clank

Take a look at this quickstart
http://atlas.asp.net/quickstart/atlas/doc/services/default.aspx#webpage

thanks
-jhawk

Use dynamic parameters when calling web service from javascript

Hello,

I would like to call a web services from javascript with dynamic parameters. I don't know the count and the value of the params that I'll set.

Here is a part of my code :

var serviceMethod =new Sys.Net.ServiceMethod(_servicePath, _serviceMethod, _appUrl);var paramArray =new Array(_serviceMethodParameters.length);for(var i = 0 ; i < _serviceMethodParameters.length ; i++ )

{

var toto = _serviceMethodParameters[i].get_Key();var tata = _serviceMethodParameters[i].get_Value();var elem = { toto : tata };

paramArray.push(elem);

}

_request = serviceMethod.invoke(paramArray, onMethodComplete, onMethodTimeout, onMethodError, onMethodAborted,

this , _timeoutInterval, _priority);

the problem that I have is actually I don't figure out the data format of the parameters

I would like the variable toto to be not interpreted as "toto", but as the content of the variable toto.

I could do this in another way, but I have to use this method to call a web service because I need to abort it if needed.

Any ideas about that?

Thanks in advance

Would something like this do the trick?

var elem = {};
elem[toto] = tata;
paramArray.push(elem);

Hope that helps,
-Hao


yes, it's working now, but now i've another problem : the parameter format is not correct.

When the webservice is called, it returns an error which is :

"error: Invalid object passed in, '{' expected. (1): [{\"last\":\"5000\"}]"


I actullay got it !! :)

I didn't need to use an Array to set the parameter but only a variable, kind of hashtable

I write the code if it could help someone who has the same problem.

here is the code :

var serviceMethod =new Sys.Net.ServiceMethod(_servicePath, _serviceMethod, _appUrl);var elem = {};for(var i = 0 ; i < _serviceMethodParameters.length ; i++ )

{

var toto = _serviceMethodParameters[i].get_Key();var tata = _serviceMethodParameters[i].get_Value();

elem[toto] = tata;

}

_request = serviceMethod.invoke(elem, onMethodComplete, onMethodTimeout, onMethodError, onMethodAborted,

this ,_timeoutInterval, _priority);