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.EchoOrder(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...
Keenan Newton - 24 May 2005 20:58 GMT
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.
Steve - 26 May 2005 01:14 GMT
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...
:)
> Hi,
>
[quoted text clipped - 36 lines]
>
> Nick...
Ziga Jakhel - 31 May 2005 10:26 GMT
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
> Hi,
>
[quoted text clipped - 36 lines]
>
> Nick...
jose - 26 Jun 2005 21:07 GMT
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.
> Looks like the usual namespace gripe.
>
[quoted text clipped - 46 lines]
> >
> > Nick...
Pete Hearn - 02 Jul 2005 12:09 GMT
This is a real pain in VS. I hope they fix it in VS 2005 'cos all these
workarounds are a bodge.