473,406 Members | 2,371 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,406 software developers and data experts.

Passing interface as parameter in web service???

hi all

is there a way to pass an interface as input parameter for a web method?
since interface is not serializable, does that mean it's impossible to do
that?

Kevin

Nov 23 '05 #1
6 5510
Kevin Yu wrote:
hi all

is there a way to pass an interface as input parameter for a web method?
since interface is not serializable, does that mean it's impossible to do
that?

Kevin


In the sense that WSDL defines an interface, and that a web method can
be designed to use that interface on the fly ( I know because I've built
such a thing )...yes.
Nov 23 '05 #2
Kevin Yu wrote:
hi all

is there a way to pass an interface as input parameter for a web method?
since interface is not serializable, does that mean it's impossible to do
that?

Kevin


In the sense that WSDL defines an interface, and that a web method can
be designed to use that interface on the fly ( I know because I've built
such a thing )...yes.
Nov 23 '05 #3
How?

please show some code sample.

Kevin

<ja*****@texeme.com> wrote in message
news:F9********************@speakeasy.net...
Kevin Yu wrote:
hi all

is there a way to pass an interface as input parameter for a web method?
since interface is not serializable, does that mean it's impossible to do that?

Kevin


In the sense that WSDL defines an interface, and that a web method can
be designed to use that interface on the fly ( I know because I've built
such a thing )...yes.

Nov 23 '05 #4
How?

please show some code sample.

Kevin

<ja*****@texeme.com> wrote in message
news:F9********************@speakeasy.net...
Kevin Yu wrote:
hi all

is there a way to pass an interface as input parameter for a web method?
since interface is not serializable, does that mean it's impossible to do that?

Kevin


In the sense that WSDL defines an interface, and that a web method can
be designed to use that interface on the fly ( I know because I've built
such a thing )...yes.

Nov 23 '05 #5
Kevin Yu wrote:
How?

please show some code sample.
This code will generate the web services interface from a WSDL
dynamically. This code requires the ThinkTecture 1.5 libraries (
available free at thinktecture.com ).
public static void WInvoke(
string WDSL,
string TypeName,
string Method,
ArrayList MethodParameters

)
{
string result = string.Empty;
DynamicWebServiceProxy ws = new DynamicWebServiceProxy();
ws.Wsdl = WDSL;
//"http://localhost/EHLO/Service1.asmx?WSDL";
ws.TypeName = TypeName;
ws.MethodName = Method;

Type[] types = ws.ProxyAssembly.GetTypes();
int mko = 0;

MethodInfo[] mi = types[0].GetMethods(BindingFlags.Public |
BindingFlags.Instance |
BindingFlags.DeclaredOnly);

ParameterInfo[] pt = null;

foreach ( MethodInfo m in mi)
if(m.Name.Equals(Method))
pt = m.GetParameters();

foreach(object o in MethodParameters){
object mo;

if (!pt[mko++].ParameterType.ToString().Equals("System.Int32"))
mo = ((methodParams)o).paramvalue.ToString();
else
mo = Convert.ToInt32(((methodParams)o).paramvalue.ToStr ing());

//Debug.WriteLine(types[tko++].ToString());
ws.AddParameter(mo);
}

// get all types of the dynamic assembly
//Type[] types = ws.ProxyAssembly.GetTypes();
// get a certain type by name - watch out for fully qualified name
//Type t = ws.ProxyAssembly.GetType(ns + "Order");
//...

//Then create an instance of the type by using reflection.

//object result = Activator.CreateInstance(t);

try
{

ws.InvokeCall();

}
catch ( Exception e)
{
Debug.WriteLine(e.ToString());
}
finally
{
//Debug.WriteLine(result);
}
}

public static void WInvoke(
string WDSL,
string TypeName,
string Method,
ArrayList MethodParameters

)
{
string result = string.Empty;
DynamicWebServiceProxy ws = new DynamicWebServiceProxy();
ws.Wsdl = WDSL;
//"http://localhost/EHLO/Service1.asmx?WSDL";
ws.TypeName = TypeName;
ws.MethodName = Method;

Type[] types = ws.ProxyAssembly.GetTypes();
int mko = 0;

MethodInfo[] mi = types[0].GetMethods(BindingFlags.Public |
BindingFlags.Instance |
BindingFlags.DeclaredOnly);

ParameterInfo[] pt = null;

foreach ( MethodInfo m in mi)
if(m.Name.Equals(Method))
pt = m.GetParameters();

foreach(object o in MethodParameters){
object mo;

if (!pt[mko++].ParameterType.ToString().Equals("System.Int32"))
mo = ((methodParams)o).paramvalue.ToString();
else
mo = Convert.ToInt32(((methodParams)o).paramvalue.ToStr ing());

//Debug.WriteLine(types[tko++].ToString());
ws.AddParameter(mo);
}

// get all types of the dynamic assembly
//Type[] types = ws.ProxyAssembly.GetTypes();
// get a certain type by name - watch out for fully qualified name
//Type t = ws.ProxyAssembly.GetType(ns + "Order");
//...

//Then create an instance of the type by using reflection.

//object result = Activator.CreateInstance(t);

try
{

ws.InvokeCall();

}
catch ( Exception e)
{
Debug.WriteLine(e.ToString());
}
finally
{
//Debug.WriteLine(result);
}
}


Kevin

<ja*****@texeme.com> wrote in message
news:F9********************@speakeasy.net...
Kevin Yu wrote:
hi all

is there a way to pass an interface as input parameter for a web method?
since interface is not serializable, does that mean it's impossible to
do
that?

Kevin


In the sense that WSDL defines an interface, and that a web method can
be designed to use that interface on the fly ( I know because I've built
such a thing )...yes.


