Search Results

Search found 295 results on 12 pages for 'webmethod'.

Page 5/12 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • How to specify a parameter as part of every web service call?

    - by LES2
    Currently, each web service for our application has a user parameter that is added for every method. For example: @WebService public interface FooWebService { @WebMethod public Foo getFoo(@WebParam(name="alwaysHere",header=true,partName="alwaysHere") String user, @WebParam(name="fooId") Long fooId); @WebMethod public Result deletetFoo(@WebParam(name="alwaysHere",header=true,partName="alwaysHere") String user, @WebParam(name="fooId") Long fooId); // ... } There could be twenty methods in a service, each with the first parameter as user. And there could be twenty web services. We don't actually use the 'user' argument in the implementations - in fact, I don't know why it's there - but I wasn't involved in the design, and the person that put it there had a reason (I hope). Anyway, I'm trying to straighten out this Big Ball of Mud. I have already come a long way by wrapping the web services by a Spring proxy, which allows me to do some before-and-after processing in an interceptor (before there were at least 20 lines of copy-pasted boiler plate per method). I'm wondering if there's some kind of "message header" I can apply to the method or package and that can be accessed by some type of handler or something outside of each web service method. Thanks in advance for the advice, LES

    Read the article

  • how to convert byte array to image in java?

    - by nemade-vipin
    I am developing a Web application in Java. In that application, I have created webservices in Java. In that webservice, I have created one webmethod which returns the image list in base64 format. The return type of the method is Vector. In webservice tester I can see the SOAP response as xsi:type="xs:base64Binary". Then I called this webmethod in my application. I used the following code: SBTSWebService webService = null; List imageArray = null; List imageList = null; webService = new SBTSWebService(); imageArray = webService.getSBTSWebPort().getAddvertisementImage(); Iterator itr = imageArray.iterator(); while(itr.hasNext()) { String img = (String)itr.next(); byte[] bytearray = Base64.decode(img); BufferedImage imag=ImageIO.read(new ByteArrayInputStream(bytearray)); imageList.add(imag); } In this code I am receiving the error: java.lang.ClassCastException: [B cannot be cast to java.lang.String" on line String img = (String)itr.next(); Is there any mistake in my code? Or is there any other way to bring the image in actual format? Can you provide me the code or link through which I can resolve the above issue? Note:- I already droped this question and I got the suggetion to try the following code Object next = iter.next(); System.out.println(next.getClass()) I tried this code and got the output as byte[] from webservice. but I am not able to convert this byte array to actual image. is there any other way to bring the image in actual format? Can you provide me the code or link through which I can resolve the above issue?

    Read the article

  • Passing javascript object to webservice via Jquery ajax

    - by kralco626
    I have a webservice that returns an object [WebMethod] public List<User> ContractorApprovals() I also have a webservice that accepcts an object [WebMethod] public bool SaveContractor(Object u) When I make my webservice calls via Jquery: function ServiceCall(method, parameters, onSucess, onFailure) { var parms = "{" + (($.isArray(parameters)) ? parameters.join(',') : parameters) + "}"; // to json $.ajax({ type: "POST", url: "services/"+method, data: parms, contentType: "application/json; charset=utf-8", dataType: "json", success: function(msg) { if (typeof onSucess == 'function' || typeof onSucess == 'object') onSucess(msg.d); }, error: function(msg, err) { $("#dialog-error").dialog('open');} }); I can call the first one just fine. My onSucess function gets passed a javascript object exactly structured like my User object on the service. However, I am now having trouble getting the object back to the server. I'm accepting Object as a parameter on the server side so I can't inagine there is an issue there. So I'm thinking something is wrong with the parms on the client side but i'm not sure what... I am doing something to the effect ServiceCall("AuthorizationManagerWorkManagement.asmx/ContractorApprovals", "", function(data,args){$("#div").data('user',data[0])}, null) then ServiceCall("AuthorizationManagerWorkManagement.asmx/SaveContractor", $("#div").data('user'), //These also do not work: "{'u': ' + $("#div").data("user") + '}", NOR JSON.stringify({u: userObject}) function(data,args){(alert(data)}, null) I know the first service call works, I can get the data. The second one is causing the "onFailure" method to execute rather then "OnSuccess". Any ideas?

    Read the article

  • asmx web service returning xml instead of json in .net 4.0

    - by Baldy
    i have just upgraded a test copy of my site to asp.net 4.0 and have noticed a strange issue that only arises when i upload the site to my server. the site has an asmx web service that returns json, yet when i run the site on my server it returns xml. it as been working fine in asp.net 3.5 for over a year. the webMethod is decorated with the correct attributes... [WebMethod][ScriptMethod(ResponseFormat = ResponseFormat.Json)] public List<LocationRecentChange> RecentChanges() and on my local machine it returns json. yet on the server (Windows 2008 64bit) it returns xml. you can inspect the response on the test site here... my test site using firebug console you will see a 200 OK response and a bunch of XML, and on my local machine the data returned is the JSON i expect. Here is the javascript that calls the service.. function loadRecentData() { $.ajax({ type: "POST", url: "service/spots.asmx/RecentChanges", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: loadRecentUpdates, failure: function(msg) { //alert(msg); } }); } Any suggestions welcome, this has got me stumped!

    Read the article

  • why i cant read my webservice with jquery???

    - by rima
    what's my function problem?I wana read from my webservice but I just receive error :( the browser message is: "undefined- status:error" when I press button just I see the error function of my Jqueary calling but I dont know why??plz help me. function SetupCompanyInfo(companyID) { //alert('aaa'); companyID = '1'; $.ajax({ type: "POST", url: '../../../Services/CompanyServices.asmx/GetCompanyInfo', data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: OnSuccess, error: OnError }); } function OnSuccess(data, status) { SetMainBody(data); } function OnError(request, status, error) { SetMainBody(error + '- ' + request + ' status:' + status); } my webservice: using System; using System.Web.Services; using System.Web.Script.Services; /// <summary> /// Summary description for CompanyServices /// </summary> [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [ScriptService] //[System.ComponentModel.ToolboxItem(false)] public class CompanyServices : System.Web.Services.WebService { [WebMethod] public string GetCompanyInfo() { string response = "aaa"; Console.WriteLine("here"); return response.ToString(); } [WebMethod] public string GetCompanyInfo(string id) { string response = "aaa"; Console.WriteLine("here2"+id); return response.ToString(); } } my aspx file,part of head and my button code: <script src="../../Scripts/InnerFunctions.js" type="text/javascript"></script> <script src="../../Scripts/jquery-1.3.2.min.js" type="text/javascript"></script> <script src="../../Scripts/TabMenu.js" type="text/javascript"></script> <script src="Scripts/InternalFunctions.js" type="text/javascript"></script> <div dir="rtl" style="border: 1px solid #CCCCCC"> <asp:Image ID="Image1" runat="server" ImageUrl="../../generalImg/Icons/64X64/settings_Icon_64.gif" style="width: 27px; height: 26px" onclick="SetupCompanyInfo(1)" /></div>

    Read the article

  • How can I [simply] consume JSON Data in a Line of Business Web Application

    - by Atomiton
    I usually use JSON with jQuery to just return a string with html. However, I want to start to use Javascript objects in my code. What's the simplest way to get started using json objects on my page? Here's a sample Ajax call ( after $(document).ready( { ... }) of course: $('#btn').click(function(event) { event.preventDefault(); var out = $('#result'); $.ajax({ url: "CustomerServices.asmx/GetCustomersByInvoiceCount", success: function(msg) { // // Iterate through the json results and spit them out to a page? // }, data: "{ 'invoiceCount' : 100 }" }); }); My WebMethod: [WebMethod(Description="Gets customers with more than n invoices")] public List<Customer> GetCustomersByInvoiceCount(int? invoiceCount) { using (dbDataContext db = new dbDataContext()) { return db.Customers.Where(c => c.InvoiceCount >= invoiceCount); } } What gets returned: {"d":[{"__type":"Customer","Account":"1116317","Name":"SOME COMPANY","Address":"UNit 1 , 392 JOHN ST. ","LastTransaction":"\/Date(1268294400000)\/","HighestBalance":13922.34},{"__type":"Customer","Account":"1116318","Name":"ANOTHER COMPANY","Address":"UNIT #345 , 392 JOHN ST. ","LastTransaction":"\/Date(1265097600000)\/","HighestBalance":549.42}]} What I'd LIKE to know, is what are people generally doing with this returned json? Do you iterate through the properties and create an html table on the fly? Is there way to "bind" JSON data using a javascript version of reflection ( something like the .Net GridView Control ) Do you throw this returned data into a Javascript Object and then do something with it? An example of what I want to achieve is to have an plain ol' html page ( on a mobile device )with a list of a Salesperson's Customers. When one of those customers are clicked, the customer id gets sent to a webservice which retrieves the customer details that are relevant to a sales person. I know the SO talent pool is quite deep so I figured you all here would be able to guide in the right direction and give me a few ideas on the best way to approach this.

    Read the article

  • Why do we need serialization in web service

    - by Cloud2010
    I have one webservice: public class Product { public int ProductId { get; set; } public string ProductName { get; set; } } public class Service : System.Web.Services.WebService { public Service () { //Uncomment the following line if using designed components //InitializeComponent(); } [WebMethod] public List<Product> GetItems() { List<Product> productList = new List<Product>() { new Product{ProductId=1,ProductName="Pencil"}, new Product{ProductId=2,ProductName="Pen"} }; return productList; } and in a asp.net application I am consuming it like: localhost.Service s = new localhost.Service(); List<localhost.Product> k = new List<localhost.Product>(); k = s.GetItems().ToList(); // i am getting the values here. now my question is do I need to serialize my webmethod as i am returning custom types? when should we serialize ? is it necessary at all, if yes , then what are the conditions?

    Read the article

  • jQuery ajax request response is empty in Internet Explorer

    - by Aprilia1982
    Hi, I'm doing the following ajax call: //exif loader function LoadExif(cImage) { $.ajax({ type: "POST", url: "http://localhost:62414/Default1.aspx/GetImageExif", data: "{iCurrentImage:" + cImage + "}", contentType: "application/json; charset=utf-8", dataType: "json", error: ajaxFailed, success: function (data, status) { var sStr = ''; for (var count in data.d) { sStr = sStr + data.d[count]; }; alert(sStr); } }); }; In Firefox the request works really fine. When I try to run the code in Internet Explorer, the response is empty. Here is the webmethod witch is called: <WebMethod()> _ <ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _ Public Shared Function GetImageExif(ByVal iCurrentImage As Integer) As String Dim sbTable As New StringBuilder sbTable.AppendLine("<table>") sbTable.AppendLine("<tr>") sbTable.AppendLine("<td>Name</td><td>" & gGallery.Images(iCurrentImage).File.Name & "</td>") sbTable.AppendLine("</tr>") sbTable.AppendLine("</table>") Return sbTable.ToString End Function Any ideas? Jan

    Read the article

  • How can I [simply] consume JSON Data to display to the page

    - by Atomiton
    I usually use JSON with jQuery to just return a string with html. However, I want to start to use Javascript objects in my code. What's the simplest way to get started using json objects on my page? Here's a sample Ajax call ( after $(document).ready( { ... }) of course: $('#btn').click(function(event) { event.preventDefault(); var out = $('#result'); $.ajax({ url: "CustomerServices.asmx/GetCustomersByInvoiceCount", success: function(msg) { // // Iterate through the json results and spit them out to a page? // }, data: "{ 'invoiceCount' : 100 }" }); }); My WebMethod: [WebMethod(Description="Gets customers with more than n invoices")] public List<Customer> GetCustomersByInvoiceCount(int? invoiceCount) { using (dbDataContext db = new dbDataContext()) { return db.Customers.Where(c => c.InvoiceCount >= invoiceCount); } } What gets returned: {"d":[{"__type":"Customer","Account":"1116317","Name":"SOME COMPANY","Address":"UNit 1 , 392 JOHN ST. ","LastTransaction":"\/Date(1268294400000)\/","HighestBalance":13922.34},{"__type":"Customer","Account":"1116318","Name":"ANOTHER COMPANY","Address":"UNIT #345 , 392 JOHN ST. ","LastTransaction":"\/Date(1265097600000)\/","HighestBalance":549.42}]} What I'd LIKE to know, is what are people generally doing with this returned json? Do you iterate through the properties and create an html table on the fly? Is there way to "bind" JSON data using a javascript version of reflection ( something like the .Net GridView Control ) Do you throw this returned data into a Javascript Object and then do something with it? An example of what I want to achieve is to have an plain ol' html page ( on a mobile device )with a list of a Salesperson's Customers. When one of those customers are clicked, the customer id gets sent to a webservice which retrieves the customer details that are relevant to a sales person. I know the SO talent pool is quite deep so I figured you all here would be able to guide in the right direction and give me a few ideas on the best way to approach this.

    Read the article

  • Updating a Data Source with a Dataset

    - by Paul
    Hi, I need advice. I have asp.net web service and winforms client app. Client call this web method and get dataset. 1. [WebMethod] 2. public DataSet GetSecureDataSet(string id) 3. { 4. 5. 6. SqlConnection conn = null; 7. SqlDataAdapter da = null; 8. DataSet ds; 9. try 10. { 11. 12. string sql = "SELECT * FROM Tab1"; 13. 14. string connStr = WebConfigurationManager.ConnectionStrings["Employees"].ConnectionString; 15. 16. conn = new SqlConnection(connStr); 17. conn.Open(); 18. 19. da = new SqlDataAdapter(sql, conn); 20. 21. ds = new DataSet(); 22. da.Fill(ds, "Tab1"); 23. 24. return ds; 25. } 26. catch (Exception ex) 27. { 28. throw ex; 29. } 30. finally 31. { 32. if (conn != null) 33. conn.Close(); 34. if (da != null) 35. da.Dispose(); 36. } 37. } After he finish work he call this update web method. He can add, delete and edit rows in table in dataset. [WebMethod] public bool SecureUpdateDataSet(DataSet ds) { SqlConnection conn = null; SqlDataAdapter da = null; SqlCommand cmd = null; try { DataTable delRows = ds.Tables[0].GetChanges(DataRowState.Deleted); DataTable addRows = ds.Tables[0].GetChanges(DataRowState.Added); DataTable editRows = ds.Tables[0].GetChanges(DataRowState.Modified); string sql = "UPDATE * FROM Tab1"; string connStr = WebConfigurationManager.ConnectionStrings["Employees"].ConnectionString; conn = new SqlConnection(connStr); conn.Open(); cmd = new SqlCommand(sql, conn); da = new SqlDataAdapter(sql, conn); if (addRows != null) { da.Update(addRows); } if (delRows != null) { da.Update(delRows); } if (editRows != null) { da.Update(editRows); } return true; } catch (Exception ex) { throw ex; } finally { if (conn != null) conn.Close(); if (da != null) da.Dispose(); } } Code on client side 1. //on client side is dataset bind to datagridview 2. Dataset ds = proxy.GetSecureDataSet(""); 3. ds.AcceptChanges(); 4. 5. //edit dataset 6. 7. 8. //get changes 9. DataSet editDataset = ds.GetChanges(); 10. 11. //call update webmethod 12. proxy.SecureUpdateDataSet(editDataSet) But it finish with this error : System.Web.Services.Protocols.SoapException: Server was unable to process request. --- System.InvalidOperationException: Update requires a valid UpdateCommand when passed DataRow collection with modified rows. at WebService.Service.SecureUpdateDataSet(DataSet ds) in D:\Diploma.Work\WebService\Service1.asmx.cs:line 489 Problem is with SQL Commad, client can add, delete and insert row, how can write a corect SQL command.... any advice please? Thank you

    Read the article

  • C# ASP.NET AJAX CascadingDropDown Selected value propriety problem

    - by Eyla
    Greetings, I have a problem to use selected value propriety of CascadingDropDown. I have 3 asp dropdown controls with ajax CascadingDropDown for each one of them. I have no problem to bind data to the 3 CascadingDropDown but my problem is to rebind CascadingDropDown. simply what I want to do is to select a record from Gridview which has the selected values for the CascadingDropDown that I want to pass then rebind the CascadingDropDown with selected value. I'm posting my code down which include: 1-ASP.NET code. 2-Code behind to handle selected record from grid view. 3- web servisice that handle binding data to the 3 CascadingDropDown. please advice how to rebind data to CascadingDropDown with selected value. by the way I used selected value proprety as showning in my code but it is not working and there is no error. Thank you, ........................ ASP.NET code ........................ <%@ Page Title="" Language="C#" MasterPageFile="~/Master.Master" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="IMAM_APPLICATION.WebForm1" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="idcontact_info" DataSourceID="ObjectDataSource1" onselectedindexchanged="GridView1_SelectedIndexChanged"> <Columns> <asp:CommandField ShowSelectButton="True" /> <asp:BoundField DataField="idcontact_info" HeaderText="idcontact_info" InsertVisible="False" ReadOnly="True" SortExpression="idcontact_info" /> <asp:BoundField DataField="Work_Field" HeaderText="Work_Field" SortExpression="Work_Field" /> <asp:BoundField DataField="Occupation" HeaderText="Occupation" SortExpression="Occupation" /> <asp:BoundField DataField="sub_Occupation" HeaderText="sub_Occupation" SortExpression="sub_Occupation" /> </Columns> </asp:GridView> <asp:Label ID="lbl" runat="server" Text="Label"></asp:Label> <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" DeleteMethod="Delete" InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" TypeName="IMAM_APPLICATION.DSContactTableAdapters.contact_infoTableAdapter" UpdateMethod="Update"> <DeleteParameters> <asp:Parameter Name="Original_idcontact_info" Type="Int32" /> </DeleteParameters> <UpdateParameters> <asp:Parameter Name="Work_Field" Type="String" /> <asp:Parameter Name="Occupation" Type="String" /> <asp:Parameter Name="sub_Occupation" Type="String" /> <asp:Parameter Name="Original_idcontact_info" Type="Int32" /> </UpdateParameters> <InsertParameters> <asp:Parameter Name="Work_Field" Type="String" /> <asp:Parameter Name="Occupation" Type="String" /> <asp:Parameter Name="sub_Occupation" Type="String" /> </InsertParameters> </asp:ObjectDataSource> <asp:DropDownList ID="cmbWorkField" runat="server" Style="top: 715px; left: 180px; position: absolute; height: 22px; width: 126px"> </asp:DropDownList> <asp:DropDownList runat="server" ID="cmbOccupation" Style="top: 745px; left: 180px; position: absolute; height: 22px; width: 77px"> </asp:DropDownList> <asp:DropDownList ID="cmbSubOccup" runat="server" style="position:absolute; top: 775px; left: 180px;"> </asp:DropDownList> <cc1:CascadingDropDown ID="cmbWorkField_CascadingDropDown" runat="server" TargetControlID="cmbWorkField" Category="WorkField" LoadingText="Please Wait ..." PromptText="Select Wor kField ..." ServiceMethod="GetWorkField" ServicePath="ServiceTags.asmx"> </cc1:CascadingDropDown> <cc1:CascadingDropDown ID="cmbOccupation_CascadingDropDown" runat="server" TargetControlID="cmbOccupation" Category="Occup" LoadingText="Please wait..." PromptText="Select Occup ..." ServiceMethod="GetOccup" ServicePath="ServiceTags.asmx" ParentControlID="cmbWorkField"> </cc1:CascadingDropDown> <cc1:CascadingDropDown ID="cmbSubOccup_CascadingDropDown" runat="server" Category="SubOccup" Enabled="True" LoadingText="Please Wait..." ParentControlID="cmbOccupation" PromptText="Select Sub Occup" ServiceMethod="GetSubOccup" ServicePath="ServiceTags.asmx" TargetControlID="cmbSubOccup"> </cc1:CascadingDropDown> </asp:Content> ...................................................... C# code behind ...................................................... protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { string strg = GridView1.SelectedDataKey["idcontact_info"].ToString(); int index = Convert.ToInt32(GridView1.SelectedDataKey["idcontact_info"].ToString()); //txtSearch.Text = GridView1.SelectedIndex.ToString(); // txtSearch.Text = GridView1.SelectedDataKey["idcontact_info"].ToString(); DSContactTableAdapters.contact_infoTableAdapter GetByIDAdapter = new DSContactTableAdapters.contact_infoTableAdapter(); DSContact.contact_infoDataTable ByID = GetByIDAdapter.GetDataByID(index); //DSSearch.contact_infoDataTable FirstName = FirstNameAdapter.GetDataByFirstNameList(prefixText); foreach (DataRow dr in ByID.Rows) { lbl.Text = dr["Work_Field"].ToString() + "....." + dr["Occupation"].ToString() + "....." + dr["sub_Occupation"].ToString(); cmbWorkField_CascadingDropDown.SelectedValue = dr["Work_Field"].ToString(); cmbOccupation_CascadingDropDown.SelectedValue = dr["Occupation"].ToString(); cmbSubOccup_CascadingDropDown.SelectedValue = dr["sub_Occupation"].ToString(); } } ....................................................... web Service ....................................................... [WebMethod] public CascadingDropDownNameValue[] GetWorkField(string knownCategoryValues, string category) { //dsCarsTableAdapters.CarsTableAdapter makeAdapter = new dsCarsTableAdapters.CarsTableAdapter(); //dsCars.CarsDataTable makes = makeAdapter.GetAllCars(); DSContactTableAdapters.tag_work_fieldTableAdapter GetWorkFieldAdapter = new DSContactTableAdapters.tag_work_fieldTableAdapter(); DSContact.tag_work_fieldDataTable WorkFields = GetWorkFieldAdapter.GetDataByGetWorkField(); List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>(); foreach (DataRow dr in WorkFields) { string Work_Field = (string)dr["work_Field_name"]; int idtag_work_field = (int)dr["idtag_work_field"]; values.Add(new CascadingDropDownNameValue(Work_Field, idtag_work_field.ToString())); } return values.ToArray(); } [WebMethod] public CascadingDropDownNameValue[] GetOccup(string knownCategoryValues, string category) { StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues); int idtag_work_field; if (!kv.ContainsKey("WorkField") || !Int32.TryParse(kv["WorkField"], out idtag_work_field)) { return null; } //dsCarModelsTableAdapters.CarModelsTableAdapter modelAdapter = new dsCarModelsTableAdapters.CarModelsTableAdapter(); //dsCarModels.CarModelsDataTable models = modelAdapter.GetModelsByCarId(makeId); DSContactTableAdapters.tag_OccupTableAdapter GetOccupAdapter = new DSContactTableAdapters.tag_OccupTableAdapter(); DSContact.tag_OccupDataTable Occups = GetOccupAdapter.GetByOccup_ID(idtag_work_field); // List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>(); foreach (DataRow dr in Occups) { values.Add(new CascadingDropDownNameValue((string)dr["Occup_Name"], dr["idtag_Occup"].ToString())); } return values.ToArray(); } [WebMethod] public CascadingDropDownNameValue[] GetSubOccup(string knownCategoryValues, string category) { StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues); int idtag_Occup; if (!kv.ContainsKey("Occup") || !Int32.TryParse(kv["Occup"], out idtag_Occup)) { return null; } //dsModelColorsTableAdapters.ModelColorsTableAdapter adapter = new dsModelColorsTableAdapters.ModelColorsTableAdapter(); //dsModelColors.ModelColorsDataTable colors = adapter.GetColorsByModelId(colorId); DSContactTableAdapters.tag_Sub_OccupTableAdapter GetSubOccupAdapter = new DSContactTableAdapters.tag_Sub_OccupTableAdapter(); DSContact.tag_Sub_OccupDataTable SubOccups = GetSubOccupAdapter.GetDataBy_Sub_Occup_ID(idtag_Occup); List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>(); foreach (DataRow dr in SubOccups) { values.Add(new CascadingDropDownNameValue((string)dr["Sub_Occup_Name"], dr["idtag_Sub_Occup"].ToString())); } return values.ToArray(); }

    Read the article

  • Method Cannot be reflected error

    - by acadia
    Hello, I am trying to add the web reference of a IBM FileNet WebSErvice in my .net application. The only change I did is changed the namespace in the reference from System.Web.Services.Protocols.SoapHttpClientProtocol TO Microsoft.Web.Services3.WebServicesClientProtocol After doing so, though the application is building properly. I am getting an error ExecuteChanges[webMethod] cannot be reflected. Please help

    Read the article

  • webservice method is not accessible from jquery ajax

    - by Abhisheks.net
    Hello everyone.. i am using jqery ajax to calling a web service method but is is not doing and genrating error.. the code is here for jquery ajax in asp page var indexNo = 13; //pass the value $(document).ready(function() { $("#a1").click(function() { $.ajax({ type: "POST", url: "myWebService.asmx/GetNewDownline", data: "{'indexNo':user_id}", contentType: "application/json; charset=utf-8", dataType: "json", success: function(msg) { $("#divResult").text(msg.d); } }); }); }); and this is the is web service method using System; using System.Collections; using System.Linq; using System.Web; using System.Web.Services; using System.Web.Services.Protocols; using System.Xml.Linq; using System.Data; using System.Web.Script.Serialization; using TC.MLM.DAL; using TC.MLM.BLL.AS; /// /// Summary description for myWebService /// [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. [System.Web.Script.Services.ScriptService] public class myWebService : System.Web.Services.WebService { public myWebService() { //Uncomment the following line if using designed components //InitializeComponent(); } [WebMethod] public string HelloWorld() { return "Hello World"; } [WebMethod] public string GetNewDownline(string indexNo) { IndexDetails indexDtls = new IndexDetails(); indexDtls.IndexNo = "13"; DataSet ds = new DataSet(); ds = TC.MLM.BLL.AS.Index.getIndexDownLineByIndex(indexDtls); indexNoDownline[] newDownline = new indexNoDownline[ds.Tables[0].Rows.Count]; for (int count = 0; count <= ds.Tables[0].Rows.Count - 1; count++) { newDownline[count] = new indexNoDownline(); newDownline[count].adjustedid = ds.Tables[0].Rows[count]["AdjustedID"].ToString(); newDownline[count].name = ds.Tables[0].Rows[count]["name"].ToString(); newDownline[count].structPostion = ds.Tables[0].Rows[count]["Struct_Position"].ToString(); newDownline[count].indexNo = ds.Tables[0].Rows[count]["IndexNo"].ToString(); newDownline[count].promoterId = ds.Tables[0].Rows[count]["PromotorID"].ToString(); newDownline[count].formNo = ds.Tables[0].Rows[count]["FormNo"].ToString(); } JavaScriptSerializer serializer = new JavaScriptSerializer(); JavaScriptSerializer js = new JavaScriptSerializer(); string resultedDownLine = js.Serialize(newDownline); return resultedDownLine; } public class indexNoDownline { public string adjustedid; public string name; public string indexNo; public string structPostion; public string promoterId; public string formNo; } } please help me something.

    Read the article

  • [Method Error 500] in Cascading dropdown update in Ajax Control Toolkit

    - by Vinni
    I am getting [MethodError 500] when I use cascading drop down. below is my code <tr> <td > Select a Hoster: </td> <td> <asp:DropDownList ID="ddlFeaturedHoster" runat="server" ></asp:DropDownList> </td> </tr> <ajaxToolkit:CascadingDropDown ID="cddHoster" runat="server" TargetControlID="ddlFeaturedHoster" PromptText="Select a Hoster" LoadingText="Loading ..." Category="ActiveHoster" ServiceMethod="GetDropDownContents" ServicePath="~/Hosting/HostingService.asmx"/> Service Code: [WebMethod] [ScriptMethod] public CascadingDropDownNameValue[] GetActiveHosters() { List<CascadingDropDownNameValue> returnList = new List<CascadingDropDownNameValue>(); HostersManager hosterManager = new HostersManager(); List<Hosters_HostingProviderDetail> hosters = hosterManager.GetAllHosters(); returnList.Add(new CascadingDropDownNameValue("--Please Select One--","0",true)); foreach (Hosters_HostingProviderDetail item in hosters) { returnList.Add(new CascadingDropDownNameValue() { name=item.HostingProviderName, value= item.HosterID.ToString()}); } return returnList.ToArray() ; } [WebMethod] [ScriptMethod] public CascadingDropDownNameValue[] GetDropDownContents(string knownCategoryValues, string category) { knownCategoryValues = FormatCategoryWord(knownCategoryValues); List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>(); HostersManager hosterManager = new HostersManager(); switch (category) { case "ActiveHoster": values.AddRange(GetActiveHosters()); break; case "ActiveOffer": values.AddRange(GetActiveOffers(1)); break; } return values.ToArray<CascadingDropDownNameValue>(); } /// <summary> /// Formats the category word /// </summary> /// <param name="value"></param> /// <returns></returns> private string FormatCategoryWord(string value) { if (string.IsNullOrEmpty(value)) return value; if (value.LastIndexOf(":") > 0) value = value.Substring(value.LastIndexOf(":") + 1); if (value.LastIndexOf(";") > 0) value = value.Substring(0, value.LastIndexOf(";")); return value; } }

    Read the article

  • How to cache method results in .Net

    - by SP
    Using webmethods, caching the results is pretty straight forward using "CacheDuration" attribute. Is there a similar "easy" way to cache non-webmethod outputs (or static methods) based on the parameters? I would appreciate any help. Thanks in advance!

    Read the article

  • How can i get the value of a session variable inside a static method in c#?

    - by Pandiya Chendur
    I am using asp.net pagemethods with jquery.... How to get the value of a session variable inside static method in c#... protected void Page_Load(object sender, EventArgs e) { Session["UserName"] = "Pandiya"; } [WebMethod] public static string GetName() { string s = Session["UserName"].ToString(); return s; } when i compile this i get the error An object reference is required for the non-static field, method, or property 'System.Web.UI.Page.Session.get' Any suggestion or any alternative...

    Read the article

  • ASP.Net JSON Web Service Post Form Data

    - by Will D
    I have a ASP.NET web service decorated with System.Web.Script.Services.ScriptService() so it can return json formatted data. This much is working for me, but ASP.Net has a requirement that parameters to the web service must be in json in order to get json out. I'm using jquery to run my ajax calls and there doesn't seem to be an easy way to create a nice javascript object from the form elements. I have looked at serialiseArray in the json2 library but it doesn't encode the field names as property name in the object. If you have 2 form elements like this <input type="text" name="namefirst" id="namefirst" value="John"/> <input type="text" name="namelast" id="namelast" value="Doe"/> calling $("form").serialize() will get you the standard query string namefirst=John&namelast=Doe calling JSON.stringify($("form").serializeArray()) will get you the (bulky) json representation [{"name":"namefirst","value":"John"},{"name":"namelast","value":"Doe"}] This will work when passing to the web service but its ugly as you have to have code like this to read it in: Public Class NameValuePair Public name As String Public value As String End Class <WebMethod()> _ Public Function GetQuote(ByVal nvp As NameValuePair()) As String End Function You would also have to wrap that json text inside another object nameed nvp to make the web service happy. Then its more work as all you have is an array of NameValuePair when you want an associative array. I might be kidding myself but i imagined something more elegant when i started this project - more like this Public Class Person Public namefirst As String Public namelast As String End Class which would require the json to look something like this: {"namefirst":"John","namelast":"Doe"} Is there an easy way to do this? Obviously it is simple for a form with two parameters but when you have a very large form concatenating strings gets ugly. Having nested objects would also complicate things The cludge I have settled on for the moment is to use the standard name value pair format stuffed inside a json object. This is compact and fast {"q":"namefirst=John&namelast=Doe"} then have a web method like this on the server that parses the query string into an associate array. <WebMethod()> _ Public Function AjaxForm(ByVal q As String) as string Dim params As NameValueCollection = HttpUtility.ParseQueryString(q) 'do stuff return "Hello" End Sub As far a cludges go this one seems reasonably elegant in terms of amount of code, but my question is: is there a better way? Is there a generally accepted way of passing form data to asp.net web/script services?

    Read the article

  • JSON Rpc libraries for use with .NET

    - by Deeptechtons
    I am looking into JSON RPC libraries for .net that are free to use in commercial applications. Up until now i just seem to have found JROCK. What other libraries, architecture have i got similar to JRock for .NET 2.0 What is the difference between a [WebMethod] in asmx web-service returning a instance of a class and a JSON Rpc method as in the JRock website page. Do i have any usability benefits, performance benefits or any benefits of using one over the other

    Read the article

  • i want to return List<DictionaryClass<string,string>> from web service but getting error for IDictio

    - by girish
    [WebMethod] public List<DictionaryClass<string,string>> GetDataByModuleDictionary(string ModuleName) { return BAL_GeneralService.GetDataByModuleDictionary(ModuleName); } here i m getting the following error... The type DictionaryClass`2[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] is not supported because it implements IDictionary.

    Read the article

  • simple jquery callback works on .net3.5 but nothing fires on .net 2.0?

    - by CliffC
    hi i have the following jquery postback method on the client <%@ Page Language="C#" AutoEventWireup="true" CodeFile="CallServerWithParameters.aspx.cs" Inherits="CallServerWithParameters" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script src="jquery-1.2.6.js" type="text/javascript"></script> <script language="javascript"> $(document).ready(function() { $("#txtNoOfMales").change(function() { var ticketRequired = this.value; var options = { type: "POST", url: "CallServerWithParameters.aspx/GetAvailableTicketsForMales", data: "{no:'" + ticketRequired + "'}", contentType: "application/json; charset=utf-8", dataType: "json", success: function(response) { if (response.d != "") { alert(response.d); $("#txtNoOfMales").focus(); } } }; //Call the PageMethods $.ajax(options); }); }); </script> </head> <body> <form id="form1" runat="server"> <div> No of Male Tickets:<asp:TextBox ID="txtNoOfMales" runat="server"></asp:TextBox> </div> </form> </body> </html> and the following web method on the server side using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.Services; public partial class CallServerWithParameters : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } [WebMethod] public static string GetAvailableTicketsForMales(int no) { string result = ""; int NoOfTicketsAvailable = 5; if (no > NoOfTicketsAvailable) { result = "Only " + NoOfTicketsAvailable.ToString() + " Male ticket(s) avaialable. Please eneter a lower number!"; } return result; } } problem is everything works fine on .net 3.5 but if i use the same code on .net 2.0 the webmethod event does not get call at all, anybody have any idea what i did wrong? thanks updated with full source code

    Read the article

  • Call a c# method from Javascript

    - by Luis
    Hi i want to call a C# method.. I already tryed with webmethod, but in the c# method i will not have acces to textbox or others controls. this is how i done without success.. http://www.singingeels.com/Articles/Using_Page_Methods_in_ASPNET_AJAX.aspx With static works, but i want without static, so i can access to the controls in the aspx and validate the page. how can i do it?

    Read the article

  • Changing namespace of Stream

    - by phenevo
    Hi, I've got asmx with method [Webmethod] public Ssytem.IO.Stream GetStream(string path) { ... } and winforms application which has webreference to this webservice. I cannot do something on my winforms application like something: var myStream= (System.IO.Stream)client.GetStream(path); because i Cannot cast expression "MyWinformsApp.MyService.Stream" to Stream. Why is that ?

    Read the article

  • When calling a asmx service via jqeury, how to pass arguments?

    - by Blankman
    How can I pass my service endpoint parameters? (pagesize in this case) My .asmx service method looks like: [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public List<Object> GetData(int pageSize) { } When I call this via jQuery like: $.ajax({ type: "POST", url: "test.asmx/test123", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: function(msg) { }, error: function(msg) { } });

    Read the article

  • SignOut() without postback in ajax login

    - by Romi
    Hi, I have one asp.net Ajax Login using webservices. In this login i call the loogout() client side from hyperlink: Sys.Services.AuthenticationService.logout(null,onLogoutCompleted,null,null); return false; My Webservice make : [WebMethod] public void Logout() { FormsAuthentication.SignOut(); } logout work but my page make one big postback. Some way to make NO postback at logout? Thanks

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >