Click here to Skip to main content
15,915,082 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi all,

when i call a web service method from javascript,an exception occured.

sys.net.webservicefailed exception and
system.invalid operation exception...... authentication failed.

this is the error message i have got when i called the web service fuction

have any idea about this.Help me
*******************this is the javasript for calling webservice.****************************************



function SaveLocation() {
    alert("inside save location_______jscript");
    gettxtPatientID().value = PatientID;
    MedVisit_Web.GMapWebService.SavePatientLocation(PatientID, Latitude, Longitude, SaveLocationResult);
}



function SaveLocationResult(result, userContext)
{
    hovermarker.closeInfoWindow();

}




*****************this is the webservice method***************************************

[WebMethod(EnableSession = true)]
        public bool SavePatientLocation(string PatientID, string Lattitude, string Longitude)
        {
            if (PatientID.Length > 0)
            {
                GMapPoints point = new GMapPoints();
                point.DeletePatientPoint(Convert.ToInt32(PatientID));
                GMapPatientDetails patientpoints = new GMapPatientDetails();
                patientpoints.PatientID = Convert.ToInt32(PatientID);
                patientpoints.Latitude = Lattitude;
                patientpoints.Longitude = Longitude;
                if (point.InsertPatientPoint(patientpoints))
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                return false;
            }
        }
Posted
Updated 29-Jun-11 23:15pm
v4
Comments
Parwej Ahamad 30-Jun-11 1:32am    
Post here piece of Jscript code block and web method block
shefeekcm 30-Jun-11 4:58am    
please see the code.
Parwej Ahamad 30-Jun-11 5:27am    
Just silly mistake, see your method parameters.

Your method has three methods and you're passing in four.
 
Share this answer
 
Comments
Pravin Patil, Mumbai 30-Jun-11 5:12am    
This is a very clear answer....When you have a function accepting only three parameters you can not pass four....
Hope this helps...
shefeekcm 30-Jun-11 6:23am    
you are wrong...it is a call back function,I got the sollution.anyway thnks for your company.
shefeekcm 5-Jul-11 2:31am    
its a simple problem,when we add a web sevice method,it should be like this.



[WebMethod]
public bool SavePatientLocation(string PatientID, string Lattitude, string Longitude)
{
if (PatientID.Length > 0)
{
GMapPoints point = new GMapPoints();
point.DeletePatientPoint(Convert.ToInt32(PatientID));
GMapPatientDetails patientpoints = new GMapPatientDetails();
patientpoints.PatientID = Convert.ToInt32(PatientID);
patientpoints.Latitude = Lattitude;
patientpoints.Longitude = Longitude;
if (point.InsertPatientPoint(patientpoints))
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
hey shefeekcm: call your method by using pagemethod.method name and add some
ontimeout,onerror and print stackstrace see there what is the error

MIDL
SavePatientLocation(PatientID, Latitude, Longitude, SaveLocationResult,ontimeout,onerror);


funtion ontimeout(error)<br />
{<br />
  alert(error);<br />
}<br />
function onerror(error,context)<br />
{<br />
  alert(error);<br />
}
 
Share this answer
 
Comments
shefeekcm 1-Jul-11 2:32am    
i have already got a sollution ,thanks for your cooperation
ParthaDinda 1-Jul-11 2:34am    
can you please share it. That it can help not only me but others too.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900