WCF / ASMX :: Passing Multiple Parameters To A Web Method?
Dec 15, 2010
I am creating a Web Service, which will be used by a client to send data to our Database.The client will be sending close to 30 fields that will be updated to our table. If I write a Web method, I will need to have all these 30 fields as parameters to that method. Is there a better way than sending all of them as parameters?
View 3 Replies
Similar Messages:
Nov 13, 2010
i have the following method, however i want to pass methods to it, i know how to do it the usual way, however when it comes to Webservices/API's what is the correct way to do it. Here is my method so far;
[Code]....
View 1 Replies
Jan 4, 2011
i am working in the webservice project. I have one project when i run it then shows the text box for parameters and return the result after passing the parameters.
But another webservice does not allow me to enter the paramerters when execute then list of methods displayed and then show the soap xml when click at any method.
what difference found in both webserivces are Excuting-one that have the Text boxes: Test: "To test the operation using the HTTP POST protocol, click the 'Invoke' button."
2nd One Not provide the parameter text boxes: Test: "The test form is only available for methods with primitive types as parameters"
Dont know how to fix that. Because i want to debug the webservice and as i am unable to provide the parameter then how can i fix it.
how can i pass the parameters in the 2nd webservice as it has different information mentioned above.
View 1 Replies
Oct 6, 2010
I have a simple Web Service method defined as:
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string MyWebMethod(string foo, string bar)
{
// DataContractJsonSerializer to deserialize foo and bar to
// their respective FooClass and BarClass objects.
return "{"Message":"Everything is a-ok!"}";
}
I'll call it from the client via:
var myParams = { "foo":{"name":"Bob Smith", "age":50},"bar":{"color":"blue","size":"large","quantity":2} };
$.ajax({
type: 'POST',
url: 'https://mydomain.com/WebServices/TestSvc.asmx/MyWebMethod',
data: JSON.stringify(myParams),
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function (response, status) {
alert('Yay!');
},
error: function (xhr, err) {
alert('Boo-urns!');
}
});
However, this yields the following error (a breakpoint on the first line in MyWebMethod() is never hit):
{"Message":"No parameterless
constructor defined for type of
u0027System.Stringu0027.","StackTrace":"
at
System.Web.Script.Serialization.ObjectConverter.ConvertDictionaryToObject(IDictionary2
dictionary, Type type,
JavaScriptSerializer serializer,
Boolean throwOnError, Object&
convertedObject)
at
System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeInternal(Object
o, Type type, JavaScriptSerializer
serializer, Boolean throwOnError,
Object& convertedObject)
at
System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeMain(Object
o, Type type, JavaScriptSerializer
serializer, Boolean throwOnError,
Object& convertedObject)
at
System.Web.Script.Services.WebServiceMethodData.StrongTypeParameters(IDictionary2
rawParams)
at
System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext
context, WebServiceMethodData
methodData, IDictionary`2
rawParams)
at
System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext
context, WebServiceMethodData
methodData)","ExceptionType":"System.MissingMethodException"}
I'd like to pass in two string parameters and use DataContractJsonSerializer to write new Foo and Bar objects. Am I missing something?
View 3 Replies
Jan 18, 2011
For example, we are going to consume web method GetEmployeeByQuery(ConnInfoXML, Query, RecordDetail), ConnInfoXML is login information in XML, Query is a SQL statement selecting records, RecordDetail is all records retrieved. All data are in XML format.
So how to write these parameters in XML to consume this web method and get all the information in XML, and then transfer XML to normal string format ?
View 1 Replies
Jan 7, 2010
Im wonding what the correct syntax is to pass 2 parameters from a Ascx control into a Vb.net function? Heres what I currently have:
<asp:Literal
ID="CommentFooterLiteral1"
Visible='<%# Eval("Approved") Or IsModerator() %>'
Text='<%# FormatFooter(Eval("Anonymous"), Eval("DisplayName"), Eval("CreatedDate")) + "
" + GetModeratorStatus(Eval("UserId")) %>'
runat="server"
/>
The Function "FormatFooter", needs to pass in Anonymous and DisplayName parameters. Anyone know the correct syntax for doing this?
View 2 Replies
Sep 20, 2010
I am trying to pass parameters in the hyperlink.
The code in sending page is as below
[Code]....
View 2 Replies
Jan 24, 2011
I need to execute the following exe file with multiple arguments from asp.net web application
"C:Program FilesSysteminvoke.exe" /project "UPLOAD" /app "Default App" /task "XMLGEN" /parm.OutputDirectory "c: emp"
I tried the following asp.net code,
[code]....
View 4 Replies
Mar 23, 2011
I have a web service called service1. Is it possible to pass the parameter related to the service to a class library so for e.g.
Service1.service ws = new Service1.service();
Service1.UserDetails ud = null;
now if I call a method that exists in a class and pass ud. Cam i do that because I am trying to do this and I am getting an error. Do i need to add a web
reference to this service in the class library My method call is like this
authenticateUser.Authenticate(ud, UserName);
and in the class libary I have
public void Authenticate( Service1.UserDetails ud , string UserName)
{
}
View 3 Replies
Jul 29, 2010
I have a parameter screen which contains many pop up windows for the parameters .
I have a department hierarchy which consists of department , branch and section.
I have 3 pop up windows for each parameter.
When i select, a department, it filters the list of the branch and shows only its branch when i open the branch pop up window.
But the problem is, when i select multiple departments, the branch pop up window shows the below error. The page works if only a department is shown.
Conversion failed when converting the nvarchar value '3,4,5,6 to data type int. Description: An unhandled exception occurred during the execution of the current web request. review the stack trace for more information about the error and where it originated in the code.
My code for the branch page is :
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Branch.aspx.cs" Inherits="Modules_Reports_Branch" Title="Select Branch"%>
<!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 id="Head1" runat="server">
[Code]....
View 4 Replies
Feb 24, 2011
I want to generate crystal report in pdf format. I had done the same thing by passing one parameter. But this time I want to pass 10 parameter. I followed the same thing what I did for passing one parameter.
But now I got the Error Message "Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack."
[Code].....
View 1 Replies
Dec 26, 2010
I have added a gridview in my aspx web page. I have added a hyperlink field, to navigate to another page from the gridview. I am getting the error as:
"There was an error rendering the control.
Index(zero based) must be greater than or equal to zero and less than the size of the argument list. "
This is the code i have used:
[Code]....
[Code]....
When i remove the hyperlink, the grid is getting displayed. I know, there is something wrong i have coded in the DataNavigateURLformatstring, but not sure what is wrong.
I want to pass the StudentID,CourseID,ChildImageID with the link as the querystring.
View 3 Replies
Apr 29, 2010
I Have a gridview where I have a link to a details page and I need to pass multiple parameters. I currently have the following:
<Columns>
<asp:BoundField DataField="AssocID" HeaderText="AssocID" InsertVisible="False"
ReadOnly="True" SortExpression="AssocID" />
<asp:BoundField DataField="FirstName" HeaderText="First Name"
SortExpression="FirstName" />
<asp:BoundField DataField="MiddleInitial" HeaderText="M. I."
SortExpression="MiddleInitial" />
<asp:BoundField DataField="LastName" HeaderText="Last Name"
SortExpression="LastName" />
<asp:BoundField DataField="State" HeaderText="State" SortExpression="State" />
<asp:BoundField DataField="EMail1" HeaderText="EMail 1"
SortExpression="EMail1" />
<asp:BoundField DataField="AddrType" HeaderText="Addr Type"
SortExpression="AddrType" />
<asp:HyperLinkField DataNavigateUrlFields="AddrID,AssocID"
DataNavigateUrlFormatString="Details.aspx?AddrID={0}&AssocID={1}" HeaderText="Details"
Text="Details" />
<asp:BoundField DataField="AddrID" HeaderText="AddrID" InsertVisible="False"
ReadOnly="True" SortExpression="AddrID" Visible="False" />
</Columns>
According to all I have read my DataNavagateUrlFields string should work but it isn't. The deal is that any one (AssocID) can have multiple AddrID's associated with it. Regardless of which I choose I only get back the first AddrID for that AssocId.
View 10 Replies
Dec 9, 2010
I'm calling PageMethod "SameMethod" from javascript method "caller" so that I can get some values from DB. After I get values, control is continuing in "onSuccess" method. Problem is that I need to use some variable values ("importantValue") from javascript method "caller" in "onSuccess" method.
function caller(){
var importantValue = 1984;
PageMethod.SomeMethod(param1,..., onSuccess, onFailure)
}
onSuccess method should be something like this:
function onSuccess(pageMethodReturnValue, importantValue ){
}
Is it possible and, if it is, how to pass multiple parameters (besides return values of page method) to "onSuccess" method of PageMethod?
View 2 Replies
Dec 10, 2010
Since ASP.NET MVC3 RC2 I encounter a bug when posting values to a controller method of which one of the parameter is a nullable int. Steps to reproduce:
I've created a test method
[code]....
In MVC3 RC1 this was working without any problems with the nullable int
Update:
I don't seem to have the problem with a newly created MVC3 website. What could I have in my project that influence model binding to nullable int's? And why would there be a difference between RC1 and RC2?
View 10 Replies
Nov 10, 2010
On my page I have a dropdown for country.
On my asmx service I want to get the value of the dropdownlist to filter the next input which will be state/providence.
My code on the asmx:
[Code]....
I want to add another clause to the WHERE statement to restrict Country = @Country so I will need to get that value to the web service.
View 2 Replies
Feb 16, 2011
[Code]....
When I want to get the output values its okay but I also want returning a table as a result data.But Datareader has no rows.is it possible if I want a returning query result and multiple output values togather ?I wrote a test above.I can get output values as sqlparameters. But Datareader attached to a Gridview is empty.can you detect whats wrong here and it doesnt return a query result.So stored procedure is not standart or ı am doing something wrong.this doesnt raise any exception.but not returning any data.
[code]....
View 8 Replies
Sep 14, 2010
I want to execute a certain piece of code by default before each web Method.
Without adding any extra code in each method how to achieve this?
I am calling this service from Win application.
View 1 Replies
Jul 9, 2010
In this answer to my question of how to insert data into SQL Server he mentioned passing parameters instead of string concatenation like I currently have.
Is this really necessary for security? If so, what exactly is passing parameters? When i google it I get a lot about stored procedures. Is that what I want, I do not know about stored procedures....yet.
EDIT:
Ok, here is what I got. It seems to update the database correctly and eventually I will change the hard coded ints to inputs from a label. confirm if how I did this is not vulnerable to any sql injection or hacks.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
public partial class Stats : System.Web.UI.Page
{
public SqlDataReader DataReader;
public SqlCommand Command;
string queryString = ("INSERT INTO UserData (UserProfileID, ConfidenceLevel, LoveLevel, HappinessLevel) VALUES (@UID, @CL, @LL, @HL);");
//string queryString = ("INSERT INTO UserData (UserProfileID, ConfidenceLevel, LoveLevel, HappinessLevel) VALUES ('a051fc1b-4f51-485b-a07d-0f378528974e', 2, 2, 2);");
protected void Page_Load(object sender, EventArgs e)
{
LabelUserID.Text = Membership.GetUser().ProviderUserKey.ToString();
}
protected void Button1_Click(object sender, EventArgs e)
{
//connect to database
MySqlConnection database = new MySqlConnection();
database.CreateConn();
//create command object
Command = new SqlCommand(queryString, database.Connection);
//add parameters. used to prevent sql injection
Command.Parameters.Add("@UID", SqlDbType.UniqueIdentifier);
Command.Parameters["@UID"].Value = Membership.GetUser().ProviderUserKey;
Command.Parameters.Add("@CL", SqlDbType.Int);
Command.Parameters["@CL"].Value = 9;
Command.Parameters.Add("@LL", SqlDbType.Int);
Command.Parameters["@LL"].Value = 9;
Command.Parameters.Add("@HL", SqlDbType.Int);
Command.Parameters["@HL"].Value = 9;
Command.ExecuteNonQuery();
}
}
View 7 Replies
Apr 12, 2010
I am using VS 2008 SP1. My also have included CSS Friendly adapter [URL] in my project ( I mentioned this because my GridView Empty data template is not showing when using GridView's CCS Friendly adapter). I have a GridView and a DetailsView. When a record in GridView is selected its details information is shown in the Details View. Type of Data source I am using is ObjectDataSource. My Insert and Update methods works perfectly. It is only the Delete method that is passing null values to the underlying object delete method. My source codes for both the UI, BLL, DAL is shown below
[Code]....
My Business Object code is below :
[Code]....
My Data Access Layer Code is:
[Code]....
View 2 Replies
Apr 21, 2010
when i worked in .NET 1.1 i used to pass parameters to user control using the method- (if the name of the usercontrol is "tables")
dim r As tables =
CType(Page.LoadControl("~/usercontrol/tables.ascx"), tables)
and calling public property of the usercontrols.
the problem is that i can't the way to do it in 2008 ver of .NET, it is not recognize the usercontrol.... how can i pass parameters to the usercontrol in run time?
View 10 Replies
Oct 9, 2010
[Code]....
and my Index
[Code]....
View 1 Replies
Aug 3, 2010
i have a dropdownlist with seven different optins like (date, subject, press, cia, media...) and user will select one of the item from the dropdownlist and click on search button to get the results.here is my repository class GetInquires method which accepts 7 parameters but it will pass only one prameters at a time to the storeproc and in case of Date (it will pass both from/to)
public List<Inquiry> GetInquiries(string fromDate, string toDate,
string subject, string press,
string cia, string media,
[code]...
View 6 Replies
Aug 24, 2010
I am trying to use a parameter field where there is a subreport in my main report but i keep getting the error "subreport cannot be shown" when running the report.
p.s - I have just set the parameters the same in the subreport as the main report.
View 2 Replies
May 23, 2010
I have a page with a lot of pictures on it. I want the user to be able to click on the picture and either bring up a popup type of window passing it the Param name and value , or to have the picture be replaced with this object.
<object id="ADR2" type="application/x-Autodesk-DWF"
width="250" height="250"> <param name="dwffilename"
value="path" /> </object>
I have found a number of places describing how to bring up a popup window, but not on how to pass it the values.
View 2 Replies