473,385 Members | 1,325 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,385 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 5509
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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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...

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.