473,387 Members | 1,673 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Sending business objects over a webservice

Hi,

I'm trying to create a system whereby my desktop application submits
it's order to an online server using a webservice (pretty standard!).

So, I added a new project to my solution to develop the webservice in
and created a basic webservice which just returns my "Order" object as a
string.

I then added some code to my app to call my webservice and pass it an
Order object.

However I get an error when I try and compile because it thinks the
Order object that the webservice proxy accepts is a different type to
the one the I'm sending.

eg:
Order order = new Order();
WrightWebService.OrderWebService webService
= new WrightWebService.OrderWebService();
webService.EchoOrder(order); //line 88

I get the following compilation errors:

checkout.aspx.cs(88,4): error CS1502: The best overloaded method match
for
'CDWebsite.WrightWebService.OrderWebService.EchoOr der(CDWebsite.WrightWebService.Order)'
has some invalid arguments

checkout.aspx.cs(88,25): error CS1503: Argument '1': cannot convert from
'Wright.BusinessLogicLayer.Order' to 'CDWebsite.WrightWebService.Order'

Why does it think they're different types? In both cases I've referenced
the same Order class in the Wright.BusinessLogicLayer namespace.

How can I fix this problem?

Thanks,

Nick...
Nov 23 '05 #1
9 2649
It thinks they are different classes becasue they are different
classes. The WSDL does not contain information about the
implementation of an object. It just carries the public members
(properties and fields). So when you generate a web service proxy from
the WSDL. It utilizes the WSDl to create a new Order class with just
the public properties and fields. You can fins this generated class
under the web references, the file I beleive is called reference.cs.
So to resolve this issue you can modify the reference.cs file, and
replace the references to the web service proxy generated order class
with your implementation in the web service method calls. This has
typically worked for me in the past. But be forwarned, if you
re-generate the web reference, your changes will get blown away.

Nov 23 '05 #2
Hi Nick,

A possible fix is to make your objects serializable into XML, then use the
XML for the transfer between the web service and client. I'm not sure about
performance in this scenario (may be better, may be worse) but it should
alleviate your problems as you then either only pass an XMLDocument or if you
wish a string.

The other side of the coin is that the XML that is passed in could be the
wrong object or completely foreign so you would have to do some schema
validation etc. before de-serializing your objects. It also puts constraints
on your object design as only public properties are serialized (I think...).

Some research on Serialization should give you a better idea but I thought
I'd throw it in as something to think about...

:)

"Nick Gilbert" wrote:
Hi,

I'm trying to create a system whereby my desktop application submits
it's order to an online server using a webservice (pretty standard!).

So, I added a new project to my solution to develop the webservice in
and created a basic webservice which just returns my "Order" object as a
string.

I then added some code to my app to call my webservice and pass it an
Order object.

However I get an error when I try and compile because it thinks the
Order object that the webservice proxy accepts is a different type to
the one the I'm sending.

eg:
Order order = new Order();
WrightWebService.OrderWebService webService
= new WrightWebService.OrderWebService();
webService.EchoOrder(order); //line 88

I get the following compilation errors:

checkout.aspx.cs(88,4): error CS1502: The best overloaded method match
for
'CDWebsite.WrightWebService.OrderWebService.EchoOr der(CDWebsite.WrightWebService.Order)'
has some invalid arguments

checkout.aspx.cs(88,25): error CS1503: Argument '1': cannot convert from
'Wright.BusinessLogicLayer.Order' to 'CDWebsite.WrightWebService.Order'

Why does it think they're different types? In both cases I've referenced
the same Order class in the Wright.BusinessLogicLayer namespace.

How can I fix this problem?

Thanks,

Nick...

Nov 23 '05 #3
Hi Nick,

A possible fix is to make your objects serializable into XML, then use the
XML for the transfer between the web service and client. I'm not sure about
performance in this scenario (may be better, may be worse) but it should
alleviate your problems as you then either only pass an XMLDocument or if you
wish a string.

The other side of the coin is that the XML that is passed in could be the
wrong object or completely foreign so you would have to do some schema
validation etc. before de-serializing your objects. It also puts constraints
on your object design as only public properties are serialized (I think...).

Some research on Serialization should give you a better idea but I thought
I'd throw it in as something to think about...

:)

"Nick Gilbert" wrote:
Hi,

I'm trying to create a system whereby my desktop application submits
it's order to an online server using a webservice (pretty standard!).

So, I added a new project to my solution to develop the webservice in
and created a basic webservice which just returns my "Order" object as a
string.

I then added some code to my app to call my webservice and pass it an
Order object.

However I get an error when I try and compile because it thinks the
Order object that the webservice proxy accepts is a different type to
the one the I'm sending.

eg:
Order order = new Order();
WrightWebService.OrderWebService webService
= new WrightWebService.OrderWebService();
webService.EchoOrder(order); //line 88

I get the following compilation errors:

