Webserices question

P

Picho

Hi all - posted this on the webservices newsgroups but its a bit slow there
so my appologiez in advance.

I have a webservice and a windows app.
both of them reference the same class library called WebServiceTest.Core
that defines a class called Class1.

the webservice exposes a method that looks like this:

[WebMethod]
public WebServiceTest.Core.Class1 GetClass1()
{
return new WebServiceTest.Core.Class1();
}

the windows app has a web reference to the webservice (and a reference to
the class library).
I want (and expected) the web-method to return a
WebServiceTest.Core.Class1 object but instead it returns a
WebServicesTest.Client.localhost.Class1 where:
WebServicesTest.Client is the windows app namespace
localhost is the name of the webreference to the web service
Class1 is some generated class that represents the return type.

my question is simple:

I need the original object. this is why both webservice and windows app
reference the shared assembly...
what can I do?
what am I doing wrong?

thanx,

Picho
 
S

Sahil Malik

Picho,

A little history.

WebServices were intended to cross bridge various platforms in a SOA
fashion. THe idea was, FINALLY we have a .NET thing that can be called from
Java and Vice Versa. Of course it turned out to be that people started
passing xsd:anytype or s:complextype, and started passing custom .NET
objects via webservices which threw that concept in the toilet. So while you
are sending your custom types, the default WSDL will assume that your remote
user rightfully so does not have access to the original class library and it
will try and create a shell of it for you. Which is the localhost.Class1
that you see.

Now to your question - Say you had some validation rules built into that
class and you wish to get an instance of that very class back via this
remote text based invocation over HTTP (WebService), you would have to,

1. Define your types in a shared assembly (You've already done this).
2. Attach a targetNamespace attribute to each type (You've done this)
3. Deploy the resulting assembly to both client and server (this is why it
is called "shared") (You've done this)
4. When you generate the client-side proxy (using wsdl.exe or Add Web
Reference...), you have to modify it to reference the custom type. (That's
what ur missing).

Here's more info.
http://hoppersoft.com/Andy/commentview.aspx?guid=ABAF08B3-1ABD-4DAE-BE05-23B733FF3C5D

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
 
P

Picho

Thanx, this realy helped.

Sahil Malik said:
Picho,

A little history.

WebServices were intended to cross bridge various platforms in a SOA
fashion. THe idea was, FINALLY we have a .NET thing that can be called
from
Java and Vice Versa. Of course it turned out to be that people started
passing xsd:anytype or s:complextype, and started passing custom .NET
objects via webservices which threw that concept in the toilet. So while
you
are sending your custom types, the default WSDL will assume that your
remote
user rightfully so does not have access to the original class library and
it
will try and create a shell of it for you. Which is the localhost.Class1
that you see.

Now to your question - Say you had some validation rules built into that
class and you wish to get an instance of that very class back via this
remote text based invocation over HTTP (WebService), you would have to,

1. Define your types in a shared assembly (You've already done this).
2. Attach a targetNamespace attribute to each type (You've done this)
3. Deploy the resulting assembly to both client and server (this is why it
is called "shared") (You've done this)
4. When you generate the client-side proxy (using wsdl.exe or Add Web
Reference...), you have to modify it to reference the custom type. (That's
what ur missing).

Here's more info.
http://hoppersoft.com/Andy/commentview.aspx?guid=ABAF08B3-1ABD-4DAE-BE05-23B733FF3C5D

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik



Picho said:
Hi all - posted this on the webservices newsgroups but its a bit slow there
so my appologiez in advance.

I have a webservice and a windows app.
both of them reference the same class library called WebServiceTest.Core
that defines a class called Class1.

the webservice exposes a method that looks like this:

[WebMethod]
public WebServiceTest.Core.Class1 GetClass1()
{
return new WebServiceTest.Core.Class1();
}

the windows app has a web reference to the webservice (and a reference
to
the class library).
I want (and expected) the web-method to return a
WebServiceTest.Core.Class1 object but instead it returns a
WebServicesTest.Client.localhost.Class1 where:
WebServicesTest.Client is the windows app namespace
localhost is the name of the webreference to the web service
Class1 is some generated class that represents the return type.

my question is simple:

I need the original object. this is why both webservice and windows app
reference the shared assembly...
what can I do?
what am I doing wrong?

thanx,

Picho
 

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

Top