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 / April 2007

Tip: Looking for answers? Try searching our database.

How to expose a class in the Webservice.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mani - 12 Apr 2007 16:20 GMT
Hi,

I have a webservice which uses a c# Dll,This Dll is a C# class library which
contain few class[Class One, Class Two] .
I am able to see the class when in the Web service but when i create a stubb
class of the webservice using wsdl.exe then these classes are not
exposed.Both the class are public.
I tried for a while and found that if I use these class(one and two) as the
parameter in the WebMethods the web service and generate the Stubb class then
these class are exposed.
For ex::

[WebMethod(EnableSession = true)]
public string GetClass(One one)
{
     return ;
}
//Method1

This is one way but is there any other way of exposing the class without
exposing in the WebMethod?

Regards,
Mani.
John Saunders [MVP] - 12 Apr 2007 16:35 GMT
> Hi,
>
[quoted text clipped - 21 lines]
> This is one way but is there any other way of exposing the class without
> exposing in the WebMethod?

What do you want to do with the class on the client if you don't want to
send it to the web service or receive it from the web service?

A web service isn't a class library. It is a way to perform particular
operations on particular kinds of data, expressed in XML and described in
XML.

Also, please be aware that even if your client referred to the same C# DLL
as the Web Service does, the two would not be able to communicate directly
using classes in the C# DLL.  The client and server are very strongly
separated in the case of Web Services, and they only communicate via XML,
XML Schema and WSDL. One thing they cannot communicate is the identity of
classes. Therefore, class "ClassLibrary.Class1" on the client and class
"ClassLibrary.Class1" on the server, are two totally different and unrelated
classes.

I hope that's not too discouraging. Please provide more detail of what
you're trying to accomplish, and maybe we'll be of more help.
Signature


John Saunders [MVP]

Mani - 13 Apr 2007 04:56 GMT
> > Hi,
> >
[quoted text clipped - 40 lines]
> I hope that's not too discouraging. Please provide more detail of what
> you're trying to accomplish, and maybe we'll be of more help.

The reson behind why i want to expose the classes with out using in the
Web-Method is ,there are few classes which perform some calucalation and
operation(For Ex:: Class Calculate)  and it is been used in the class One and
Two and i dont want to add all these classes in the webmethod as the
parameter.
So when i generate a Stubb class using the Wsdl.exe the class Calculate is
not exposed as it is not been passed as parameter in the WebMethod.This is
just one small example of a class , I have few more classes like this which i
want to expose in the web-service client so that i perform few
operations(validating and calculating) before calling the webmethod.
How can i achive this ?.Is there any way through which i can say a
particlular class to be exposed in the Stubbed class(Webservice Class) with
out adding as a parameter in the web-method.

Regards
Mani.
John Saunders [MVP] - 13 Apr 2007 16:53 GMT
>> > Hi,
>> >
[quoted text clipped - 62 lines]
> with
> out adding as a parameter in the web-method.

No, there is no simple way to do this.

If these are just helper classes, then they should be in their own assembly,
which you could distribute to the clients. They could use these classes to
produce the values sent to the web service.
Signature


John Saunders [MVP]

Marc - 19 Apr 2007 21:30 GMT
Hello,

I have a similar situation where I would like to expose some additional
classes and have them passed / returned from a webservice method.  For
example:

class requestType1
class responseType1

class requestType2
class responseType2

requestType1 would have different member fields than requestType2 and
similarly with the responseType1 and responseType2.

I would like to have a webservice method defined as:

public object MethodCall(object request)
{
   object Reponse = null;

   // Based on the type of the request parameter different methods would be
called
   // returning the corresponding responseType for the requestType.
   // ie if request is requestType2 then the result value of the method
called would
   // be responseType2 and assigned to the Response variable and returned.

   return Response;
}

I hope that this all makes sense.

Regards and thanks in advance,
Marc
arjun Arora - 20 Apr 2007 19:54 GMT
I am doing same, any solution so far?? Thanks

> Hello,
>
[quoted text clipped - 31 lines]
> Regards and thanks in advance,
> Marc

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.