Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / May 2005

Tip: Looking for answers? Try searching our database.

Error: The type namespace.class was not expected. Use the XmlInclude or SoapInclude attribute....

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nick Gilbert - 25 May 2005 12:20 GMT
Hi,

I'm developing a webservice that will accept an Order and forward it to
a backend system, but I'm having a problem with transferring my "Order"
class over a webservice.

When I try and call the webservice and pass it an Order, I get the
following error message:

The type Wright.BusinessLogicLayer.OrderLine was not expected. Use the
XmlInclude or SoapInclude attribute to specify types that are not known
statically.

Source Error:

Line 55:         public string EchoOrder(Order order) {
Line 56:             object[] results = this.Invoke("EchoOrder", new
object[] {
Line 57:                         order});
Line 58:             return ((string)(results[0]));

My Order class contains a single property, which is just an ArrayList of
OrderLines.

I've tried adding the SoapAttribute but it seems to have no effect:

[WebMethod]
[SoapInclude(typeof(OrderLine))]
public string EchoOrder(Order order) {
  return order.ToString();
}

Any ideas what am I doing wrong?

Thanks!

Nick...
Nick Gilbert - 25 May 2005 15:29 GMT
The odd thing is, if I change my class so that it has a single OrderLine
object instead of an arraylist of them:

        public OrderLine Item {
            get { return item; }
            set { item = value; }
        }

as opposed to:

        public ArrayList OrderItems {
            get { return orderItems; }
            set { orderItems = value; }
        }

Then it works fine. So it's obviously having trouble serializing the
ArrayList of OrderItems.

I don't know how to fix this and I can't proceed with my project until
I've got this working! Needless to say - I'm getting very stressed and
worried!

Nick...
Sami Vaaraniemi - 27 May 2005 08:22 GMT
Change the property to:

public OrderLine[] OrderItems
{
   ...
}

Regards,
Sami

> The odd thing is, if I change my class so that it has a single OrderLine
> object instead of an arraylist of them:
[quoted text clipped - 19 lines]
>
> Nick...

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.