webservice sending object - serialisation error

R

Rotsey

Hi,

I am trying to send a object to a webservice and I get an serialisation
error
on the object saying "object not expected" add "XmlInclude or
SoapInclude attribute"

I have done this but still get the error.

Below is the class. The problem is with "data" object.

I want to send different classes not known to the service wrapped
in another object.

Antyone know why?

Is there a better method I am missing?

rotsey





[XmlInclude(typeof(NukedEmShot))]

public class BroadcastMessage

{

private BroadcastMessageType messageType;

public BroadcastMessageType MessageType

{

get { return MessageType;}

set { MessageType = value;}

}

[XmlElement(typeof(NukedEmShot))]

private object data;

public object Data

{

get { return data; }

set { data = value; }

}

private string sender;

public string Sender

{

get { return sender; }

set { sender = value; }

}

private ArrayList recipients;

public ArrayList Recipients

{

get { return recipients; }

set { recipients = value; }

}

private ReturnStatus status;

public ReturnStatus Status

{

get { return status; }

set { status = value; }

}

public BroadcastMessage()

{

}

}
 
J

John Saunders [MVP]

Rotsey said:
Hi,

I am trying to send a object to a webservice and I get an serialisation
error
on the object saying "object not expected" add "XmlInclude or
SoapInclude attribute"

I have done this but still get the error.

Below is the class. The problem is with "data" object.

I want to send different classes not known to the service wrapped
in another object.

Antyone know why?

Is there a better method I am missing?

How will the service process the objects of types it doesn't know about? How
would the service know how to deserialize the objects?

Depending on what you expect to have happen, you might need to process the
data as XML.
 
R

Rotsey

John,

What I am trying to do is send data to the webservice and that other
requests can receive. I am using the Application object for this.
This is a small appliation with not much data being sent.

So I have several objects that I want to wrap in a wrapper class
and send to be broadcasted.

I tried your idea of sending xml, so I serialize my objects and
then send then in a string in the wrapper class

Now I get this error message

Client found response content type of 'text/html; charset=utf-8', but
expected 'text/xml'.

Do you have any input in the way I should do this?

rotsey
 
J

John Saunders [MVP]

Rotsey said:
John,

What I am trying to do is send data to the webservice and that other
requests can receive. I am using the Application object for this.
This is a small appliation with not much data being sent.

So I have several objects that I want to wrap in a wrapper class
and send to be broadcasted.

I tried your idea of sending xml, so I serialize my objects and
then send then in a string in the wrapper class

Now I get this error message

Client found response content type of 'text/html; charset=utf-8', but
expected 'text/xml'.

This message means that you've received an error from ASP.NET in the form of
a HTML page. You should look at the HTML to see what the error is.
Alternatively, you should look in the Application event log for warning
messages from ASP.NET. Look to see what error is happening. It may be due to
a simple bug in your code rather than a problem with the technique.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top