473,473 Members | 1,917 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to expose a class in the Webservice.

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.
Apr 12 '07 #1
5 9633
Mani" <Ma**@discussions.microsoft.comwrote in message
news:0C**********************************@microsof t.com...
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?
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.
--

John Saunders [MVP]
Apr 12 '07 #2

"John Saunders [MVP]" wrote:
Mani" <Ma**@discussions.microsoft.comwrote in message
news:0C**********************************@microsof t.com...
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?

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.
--

John Saunders [MVP]
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.
Apr 13 '07 #3
"Mani" <Ma**@discussions.microsoft.comwrote in message
news:E9**********************************@microsof t.com...
>
"John Saunders [MVP]" wrote:
>Mani" <Ma**@discussions.microsoft.comwrote in message
news:0C**********************************@microso ft.com...
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?

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.
--

John Saunders [MVP]

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.
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.
--

John Saunders [MVP]
Apr 13 '07 #4
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
Apr 19 '07 #5
I am doing same, any solution so far?? Thanks

"Marc" wrote:
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

Apr 20 '07 #6

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

Similar topics

2
by: Sergi Adamchuk | last post by:
I need determine which web service (class WebService or its inheritors) serveces current request (I need Type instance of class that serves request). For example you wrote your own WebService: ...
11
by: Andy | last post by:
Make the story short, I have a VB.NET client interface calling .NET webservice, written in VB.NET as well. I am trying to make the client as thin as possible so I let the webservice part to...
0
by: Taja | last post by:
Hi, I'm looking for a solution which can expose query's via webservice, with the following approach: 1. Administration part which allows the user to connect to a datasource and define some...
6
by: cipher | last post by:
I have some constant values in my web service that my client application will require. Having to keep server side and client side definitions insync is tedious. I am trying to do something like...
3
by: Miguel Ferreira via .NET 247 | last post by:
Hi ! I have developed a class Library with several classes and methods. Its working fine with a windows forms test application, but now i need to create a webservice that will expose those...
1
by: MisterT | last post by:
Hello, I have a web service that updates an SQL database thru a web service. I would like to expose the database table so I can easily add it as a Data Source in VS 2005 to program the web...
3
by: LT_Hassan | last post by:
This is only a model program, because it would take too long to demonstrate the real solution. Anyway, I have 3 projects - ClassLibrary1, ConsoleApplication1 and WebSite1 (which hosts webservice)....
1
by: Jon Ebersole | last post by:
I am developing a webservice and a windows application that talk to each other. They are using a standard VB class library in the background. I am having problems understanding why I can't sync my...
8
by: cj | last post by:
I've seen examples of web services written with <%@ WebService Language ="Vb" Class=".... at the top. Is it not used in VB 2008?
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,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.