Nov 23 '05 #6
Kevin Yu wrote:
How?

please show some code sample.
This code will generate the web services interface from a WSDL
dynamically. This code requires the ThinkTecture 1.5 libraries (
available free at thinktecture.com ).
public static void WInvoke(
string WDSL,
string TypeName,
string Method,
ArrayList MethodParameters

)
{
string result = string.Empty;
DynamicWebServiceProxy ws = new DynamicWebServiceProxy();
ws.Wsdl = WDSL;
//"http://localhost/EHLO/Service1.asmx?WSDL";
ws.TypeName = TypeName;
ws.MethodName = Method;

Type[] types = ws.ProxyAssembly.GetTypes();
int mko = 0;

MethodInfo[] mi = types[0].GetMethods(BindingFlags.Public |
BindingFlags.Instance |
BindingFlags.DeclaredOnly);

ParameterInfo[] pt = null;

foreach ( MethodInfo m in mi)
if(m.Name.Equals(Method))
pt = m.GetParameters();

foreach(object o in MethodParameters){
object mo;

if (!pt[mko++].ParameterType.ToString().Equals("System.Int32"))
mo = ((methodParams)o).paramvalue.ToString();
else
mo = Convert.ToInt32(((methodParams)o).paramvalue.ToStr ing());

//Debug.WriteLine(types[tko++].ToString());
ws.AddParameter(mo);
}

// get all types of the dynamic assembly
//Type[] types = ws.ProxyAssembly.GetTypes();
// get a certain type by name - watch out for fully qualified name
//Type t = ws.ProxyAssembly.GetType(ns + "Order");
//...

//Then create an instance of the type by using reflection.

//object result = Activator.CreateInstance(t);

try
{

ws.InvokeCall();

}
catch ( Exception e)
{
Debug.WriteLine(e.ToString());
}
finally
{
//Debug.WriteLine(result);
}
}

public static void WInvoke(
string WDSL,
string TypeName,
string Method,
ArrayList MethodParameters

)
{
string result = string.Empty;
DynamicWebServiceProxy ws = new DynamicWebServiceProxy();
ws.Wsdl = WDSL;
//"http://localhost/EHLO/Service1.asmx?WSDL";
ws.TypeName = TypeName;
ws.MethodName = Method;

Type[] types = ws.ProxyAssembly.GetTypes();
int mko = 0;

MethodInfo[] mi = types[0].GetMethods(BindingFlags.Public |
BindingFlags.Instance |
BindingFlags.DeclaredOnly);

ParameterInfo[] pt = null;

foreach ( MethodInfo m in mi)
if(m.Name.Equals(Method))
pt = m.GetParameters();

foreach(object o in MethodParameters){
object mo;

if (!pt[mko++].ParameterType.ToString().Equals("System.Int32"))
mo = ((methodParams)o).paramvalue.ToString();
else
mo = Convert.ToInt32(((methodParams)o).paramvalue.ToStr ing());

//Debug.WriteLine(types[tko++].ToString());
ws.AddParameter(mo);
}

// get all types of the dynamic assembly
//Type[] types = ws.ProxyAssembly.GetTypes();
// get a certain type by name - watch out for fully qualified name
//Type t = ws.ProxyAssembly.GetType(ns + "Order");
//...

//Then create an instance of the type by using reflection.

//object result = Activator.CreateInstance(t);

try
{

ws.InvokeCall();

}
catch ( Exception e)
{
Debug.WriteLine(e.ToString());
}
finally
{
//Debug.WriteLine(result);
}
}


Kevin

<ja*****@texeme.com> wrote in message
news:F9********************@speakeasy.net...
Kevin Yu wrote:
hi all

is there a way to pass an interface as input parameter for a web method?
since interface is not serializable, does that mean it's impossible to
do
that?

Kevin


In the sense that WSDL defines an interface, and that a web method can
be designed to use that interface on the fly ( I know because I've built
such a thing )...yes.


Nov 23 '05 #7

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

Similar topics

6
by: wiredless | last post by:
What is the advantage of passing an interface type? according to UML (visio) when i reverse engineer existing code to a UML diagram I get the error "UMLE00046: sample : - An interface cannot...
8
by: Dennis Myrén | last post by:
I have these tiny classes, implementing an interface through which their method Render ( CosWriter writer ) ; is called. Given a specific context, there are potentially a lot of such objects,...
0
by: Kevin Yu | last post by:
hi all is there a way to pass an interface as input parameter for a web method? since interface is not serializable, does that mean it's impossible to do that? Kevin
12
by: scottt | last post by:
hi, I am having a little problem passing in reference of my calling class (in my ..exe)into a DLL. Both programs are C# and what I am trying to do is pass a reference to my one class into a DLL...
9
by: Greger | last post by:
Hi, I am building an architecture that passes my custom objects to and from webservices. (Our internal architecture requires me to use webservices to any suggestion to use other remoting...
10
by: amazon | last post by:
Our vender provided us a web service: 1xyztest.xsd file... ------------------------------------ postEvent PostEventRequest ------------------------------------- authetication authentication...
0
by: amazon | last post by:
I have web service that acceping following parameters.. postev.PostEvent(authentication as ws.authentication, name as string,id as string, exdate as date, parameter() as ws.nameparametervaluepair...
10
by: Janus | last post by:
Hi, Is there a way to pass arguments to the callback function used inside an addEventListener? I see that I can only list the name of the callback function. For eg, I use this: var...
3
by: cmrhema | last post by:
Hi, Kindly excuse if I am posting in the wrong place. I am using Visual Studio 2008, .net framework 3.5, asp.net , c# and sql server 2005. I am supposed to pass stored procedures from client...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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...

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.