Click here to Skip to main content
15,889,462 members
Home / Discussions / C#
   

C#

 
QuestionHow to make a column of listview control invisible Pin
NarVish22-Apr-09 4:30
NarVish22-Apr-09 4:30 
AnswerRe: How to make a column of listview control invisible Pin
Eddy Vluggen22-Apr-09 4:55
professionalEddy Vluggen22-Apr-09 4:55 
Questionhelp Pin
benson.misi22-Apr-09 4:28
benson.misi22-Apr-09 4:28 
AnswerRe: help Pin
musefan22-Apr-09 4:35
musefan22-Apr-09 4:35 
AnswerRe: help Pin
SeMartens22-Apr-09 4:39
SeMartens22-Apr-09 4:39 
AnswerRe: help Pin
CPallini22-Apr-09 4:41
mveCPallini22-Apr-09 4:41 
AnswerRe: help Pin
Thomas ST22-Apr-09 4:45
Thomas ST22-Apr-09 4:45 
QuestionObject "type not expected" when using serialization in web services Pin
BASONJS22-Apr-09 4:03
BASONJS22-Apr-09 4:03 
Hi all,

Hope I am posting this in the right forum.

I seem to be having a problem when using serialization and web services.

Scenario:

I have built a web service which includes a multitude of web methods. All the web methods have various parameters, but one parameter which they all have in common is an 'object' parameter. This is due to the fact that the web service works differently according to the type of object being passed into it.

Now as for the objects, I have constructed a set of custom classes which satisfy my need. For example's sake, let us say we have:

Teacher class
Student Class
LectureRoom Class
Lecture Class

We will call these the "School Package classes"

I am then wrapping these classes within other custom classes which I use not only to transport my objects around but also to keep track of statuses etc. Example:

Request Class
Response Class

The school package classes would be serialized and saved within the request or response class. So effectively, the objects which the web service really sees are the request and response classes which will in turn have the school package classes inside of them.

The Problem:

The problem is found when a school package object is passed within the response and request object. On deserialisation or transportation of these objects, the web service always throws an exception as follows:

{"System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.InvalidOperationException: There was an error generating the XML document. ---> System.InvalidOperationException: The type <classname> was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically.

From what I could gather and the research I have done, the problem lies with the web service not knowing of the object types at compile time.

Make Shift Solution:
For a quick and dirty solution I created methods within the web service which use the object types needed. For Example:

public void Junk(Student myStudent){}

This seemed to have worked, but is not what I want, as with about 40 custom classes, this is both horrible coding and very tedious.

I have also tried researching the xmlinclude and soapinclude found in the System.Xml.Serialization library, but dont really know how to use these. I have tried adding them above the web service class declaration and the web methods which use the objects in this format:

[XmlInclude(typeof(Student))]

But yet to no avail. I have officially run out of ideas and would greatly appreciate anyone who has experience or ideas regarding this problem.

Thank you very much in advance for your time and excuse the length of the post.

James Bason
AnswerRe: Object "type not expected" when using serialization in web services Pin
Thomas ST22-Apr-09 4:59
Thomas ST22-Apr-09 4:59 
GeneralRe: Object "type not expected" when using serialization in web services Pin
BASONJS22-Apr-09 5:14
BASONJS22-Apr-09 5:14 
GeneralRe: Object "type not expected" when using serialization in web services Pin
Thomas ST22-Apr-09 20:57
Thomas ST22-Apr-09 20:57 
GeneralRe: Object "type not expected" when using serialization in web services Pin
BASONJS22-Apr-09 23:04
BASONJS22-Apr-09 23:04 
GeneralRe: Object "type not expected" when using serialization in web services Pin
BASONJS23-Apr-09 5:29
BASONJS23-Apr-09 5:29 
Questionproblem with keypress function Pin
MehmetKocc22-Apr-09 3:57
MehmetKocc22-Apr-09 3:57 
AnswerRe: problem with keypress function Pin
musefan22-Apr-09 4:02
musefan22-Apr-09 4:02 
AnswerRe: problem with keypress function Pin
Luc Pattyn22-Apr-09 4:13
sitebuilderLuc Pattyn22-Apr-09 4:13 
AnswerRe: problem with keypress function Pin
DoctorMick22-Apr-09 4:15
DoctorMick22-Apr-09 4:15 
AnswerRe: problem with keypress function Pin
ramz_g22-Apr-09 23:22
ramz_g22-Apr-09 23:22 
QuestionRefreshing Windows Form content / moving the window around Pin
Piratenwichtl200022-Apr-09 3:40
Piratenwichtl200022-Apr-09 3:40 
AnswerRe: Refreshing Windows Form content / moving the window around Pin
musefan22-Apr-09 4:00
musefan22-Apr-09 4:00 
GeneralRe: Refreshing Windows Form content / moving the window around Pin
Piratenwichtl200022-Apr-09 21:24
Piratenwichtl200022-Apr-09 21:24 
QuestionHow can i perform Alt+T operation through programming in c#.net 3.5 Windows application. Pin
Narendra Reddy Vajrala22-Apr-09 3:35
Narendra Reddy Vajrala22-Apr-09 3:35 
AnswerRe: How can i perform Alt+T operation through programming in c#.net 3.5 Windows application. Pin
Henry Minute22-Apr-09 3:49
Henry Minute22-Apr-09 3:49 
GeneralRe: How can i perform Alt+T operation through programming in c#.net 3.5 Windows application. Pin
Narendra Reddy Vajrala22-Apr-09 5:08
Narendra Reddy Vajrala22-Apr-09 5:08 
GeneralRe: How can i perform Alt+T operation through programming in c#.net 3.5 Windows application. Pin
Henry Minute22-Apr-09 5:12
Henry Minute22-Apr-09 5:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.