I have a web service and its methods return a class which is name WSResult. WSResult has 2 properties. One of property's type is int and the other one's type is object. I want to return some different type with this second property.
[code]....
How can i pass an object which i retrieved from other web services or that i generated from my serializable classes inside M_ResultObject property ?
I have a webservice - called MyCompany.WebService1
I reference this using a web reference in my ASP.net web application.
Theres a method called "GetDeal" in this web service, that returns a "Deal" Object.
The deal object currently looks (for example) like this:
[code]....
This class is in a different assembly: MyCompany.Model
The web service references this assembly.
In my web app, I can call the GetDeal method. This returns Service1.Deal (service1 is just the name of the web reference)
I can access both properties above. I have now changed the Deal class, and added a couple more properties.
However, I can't see these new properties in my web application. I've updated the web service in the web application. I rebuilt the web service several times, tried removing the MyCompany.Model reference and re-addding it etc...
I can't figure out what has changed... This was working - I have changed the model before, and it's updated the reference correctly...
public AuthenticationResult Authenticate(Enum type, string userName, string password) But the problem I had is that if a null/invalid enum is entered for the type variable it throws an error message.
So the obvious solution is to use a string/int instead but I am cannot do this as current users already use the existing webmethod.
So i was thinking:
public AuthenticationResult Authenticate(object type, string userName, string password) and handling the casting myself but the problem I had with this is that now my users do not have access to the Enum type.
So my question is can I publish the enum type without having it as a parameter/return value? Allow the client to access the Enum so they can pass it into the method. Would using a method that returned a type that was my enum work? Or is there a way to catch this custom error: (I dont think so as it appears to be on the client end when converting Enum to xml). The error is: (System.InvalidOperationException: There was an error generating the XML document. ---> System.InvalidOperationException: Instance validation error: '45465' is not a valid value for Enum.)
I just hit the following issue: I am calling a web service that returns a serialized JSON object let's say: __type, FirstName, LastName (.net object Person with properties FirstName and LastName). __type's value is Test.Person
I have created a JS object using Type.registerNameSpace/registerClass called Demo.Person and it is registered on the page using the ScriptManager. Everything is working fine; I am able to get data from the server on the call back.
Is it possible to make the returned object from the web service be an instance of the declared JavaScript Demo.Person class? The idea would be to call a method like result.getFullName() on the client side without having to copy all the properties. This is just a simple scenario for more complex objects.
public dynamic GetReferenceTableData(string tableName) { try { dynamic tableData = ReferenceTableDAL.GetReferenceTableData(tableName); return tableData; } catch (Exception ex) { throw; } } method at DAL(ReferenceTableDAL): public static dynamic GetReferenceTableData(string tableName) { Database db = DatabaseFactory.CreateDatabase(Flags.ConnectionStringKey); DbCommand dbCommand = db.GetStoredProcCommand("USP_GETTABLEDATA"); dynamic objDynamic = null; if (tableName.ToLower() == "a") { objDynamic = new List<A>(); } else if (tableName.ToLower() == "b") { objDynamic = new List<B>(); } else if (tableName.ToLower() == "c") { objDynamic = new List<C>(); } try { db.DiscoverParameters(dbCommand); dbCommand.Parameters["IN_TABLENAME"].Value = tableName; DataSet dsTableData = db.ExecuteDataSet(dbCommand); if (tableName.ToLower() == "a") { foreach (DataRow dataRow in dsTableData.Tables[0].Rows) { objDynamic.Add((A)dataRow); } } else if (tableName.ToLower() == "b") { foreach (DataRow dataRow in dsTableData.Tables[0].Rows) { objDynamic.Add((B)dataRow); } } else if (tableName.ToLower() == "c") { foreach (DataRow dataRow in dsTableData.Tables[0].Rows) { objDynamic.Add((C)dataRow); } } } catch (Exception ex) { throw; } return objDynamic; } @ Aspx try { using (DataServiceRef.DataServiceClient petService = new DataServiceRef.DataServiceClient()) { dynamic tableData = petService.GetReferenceTableData(tableName); //tableData is null ,exception } } catch (Exception ex) { throw; }
There is no exception at dal or service end when i debug list gets filled ok but when returns to aspx error at aspx(no exception gets caught at @ service) but exception at aspx i.e:
Message:The underlying connection was closed: The connection was closed unexpectedly. Stack Trace: at System.Net.HttpWebRequest.GetResponse() at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
Can my WebMethod return an XmlDocument as return type?
When I try to consume the web service I'm still not getting XML. It appears as though a reference to the method is being returned rather than say a string containing XML.
<WebMethod()> _ Public Function CustomerSearch(ByVal lastName As String, ByVal firstName As String, ByVal companyName As String, ByVal city As String, ByVal state As String, ByVal email As String) As XmlDocument ' Create XML doc Dim doc As XmlDocument = New XmlDocument() ' some more code Return doc End Function
I have simple 3 tier web application and have mostly CRUDE functionalities. Recently I required to add new console application to the existing solution in which I call data layer methods for retrieving data from DB but I get an exception "The type initializer for threw an exception."When I debugged I found that the exception is thrown at datalayer on first line of class where I get connectionstring from
web.config, the code is public static readonly string CONNECT_STRING =
Now if I hardcode the connection string value like public static readonly string CONNECT_STRING = "Data Source=XYZ;uid=sa;password=XXX;initial catalog=ABC;"
it works fine.I don't understand what is the issue here as web application works fine with this datalayer.
we have console-hosted WCF Service and ASP.NET WEB Service (on IIS). After some tough operation WCF Service must return some data(large data) to ASP.NET Web Service for next processing. I tested on small results - everything is ok. But after testing on real data(serialized result object is near 4.5 mb) error occurs on ASP.NET Web Service (which is client in wcf-client-server communication).
Messages size are configured by next binding (on server and client): NetTcpBinding netTcpBinding = new NetTcpBinding(); netTcpBinding.TransactionFlow = true; netTcpBinding.SendTimeout = new TimeSpan(0, 4,0, 0); netTcpBinding.Security.Mode = SecurityMode.None; [code]...
I developed a web service in VS2010 on my local machine, wrote a consumer of it also locally, and that all works.
I copied the dll and the asmx file to our server, and I am getting an error when I try to invoke it from a browser (also still on the server machine) to make sure it correctly exposes its web methods, but it is not, it is saying "Could not create type 'Service'". That error comes from this line:
Line 1: <%@ WebService Language="C#" CodeBehind="~/App_Code/WarrantyDuplicate.cs" Class="Service" %> There other web services in the same folder on the server that all work fine so I don't believe it's an IIS setup thing.
This is my first web service in C# and when I created it in VS I did think it odd that the code behind file went into App_Code (as you can see from the line in the asmx file) and is just named dot-cs rather than asmx-dot-cs. But since it worked fine locally, I wasn't sure that mattered.
We have an asp.net 2.0 application in which we get the exception of type 'System.OutOfMemoryException' whenever value is retrieved or stored in viewstate. It does not happen when we test it in local PC but when it is deployed on application server, the exception is thrown.
I'm trying to extend the GridView class to always show the header and footer even when the datasource is empty by using the code I found online (link). However, the code is written in C# but I use VB.
What is the VB equivalent of the following?
public event MustAddARowHandler MustAddARow;
Is there a way around VB.NET not allowing events to return a type?
Also, I cannot convert the following function because of the error below.
Do any one know how to return an anonymous type. I am using Linq where i need to return the following code
private <What's the return type to be provided here> SampleLinq(Int32 Num) { var query = (from dept in obj.DeptTable where dept.Id == Num select new { dept.DeptName, dept.DeptId }); return (query) }
I have one issue , on that page i have Gridview ie: binding data(by making relationship b/w two tables ) ie: each row contains 75 EasyListbox control so it will be visible as per the condition ie: getting from Database.
But when the page_Loads on that page - First rows shows correctly ie: when i click on paging for Second page - it shows error like this
I want to log all errors happened in my App to sql db. I'm passing all exception properties like (ex.Message, ex.Source, ex.StackTrace, ex.TargetSite and ex.InnerException) to stored procedure.
The problem is that when I try to pass the ex.InnerException as string to stored procedure I got this error:
Cannot implicitly convert type 'System.Exception' to 'string'
I tried ex.InnerException.ToString() and Convert.ToString (ex.InnerException) but no success.
I am getting Error Msg Given Below..After Uploading My WebApplication..whenever i try to access my webapplication? what is the exactly reason of this Error. Some time it solved automatically when i try some time later.
Server Error in '/' Application.
Exception of type 'System.OutOfMemoryException' was thrown. 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.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
I recently downloaded the mvc 3 RC and I am receiving a type load exception everytime i do a fresh compile and start a debugging session. The error is
System.TypeLoadException crossed a native/managed boundary
[code]...
I can click ok and my debug session continues working as normal. I can close the session and restart without making any code changes, and it will open and work correctly. But, everytime I close, make a compilable change and rerun, I get the message.
I have ELMAH set up for a webapp, logging exceptions to a SQL server. I wish to have ELMAH send me an email too, but only when a specific exception is thrown (ie. MySpecialException). ELMAH must still log all exceptions to SQL server. I know you can do it programmatically in global.asax, but I'd prefer to use web.config. So, how do I restrict ELMAH error mails to filter out everything but a specific exception type, using web.config? UPDATE The filter ended up looking like this:
I am getting this exception whenever i tried to delete the WCF Service reference in project.I cannot even update it.Our WCF Service is bit huge and looks like this is causing the issue.I Start/Stopped IIS web server but still i cant get rid of it.
I have create a table and create edmx file, and I create a Stored Procedure that return a single row (select by primary key), and I want the edmx to have a function that calls that SP and return a type.
I am consuming an RSS feed to display on my website using a repeater control. I was wondering if it's possible in VB to return an anonymous type from my linq query rather than a collection of strongly typed RSSItems. I know this is possible in C#, however haven't been able to work out a VB equivalent.
I have this storde procedure that I add to my dbml file, when I do that it does not recognize the return type. The return type is a string, how do I set that it should be a string?