checkout.aspx.cs(88,4): error CS1502: The best overloaded method match
for
'CDWebsite.WrightWebService.OrderWebService.EchoOr der(CDWebsite.WrightWebService.Order)'
has some invalid arguments

checkout.aspx.cs(88,25): error CS1503: Argument '1': cannot convert from
'Wright.BusinessLogicLayer.Order' to 'CDWebsite.WrightWebService.Order'

Why does it think they're different types? In both cases I've referenced
the same Order class in the Wright.BusinessLogicLayer namespace.

How can I fix this problem?

Thanks,

Nick...

Nov 23 '05 #4
Looks like the usual namespace gripe.

What namespace is your Order type in?
Do you have a WrigtWebService.Order type available? If yes, cast your
"order" to this and retry.

Regards,

Sigmund Jakhel

"Nick Gilbert" <ne**@nickgilbert.com> wrote in message
news:eo**************@TK2MSFTNGP15.phx.gbl...
Hi,

I'm trying to create a system whereby my desktop application submits
it's order to an online server using a webservice (pretty standard!).

So, I added a new project to my solution to develop the webservice in
and created a basic webservice which just returns my "Order" object as a
string.

I then added some code to my app to call my webservice and pass it an
Order object.

However I get an error when I try and compile because it thinks the
Order object that the webservice proxy accepts is a different type to
the one the I'm sending.

eg:
Order order = new Order();
WrightWebService.OrderWebService webService
= new WrightWebService.OrderWebService();
webService.EchoOrder(order); //line 88

I get the following compilation errors:

checkout.aspx.cs(88,4): error CS1502: The best overloaded method match
for
'CDWebsite.WrightWebService.OrderWebService.EchoOr der(CDWebsite.WrightWebService.Order)'
has some invalid arguments

checkout.aspx.cs(88,25): error CS1503: Argument '1': cannot convert from
'Wright.BusinessLogicLayer.Order' to 'CDWebsite.WrightWebService.Order'

Why does it think they're different types? In both cases I've referenced
the same Order class in the Wright.BusinessLogicLayer namespace.

How can I fix this problem?

Thanks,

Nick...

Nov 23 '05 #5
Looks like the usual namespace gripe.

What namespace is your Order type in?
Do you have a WrigtWebService.Order type available? If yes, cast your
"order" to this and retry.

Regards,

Sigmund Jakhel

"Nick Gilbert" <ne**@nickgilbert.com> wrote in message
news:eo**************@TK2MSFTNGP15.phx.gbl...
Hi,

I'm trying to create a system whereby my desktop application submits
it's order to an online server using a webservice (pretty standard!).

So, I added a new project to my solution to develop the webservice in
and created a basic webservice which just returns my "Order" object as a
string.

I then added some code to my app to call my webservice and pass it an
Order object.

However I get an error when I try and compile because it thinks the
Order object that the webservice proxy accepts is a different type to
the one the I'm sending.

eg:
Order order = new Order();
WrightWebService.OrderWebService webService
= new WrightWebService.OrderWebService();
webService.EchoOrder(order); //line 88

I get the following compilation errors:

checkout.aspx.cs(88,4): error CS1502: The best overloaded method match
for
'CDWebsite.WrightWebService.OrderWebService.EchoOr der(CDWebsite.WrightWebService.Order)'
has some invalid arguments

checkout.aspx.cs(88,25): error CS1503: Argument '1': cannot convert from
'Wright.BusinessLogicLayer.Order' to 'CDWebsite.WrightWebService.Order'

Why does it think they're different types? In both cases I've referenced
the same Order class in the Wright.BusinessLogicLayer namespace.

How can I fix this problem?

Thanks,

Nick...

Nov 23 '05 #6
try this

Prueba.localhost.Service1 ws = new Prueba.localhost.Service1();
MyClass1 mc = ws.GetMyClass1();

should be -

Prueba.localhost.Service1 ws = new Prueba.localhost.Service1();
Prueba.localhost.MyClass1 mc = ws.GetMyClass1();

After adding reference the web service, the return type of ws.GetMyClass1()
is Prueba.localhost.MyClass1. It is not ClassLibrary1.MyClass1. Yes, we
know that the two classes are the same. However, for the compiler, it has
no knowledge of it. What it knows is that these two classes have the same
name but belong to different namespaces. So it feels that they are
different classes.


"Ziga Jakhel" wrote:
Looks like the usual namespace gripe.

What namespace is your Order type in?
Do you have a WrigtWebService.Order type available? If yes, cast your
"order" to this and retry.

Regards,

Sigmund Jakhel

"Nick Gilbert" <ne**@nickgilbert.com> wrote in message
news:eo**************@TK2MSFTNGP15.phx.gbl...
Hi,

I'm trying to create a system whereby my desktop application submits
it's order to an online server using a webservice (pretty standard!).

