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 / October 2005

Tip: Looking for answers? Try searching our database.

Customer Entity from Web Service

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lumina - 20 Oct 2005 19:14 GMT
I have a class "product" in a Web Project with the ensamblie.
In otherside I Have a Web Service and I want to return an product class
object,
but when I want to received this object in the Web Application I have an
error saying "can't not convert product in product".

Someone can help me.
S.M. Altaf [MVP] - 21 Oct 2005 21:50 GMT
Hi Lumina,

Does the web service have a reference to the class library containing the definitions for the Product Class?  

-Altaf[MVP]

--------------------------------------------------------------------------------
All that glitters has a high refractive index.
www.mendhak.com
 I have a class "product" in a Web Project with the ensamblie.
 In otherside I Have a Web Service and I want to return an product class
 object,
 but when I want to received this object in the Web Application I have an
 error saying "can't not convert product in product".

 Someone can help me.
Lumina - 23 Oct 2005 01:15 GMT
Yes, the Web Application  and the Web Service have the same refernce to the
product class.

Product class have the <serialization> tag.

> Hi Lumina,
>
[quoted text clipped - 12 lines]
>
>   Someone can help me
Lumina - 23 Oct 2005 02:04 GMT
More datails.....

"No se puede convertir un valor de tipo '1-matriz dimensional
de Service.ProductoWSR.producto' en '1-matriz dimensional
de Common.producto' debido a que 'Service.ProductoWSR.producto'
no se deriva de 'Common.producto'."

code in Web Services
<WebMethod()> Public Function GetByCatId(ByVal nCt_id As Integer) As
Common.producto()

Code in Web page

Dim oWeb As New ProductoWSR.ProductoWS
Dim Productos As producto() = oWeb.GetByCatId(nCt_id)

> Hi Lumina,
>
[quoted text clipped - 12 lines]
>
>   Someone can help me
Marvin Smit - 24 Oct 2005 14:11 GMT
Hi,

I think the issue you are experiencing is the following;

You have a duplkicate definition of the data classes.
- 1 definition is comming from the original assembly (the one used by
your WebSerivice server)
- 1 definition is comming from the Proxy generated for the client
based on the WSDL.

You should remove the reference 'to the assembly with dataclasses'
from the client. The generated webservice proxy class already contains
the proxy classes for the data types too.

Hope this helps,

Marvin Smit.

>More datails.....
>
[quoted text clipped - 28 lines]
>>
>>   Someone can help me
Lumina - 25 Oct 2005 02:49 GMT
Thank You Marvin. I am progresing but i do not complete the task.

I Have:

Web service :
<WebMethod()> Public Function GetByCatId(ByVal nCt_id As Integer) As
producto()
....
....
       Return productos.ToArray(GetType(producto))
End Function

ServiciosProductos Class :

Public Class ServicioProductos

   Public Shared Function GetProductosPorCatWS(ByVal nCt_id As Integer) As
ProductoWSR.producto()
       Dim oWeb As New ProductoWSR.ProductoWS
       Dim Productos As ProductoWSR.producto() = oWeb.GetByCatId(nCt_id)
       oWeb.Dispose()
       oWeb = Nothing

       '*1
       Return Productos
   End Function
End Class

Note: ProductoWSR = Producto Web Service reference

In the *1, the code works perfectly. Now.. this function is used from the
web page  :

....
....

       Me.Lista.DataSource =
Service.ServicioProductos.GetProductosPorCatWS(nCt_id)

       Me.Lista.DataBind()

In the Databind see this error:

DataBinder.Eval: 'Service.ProductoWSR.producto' no contiene una propiedad
con el nombre 'nombre'

But in the point '*1' i see the property 'nombre'.
I Inspect 'Me.Lista.DataSource' and see perfectly the property 'nombre'..
but in the databing.. crash.

Thank You.

> Hi,
>
[quoted text clipped - 46 lines]
> >>
> >>   Someone can help me
Marvin Smit - 25 Oct 2005 17:19 GMT
Hi,

I'm glad we got the duplicate definition out of the code. I'm  sorry
to say, but i must yield to someone else now. I have little experience
in using the databinding functionality.

The little info i can provide would be;

- I'm sure the de-serialization is correct because you show that souce
(with the *1) does return exactly what you expected.

But i'm sure an databinding expert on this list will be able to help
you further with this problem.

one last thing that jumped into my mind was that you might have
special characters in the naming (Italian, Spanish?)

Marvin Smit.

>Thank You Marvin. I am progresing but i do not complete the task.
>
>I Have:
>
>Web service :
> <WebMethod()> Public Function GetByCatId(ByV
b
l nCt_id As Integer) As
>producto()
>....
[quoted text clipped - 92 lines]
>> >>
>> >>   Someone can help me
RYoung - 30 Oct 2005 23:20 GMT
>        Me.Lista.DataSource =
> Service.ServicioProductos.GetProductosPorCatWS(nCt_id)
[quoted text clipped - 5 lines]
> DataBinder.Eval: 'Service.ProductoWSR.producto' no contiene una propiedad
> con el nombre 'nombre'

If I'm not mistaken, in order for an object to act as a DataSource for a
control, it needs to have property accessors. The generated code for the web
service, the Product class, only generates public field accessors, therefore
cannot be databound

Your Product class may look like this:

[Serializable]
public class Product
{
   private int productId;
   public int ProductId{ get{ return productId; } set{ productId =
value; }}
}

The proxy generated class will look like this:

public class Product
{
   public int ProductId
}

So, on the client side you'll need to do some transformation to map the
proxy Product class to a domain Product class so that you can databind.
Alternatively, I believe the XsdObjectGen utility will generate proxy
classes with property accessors. Google for XsdObjectGen.

Ron

Rate this thread:







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.