Hello,
I have a web service with a method called "Login" Login returns a custom enumeration type called "MethodStatus". I am trying to call this method in Atlas, my client code is below
function OnbuttonGo_click() { //Call script proxy passing the input element data var object = Crisp.ParentWebService.MainService.Login( 'd','d', //params OnComplete, //Complete event OnTimeout //Timeout event ); return false; } function OnComplete(result) { alert(result); } function OnTimeout(result) { alert("Timed out"); }This method works fine if I change the type in my Login status to String but when I use my enumeration it fails
giving me the following error message:
Key cannot be null.
Parameter name: key
Server Error in '/AtlasWebSite1' Application.
Key cannot be null.
Parameter name: key
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.ArgumentNullException: Key cannot be null.
Parameter name: key
Source Error:
An unhandled exception was generated during the execution of the current
web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.
Stack Trace:
[ArgumentNullException: Key cannot be null.
Parameter name: key]
System.Collections.Hashtable.ContainsKey(Object key) +2773989
System.Collections.Hashtable.Contains(Object key) +4
Microsoft.Web.Services.ClientProxyGenerator.EnsureNamespace(Type t) +46
Microsoft.Web.Services.ClientProxyGenerator.GenerateEnumTypeProxies(IEnumerable`1 enumTypes) +117
Microsoft.Web.Services.ClientProxyGenerator.GetClientProxyScript(WebServiceData webServiceData) +339
Microsoft.Web.Services.WebServiceClientProxyGenerator.GetClientProxyScript(HttpContext context) +263
Microsoft.Web.Services.RestClientProxyHandler.ProcessRequest(HttpContext context) +79
Microsoft.Web.Services.HandlerWrapper.ProcessRequest(HttpContext context) +30
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +401
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +117
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42
<!--
[ArgumentNullException]: Key cannot be null.
Parameter name: key
at System.Collections.Hashtable.ContainsKey(Object key)
at System.Collections.Hashtable.Contains(Object key)
at Microsoft.Web.Services.ClientProxyGenerator.EnsureNamespace(Type t)
at Microsoft.Web.Services.ClientProxyGenerator.GenerateEnumTypeProxies(IEnumerable`1 enumTypes)
at Microsoft.Web.Services.ClientProxyGenerator.GetClientProxyScript(WebServiceData webServiceData)
at Microsoft.Web.Services.WebServiceClientProxyGenerator.GetClientProxyScript(HttpContext context)
at Microsoft.Web.Services.RestClientProxyHa
You're doing something else wrong somewhere, and I don't know from your code what it is. I just did the part that you think is tripping you up, and it works fine. Code follows:
<... Html stuff that builds a pair of text boxes and a button ...>
<script type="text/javascript">
function button_Click()
{
var name = document.getElementById("userName");
var pass = document.getElementById("passWord");
requestService = TestEnums.MyService.Login(
name.value, pass.value
OnComplete,
OnTimeOut);
return false;
}
function OnComplete(result)
{
alert(result);
}
function OnTimeOut(result)
{
alert('timed out');
}
</script>
<... closing html stuff ...>
now the web service
<... web service header, using statements, and so on ...>
[WebMethod]
public Status Login(string a, string b)
{
if(a==b)
return Status.Authenticated;
else
return Status.Anonymous;
}
<.... Enum ...>
publuic enum Status
{
Anonymous,
Authenticated
}
Now, what happens is that the thing runs, and it alerts 0 or 1. I suspect you'd have to handle the enum in javascript as well in order to translate the enumeration into something meaningful on the client. But the bottom line is that passing a custom type is not error-generating action.
Hello,
I have fixed the problem now the problem was because I never set a namespace for the enumeration. I had set a namespace for my service and not for my enumeration.
Thank's alot for your help!
Rob
No problem, glad you found it!
No comments:
Post a Comment