So, I added a new project to my solution to develop the webservice in
and created a basic webservice which just returns my "Order" object as a
string.

I then added some code to my app to call my webservice and pass it an
Order object.

However I get an error when I try and compile because it thinks the
Order object that the webservice proxy accepts is a different type to
the one the I'm sending.

eg:
Order order = new Order();
WrightWebService.OrderWebService webService
= new WrightWebService.OrderWebService();
webService.EchoOrder(order); //line 88

I get the following compilation errors:

checkout.aspx.cs(88,4): error CS1502: The best overloaded method match
for
'CDWebsite.WrightWebService.OrderWebService.EchoOr der(CDWebsite.WrightWebService.Order)'
has some invalid arguments

checkout.aspx.cs(88,25): error CS1503: Argument '1': cannot convert from
'Wright.BusinessLogicLayer.Order' to 'CDWebsite.WrightWebService.Order'

Why does it think they're different types? In both cases I've referenced
the same Order class in the Wright.BusinessLogicLayer namespace.

How can I fix this problem?

Thanks,

Nick...


Nov 23 '05 #7
try this

Prueba.localhost.Service1 ws = new Prueba.localhost.Service1();
MyClass1 mc = ws.GetMyClass1();

should be -

Prueba.localhost.Service1 ws = new Prueba.localhost.Service1();
Prueba.localhost.MyClass1 mc = ws.GetMyClass1();

After adding reference the web service, the return type of ws.GetMyClass1()
is Prueba.localhost.MyClass1. It is not ClassLibrary1.MyClass1. Yes, we
know that the two classes are the same. However, for the compiler, it has
no knowledge of it. What it knows is that these two classes have the same
name but belong to different namespaces. So it feels that they are
different classes.


"Ziga Jakhel" wrote:
Looks like the usual namespace gripe.

What namespace is your Order type in?
Do you have a WrigtWebService.Order type available? If yes, cast your
"order" to this and retry.

Regards,

Sigmund Jakhel

"Nick Gilbert" <ne**@nickgilbert.com> wrote in message
news:eo**************@TK2MSFTNGP15.phx.gbl...
Hi,

I'm trying to create a system whereby my desktop application submits
it's order to an online server using a webservice (pretty standard!).

So, I added a new project to my solution to develop the webservice in
and created a basic webservice which just returns my "Order" object as a
string.

I then added some code to my app to call my webservice and pass it an
Order object.

However I get an error when I try and compile because it thinks the
Order object that the webservice proxy accepts is a different type to
the one the I'm sending.

eg:
Order order = new Order();
WrightWebService.OrderWebService webService
= new WrightWebService.OrderWebService();
webService.EchoOrder(order); //line 88

I get the following compilation errors:

checkout.aspx.cs(88,4): error CS1502: The best overloaded method match
for
'CDWebsite.WrightWebService.OrderWebService.EchoOr der(CDWebsite.WrightWebService.Order)'
has some invalid arguments

checkout.aspx.cs(88,25): error CS1503: Argument '1': cannot convert from
'Wright.BusinessLogicLayer.Order' to 'CDWebsite.WrightWebService.Order'

Why does it think they're different types? In both cases I've referenced
the same Order class in the Wright.BusinessLogicLayer namespace.

How can I fix this problem?

Thanks,

Nick...


Nov 23 '05 #8
This is a real pain in VS. I hope they fix it in VS 2005 'cos all these
workarounds are a bodge.
Nov 23 '05 #9
This is a real pain in VS. I hope they fix it in VS 2005 'cos all these
workarounds are a bodge.
Nov 23 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Brian Kiser | last post by:
What is Microsoft's stance on developing business objects vs datasets when creating n-tier apps. Is anyone doing business objects? It appears that most articles from MS recommend passing...
2
by: Tim Smith | last post by:
Hi, With our architecture we are looking at the following client applications: - 20-40 GUI desktop power users - 40-100 ASP.NET light users - 5-10 heavy server side integration apps We...
4
by: Nick Gilbert | last post by:
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...
1
by: Nick Gilbert | last post by:
Hi, I'm trying to create a system whereby my desktop application submits it's order to an online server using a webservice (pretty standard!). So, I added a new project to my solution to...
1
by: hazz | last post by:
if I think about efficiently sending data back and forth through a webservice for a 'typical' application (in this case smart client using Composite UI application block) what questions do I ask...
2
by: Water Cooler v2 | last post by:
I create a test Web service like so: public class ServiceThingy: System.Web.Services.WebService { public int ReturnFour() { return 4; }
2
by: steve | last post by:
Hi All I need to learn how to update a SQl server or Access database located on a web server from my windows forms application, via the internet I have a customer who wants to run several...
3
by: Rotsey | last post by:
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...
12
by: BillE | last post by:
I'm trying to decide if it is better to use typed datasets or business objects, so I would appreciate any thoughts from someone with more experience. When I use a business object to populate a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.