Entity cannot be passed as Object

Posts   
 
    
mkamoski avatar
mkamoski
User
Posts: 116
Joined: 06-Dec-2005
# Posted on: 10-May-2006 17:37:43   

All--

It looks like an Entity cannot be passed as Object.

Is this the case?

I am trying to return an Entity as an Object from a web service and I get the error message below.

I am wondering-- is this an LLBLGen restriction, a Web Services restriction, or something else?

FYI, we are using LLBLGen, ASP.NET, VS.NET 2003, VB.NET, .NET 1.1, the Adapter templates, SQL Server 2000, web services, SD.LLBLGen.Pro.DQE.SqlServer.NET11.dll Version 1.0.20051.51207, SD.LLBLGen.Pro.ORMSupportClasses.NET11.dll Version 1.0.20051.51214, Windows XP Pro, IIS 5.1, and so on.

FYI, I have read the posts about web services and have seen in the help files that an LLBLGen object should be serialized to String or converted to a DataSet or one should adjust the proxy by hand or one should make a custom DTO.

But, I am specifically wondering about passing it as an Object and I am curious as to why that does not work.

(Unfortunately, our team lead does not want to pass the Entity as a String of XML, which does work perfectly.)

This is the error.

' 'System.Web.Services.Protocols.SoapException: Server was unable to process 'request. --> 'There was an error generating the XML document. --> ' 'The type Scratch.Llblgen.Windows.VB.Northwind.EntityClasses.ShippersEntity 'may not be used in this context. 'To use Scratch.Llblgen.Windows.VB.Northwind.EntityClasses.ShippersEntity 'as a parameter, return type, or member of a class or struct, 'the parameter, return type, or member must be declared as type 'Scratch.Llblgen.Windows.VB.Northwind.EntityClasses.ShippersEntity '(it can't be object). Objects of type 'Scratch.Llblgen.Windows.VB.Northwind.EntityClasses.ShippersEntity may not be 'used in un-typed collections, such as ArrayLists. ' ' at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse '(SoapClientMessage message, WebResponse response, 'Stream responseStream, Boolean asyncCall) ' at System.Web.Services.Protocols.SoapHttpClientProtocol. 'Invoke(String methodName, Object[] parameters) ' at ShippersService.Shippers.RetrieveEntityAsObject(Int32 entityId) 'in C:\projects\Scratch\Llblgen\Windows\VB\Scratch.Llblgen.Windows.VB. 'Northwind.Client\Web References\ShippersService\Reference.vb:line 70 ' at Scratch.Llblgen.Windows.VB.Northwind.Client.Form1. 'RetrieveOneAsObjectViaServiceButton_Click(Object sender, EventArgs e) in 'C:\projects\Scratch\Llblgen\Windows\VB\Scratch.Llblgen.Windows.VB.Northwind. 'Client\Form1.vb:line1065 '

What do you think?

Please advise.

Thank you.

--Mark Kamoski

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 11-May-2006 07:08:46   

Would you please try to add an XMLInclude attribute to your Web Method.

Assuming that your web method is called RetrieveEntityAsObject(), and you entity is of type ShippersEntity it should look like the following.

[System.Web.Services.WebMethod]
[System.Xml.Serialization.XmlInclude(typeof(ShippersEntity))]
public Object RetrieveEntityAsObject(Int32 entityId) {}

mkamoski avatar
mkamoski
User
Posts: 116
Joined: 06-Dec-2005
# Posted on: 11-May-2006 20:56:27   

Walaa wrote:

Would you please try to add an XMLInclude attribute to your Web Method.

Assuming that your web method is called RetrieveEntityAsObject(), and you entity is of type ShippersEntity it should look like the following.

[System.Web.Services.WebMethod]
[System.Xml.Serialization.XmlInclude(typeof(ShippersEntity))]
public Object RetrieveEntityAsObject(Int32 entityId) {}

Ah, you had me excited there, but, I tried your idea and it did not work for me.

Adding the attribute is OK and the web service compiles just fine.

However, in the project that consumes the web service, when I try to run the "Update Web Reference" command, it fails and I get the following...

There was an error downloading 'httpdisappointed /localhost/Scratch-Llblgen-Windows-VB-Northwind-ServiceInterface/Shippers.asmx?WSDL'.

The request failed with the error message:

Type Scratch.Llblgen.Windows.VB.Northwind.EntityClasses.ShippersEntity is derived from System.Xml.Serialization.IXmlSerializable and therefore cannot be used with attribute XmlInclude.

(That is funny how the : / translates to a smiley in the quote above.)

Anyway, that's the picture.

Do you have any other ideas?

Please advise.

Thank you.

--Mark Kamoski

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 12-May-2006 08:30:24   

Do you have any other ideas?

Unfortunatly no, that was the only thing I can think of.