Returning an object from a web service
-
Hi Folks, I currently have an issue where I'm trying to write some code to allow me to return an object from a web service. When this object is based on a Struct, all's good. However, when I replace the Struct with a [Serializable]Class, compile, and run the service, on invoking the method which is to return the class object, I receive the below error: ====================================================================================================== Server Error in '/' Application. -------------------------------------------------------------------------------- This type of page is not served. Description: The type of page you have requested is not served because it has been explicitly forbidden. The extension '.asp' may be incorrect. Please review the URL below and make sure that it is spelled correctly. Requested URL: /default.asp ====================================================================================================== The reason I'd like to move from using a Struct to a Class is this would allow me to take advantage of interfaces and generics, to move the code which currently populates the Struct's properties from a DbDataReader's values into a delegate function, which can take a reader and a list of each field's type, and convert each record to an instance of the Struct. Thanks in advance. JB
-
Hi Folks, I currently have an issue where I'm trying to write some code to allow me to return an object from a web service. When this object is based on a Struct, all's good. However, when I replace the Struct with a [Serializable]Class, compile, and run the service, on invoking the method which is to return the class object, I receive the below error: ====================================================================================================== Server Error in '/' Application. -------------------------------------------------------------------------------- This type of page is not served. Description: The type of page you have requested is not served because it has been explicitly forbidden. The extension '.asp' may be incorrect. Please review the URL below and make sure that it is spelled correctly. Requested URL: /default.asp ====================================================================================================== The reason I'd like to move from using a Struct to a Class is this would allow me to take advantage of interfaces and generics, to move the code which currently populates the Struct's properties from a DbDataReader's values into a delegate function, which can take a reader and a list of each field's type, and convert each record to an instance of the Struct. Thanks in advance. JB
The only reason for the error is you need to rebind your web service reference to your project. Just remove the web reference of your web service and rebind it and that's it. For quick reference find following links to return serialized object from web service. http://stackoverflow.com/questions/255400/serializing-name-value-pairs-in-a-custom-object-via-web-service[^] http://ryanfarley.com/blog/archive/2004/05/26/737.aspx[^] Hope this will help!
Jinal Desai - LIVE
modified on Friday, April 30, 2010 7:28 AM
-
Hi Folks, I currently have an issue where I'm trying to write some code to allow me to return an object from a web service. When this object is based on a Struct, all's good. However, when I replace the Struct with a [Serializable]Class, compile, and run the service, on invoking the method which is to return the class object, I receive the below error: ====================================================================================================== Server Error in '/' Application. -------------------------------------------------------------------------------- This type of page is not served. Description: The type of page you have requested is not served because it has been explicitly forbidden. The extension '.asp' may be incorrect. Please review the URL below and make sure that it is spelled correctly. Requested URL: /default.asp ====================================================================================================== The reason I'd like to move from using a Struct to a Class is this would allow me to take advantage of interfaces and generics, to move the code which currently populates the Struct's properties from a DbDataReader's values into a delegate function, which can take a reader and a list of each field's type, and convert each record to an instance of the Struct. Thanks in advance. JB
The type of object has nothing to do with your problem. Basically, you have something trying to serve up default.asp and this extension has not been allowed by your web server. I suspect that you should actually have default.aspx in there.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.