webservice sending object - serialisation error

  • Thread starter Thread starter Rotsey
  • Start date Start date
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()

{

}

}
 
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.
 
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
 
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.
 
Back
Top