Showing posts with label service. Show all posts
Showing posts with label service. Show all posts

Wednesday, March 21, 2012

ASMX Web service

Hi all,

I would like to create an ASP.Net Atlas application that will call a remote web service. I have checked a few samples and I have only seen examples where the web service sits on the same project as the Atlas application. Is there a way of calling a single remote web service with ATLAS or do I have to use a bridge?

Thanks

Regards

Stephanie

Never tryed, is this going to work?

<atlas:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<atlas:ServiceReference Path="http://somedoamin/someApp/WebService.asmx" />
</Services>
</atlas:ScriptManager>


I believe that should work if that cross domain webservice is an atlas webservice and:

1) The iframehandler is registered in your web.config.

<add verb="*" path="iframecall.axd" type="Microsoft.Web.Services.IFrameHandler" validate="false"/>


2) You have a WebOperation attribute on your web service that allows crossdomain posts (third parameter to the attribute constructor) i.e.

[WebOperation(true, ResponseFormatMode.Json, true)]

Hope that helps,
-Hao


Oh, and if your remote web service is not an atlas webservice, then I believe you would have to use a bridge.
I have tried that without any success

I have tried that without any success.

Xiyuan Shen:

Never tryed, is this going to work?

<atlas:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<atlas:ServiceReference Path="http://somedoamin/someApp/WebService.asmx" />
</Services>
</atlas:ScriptManager>


Hi,

The server where ATLAS app will be and the server where the web service will be are on the same domain, same site.

Is there another solution for that case?

Thanks

Stephanie

HaoK:

I believe that should work if that cross domain webservice is an atlas webservice and:

1) The iframehandler is registered in your web.config.

<add verb="*" path="iframecall.axd" type="Microsoft.Web.Services.IFrameHandler" validate="false"/>


2) You have a WebOperation attribute on your web service that allows crossdomain posts (third parameter to the attribute constructor) i.e.

[WebOperation(true, ResponseFormatMode.Json, true)]

Hope that helps,
-Hao


If I read Haok's comments right. I think the web service you refer to should run under asp.net 2.0, also the web.config file for the web service should be modified to use
Microsoft.Web.Services.ScriptHandlerFactory for handling web service request.

<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" type="Microsoft.Web.Services.ScriptHandlerFactory" validate="false"/>
</httpHandlers>


So even if the webservice is on the same site and same domain, it stillneeds to be running atlas if you wish to access it using the atlasclient script proxies, so what Xiyuan mentions above is what you needon the web service site to enable generation of the client scriptproxies.

Hope that helps,
-Hao

Arrgggh - AJAX just wont run?

I've seen a lot about this and never any good fixes - clean machine, XP SP2 - all service packs, .NET 1.1/2/3 and service packs, VS 2005 Pro SP1 and just downloaded and installed AJAX Extensions and none of my Ajax projects work not even new ones and of course I keep getting this useless error msg: and yes I do have the extensions dll in my bin folder.

Error 1 Could not load file or assembly 'Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. Web.config 66

My web.config is correct because I have this running in 5 VM's and many production servers but also got this error on a couple of those and it just magically went away ...

Hi craig,

This is locally where you get the problem? Well, if the ajax extentions are installed on your local machine, then they shouldn't be in your bin folder. Since they are present in the GAC. (But, this couldn't be causing the error I guess ....)

Euhm, what about making a plain website and ajax enabling it? will that work?

Just place the system.web.extentions.dll and the system.web.extentions.design.dll in the bin, and paste the following in the web.config under the <system.web> tag:

<!--AJAX ENABLE WEBSITE--><httpHandlers><remove verb="*" path="*.asmx"/><add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/><add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/></httpHandlers><httpModules><add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/></httpModules><!--END AJAX ENABLING-->

What is the effect of this? Same error?
Can you also provide the error? Maybe the line in the web.config the error mentioned?

Kind regards,
Wim


I just figured it out and it makes no sense - I found an ASPAJAXExtSetup.msi that was released in Dec 2006 which to me looks "Identical" to the one I download a few days ago, it has the same version number etc but any machine I install this one on works first time .... including solving my local issue. Same version number! ...

thanks

-c

array of class object to web service

Hi

I'm able to work with class objects on the client and i want to send the array of class objects to the web service as parameter. Somehow i'm not able to get it work.. What should be the parameter declaration on the web service. can someone post the sample for this?

Thank You

Subba

this should work. Can past your code. i will take a look


Hi Raghu, here is my code snippets. Let me know if you need any more information.

Question is my class object and added the addtribute<GenerateScriptType(GetType(Question))>on the web service.

<WebMethod()> _

PublicFunction BuildQuestions(ByVal questionsTobeBuiltAs List(Of Question))AsString

Dim queryStringAsString =String.Empty

For Each item As Question In questionsTobeBuilt

queryString = queryString & item.Content

Next

ReturnqueryString

EndFunction

on the client i'm adding the data in this way:

this._questions = new Object();

this._questions[data.Id] = {Question: data};

and my webservice call from client:

ASPNETFuturesDragDrop.QuestionareService.BuildQuestions(questonsToBeSubmitted, onBuilded);

//display the server-side response to the customer

function onBuilded(result) {

//Sys.Preview.UI.Window.messageBox(result,Sys.Preview.UI.MessageBoxStyle.OK);

OutputMsg.innerHTML=result;

}


go through this forum, they discuss the same problem you are having. It is by design. Change your web method that takes array of your class instead of Generic List.

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=90536&SiteID=1


Thanks for the link. i even tried with array of objects, Question() as parameter for the web service. that gives me an error 'System.MissingMethodException -- No parameterless constructor defined for type Question[]'. I donno where do i need to declared the constructor for an arrya of objects..


Mark Your WebService/WebMethod with the GenerateScriptType Atttribute with the Server Side Class then in the client Create a Array Like the following:

var q1 = new Question();
var q2 = new Question();
var q3 = new Question();
var q4 = new Question();

//Code to set the properties of the above questions

var questions = new Array();

questions.push(q1):
questions.push(q2):
questions.push(q3):
questions.push(q4):

//Then Call the WS with the array.

WS.SomeMethod(questions, successHandler);

ArgumentOutOfRangeException when calling a web service

I have a script service that is failing for some (but not all) clients. Below is the stack trace. My understanding is that Script Handler is failing to understand the request and bombs out when trying to send a json string representation of the problem. This is making it hard for me to determine what the cause of the problem is. Has anyone else seen this happen before?

System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: startIndex
at System.Text.StringBuilder.Append(String value, Int32 startIndex, Int32 count)
at Microsoft.Web.Script.Serialization.JavaScriptString.QuoteString(String value)
at Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeString(String input)
at Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeValueInternal (Object o)
at Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeValue(Object o)
at Microsoft.Web.Services.RestHandler.WriteExceptionJsonString(HttpContext context, TextWriter writer, Exception ex)
at Microsoft.Web.Services.RestHandler.ProcessRequest(HttpContext context)
at Microsoft.Web.Services.ScriptHandlerFactory.HandlerWrapper.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute ()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

It seems you are having problem with serialization, you are trying to serialize which is not supoorted with default JavaScriptSeriallizer, Try FireBug forFF or Fiddler for IE to trace the JSOn string. You can also paste the code here which we can investigate.