[Howto] passing non-primitive data ?

B

Bsiang Tan

Dear all experts,


I am trying to passing non-primitive data like TimeSpan, Point and etc
from my web application to my web service.
And I found it can't let me pass. Am I miss something there ?

For example, I have a web method call
[WebMethod]
public System.Drawing.Point GetPoint()
{
return new Point(2, 2);
}


and in my Web Application code :

Point point = Service.GetPoint();

It give me an error that : Cannot implicitly convert type 'Service.Point'
to 'System.Drawing.Point'

I met the same problem when I try pass TimeSpan data from my Web App to my
Web Service.

Can anyone teach me how to make it ?

Thank for your helpful hands.


Best regard,
Bsiang.
 
J

Jan Tielens

When you add a web reference from your client project to your web service,
there are proxy classes generated for each type your web service exposes. So
the GetPoint method doesn't return an object of the "real" Point class, but
it returns an object of the proxy class for the point class. So you can't
cast from proxy to the Point class.

What you could do is convert the proxy instance to an instance of the real
Point class:

Services.Point point = Service.GetPoint();
Point realPoint = new Point(point.X, point.Y, ...);

--
Greetz

Jan Tielens
________________________________
Read my weblog: http://weblogs.asp.net/jan
 

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,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top