Passing interface as parameter in web service???

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kevin Yu

    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



  • jabailo@texeme.com

    #2
    Re: Passing interface as parameter in web service???

    Kevin Yu wrote:[color=blue]
    > 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
    >
    >
    >[/color]

    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.

    Comment

    • jabailo@texeme.com

      #3
      Re: Passing interface as parameter in web service???

      Kevin Yu wrote:[color=blue]
      > 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
      >
      >
      >[/color]

      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.

      Comment

      • Kevin Yu

        #4
        Re: Passing interface as parameter in web service???

        How?

        please show some code sample.

        Kevin

        <jabailo@texeme .com> wrote in message
        news:F9SdnS52r4 n2p1HfRVn-ig@speakeasy.ne t...[color=blue]
        > Kevin Yu wrote:[color=green]
        > > 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[/color][/color]
        do[color=blue][color=green]
        > > that?
        > >
        > > Kevin
        > >
        > >
        > >[/color]
        >
        > 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.[/color]


        Comment

        • Kevin Yu

          #5
          Re: Passing interface as parameter in web service???

          How?

          please show some code sample.

          Kevin

          <jabailo@texeme .com> wrote in message
          news:F9SdnS52r4 n2p1HfRVn-ig@speakeasy.ne t...[color=blue]
          > Kevin Yu wrote:[color=green]
          > > 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[/color][/color]
          do[color=blue][color=green]
          > > that?
          > >
          > > Kevin
          > >
          > >
          > >[/color]
          >
          > 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.[/color]


          Comment

          • jabailo@texeme.com

            #6
            Re: Passing interface as parameter in web service???

            Kevin Yu wrote:[color=blue]
            > How?
            >
            > please show some code sample.[/color]

            This code will generate the web services interface from a WSDL
            dynamically. This code requires the ThinkTecture 1.5 libraries (
            available free at thinktecture.co m ).


            public static void WInvoke(
            string WDSL,
            string TypeName,
            string Method,
            ArrayList MethodParameter s

            )
            {
            string result = string.Empty;
            DynamicWebServi ceProxy ws = new DynamicWebServi ceProxy();


            ws.Wsdl = WDSL;
            //"http://localhost/EHLO/Service1.asmx?W SDL";
            ws.TypeName = TypeName;
            ws.MethodName = Method;

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

            MethodInfo[] mi = types[0].GetMethods(Bin dingFlags.Publi c |
            BindingFlags.In stance |
            BindingFlags.De claredOnly);

            ParameterInfo[] pt = null;

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

            foreach(object o in MethodParameter s){
            object mo;

            if (!pt[mko++].ParameterType. ToString().Equa ls("System.Int3 2"))
            mo = ((methodParams) o).paramvalue.T oString();
            else
            mo = Convert.ToInt32 (((methodParams )o).paramvalue. ToString());

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

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

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

            //object result = Activator.Creat eInstance(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 MethodParameter s

            )
            {
            string result = string.Empty;
            DynamicWebServi ceProxy ws = new DynamicWebServi ceProxy();


            ws.Wsdl = WDSL;
            //"http://localhost/EHLO/Service1.asmx?W SDL";
            ws.TypeName = TypeName;
            ws.MethodName = Method;

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

            MethodInfo[] mi = types[0].GetMethods(Bin dingFlags.Publi c |
            BindingFlags.In stance |
            BindingFlags.De claredOnly);

            ParameterInfo[] pt = null;

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

            foreach(object o in MethodParameter s){
            object mo;

            if (!pt[mko++].ParameterType. ToString().Equa ls("System.Int3 2"))
            mo = ((methodParams) o).paramvalue.T oString();
            else
            mo = Convert.ToInt32 (((methodParams )o).paramvalue. ToString());

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

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

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

            //object result = Activator.Creat eInstance(t);

            try
            {

            ws.InvokeCall() ;

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



            [color=blue]
            >
            > Kevin
            >
            > <jabailo@texeme .com> wrote in message
            > news:F9SdnS52r4 n2p1HfRVn-ig@speakeasy.ne t...
            >[color=green]
            >>Kevin Yu wrote:
            >>[color=darkred]
            >>>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[/color][/color]
            >
            > do
            >[color=green][color=darkred]
            >>>that?
            >>>
            >>>Kevin
            >>>
            >>>
            >>>[/color]
            >>
            >>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.[/color]
            >
            >
            >[/color]

            Comment

            • jabailo@texeme.com

              #7
              Re: Passing interface as parameter in web service???

              Kevin Yu wrote:[color=blue]
              > How?
              >
              > please show some code sample.[/color]

              This code will generate the web services interface from a WSDL
              dynamically. This code requires the ThinkTecture 1.5 libraries (
              available free at thinktecture.co m ).


              public static void WInvoke(
              string WDSL,
              string TypeName,
              string Method,
              ArrayList MethodParameter s

              )
              {
              string result = string.Empty;
              DynamicWebServi ceProxy ws = new DynamicWebServi ceProxy();


              ws.Wsdl = WDSL;
              //"http://localhost/EHLO/Service1.asmx?W SDL";
              ws.TypeName = TypeName;
              ws.MethodName = Method;

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

              MethodInfo[] mi = types[0].GetMethods(Bin dingFlags.Publi c |
              BindingFlags.In stance |
              BindingFlags.De claredOnly);

              ParameterInfo[] pt = null;

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

              foreach(object o in MethodParameter s){
              object mo;

              if (!pt[mko++].ParameterType. ToString().Equa ls("System.Int3 2"))
              mo = ((methodParams) o).paramvalue.T oString();
              else
              mo = Convert.ToInt32 (((methodParams )o).paramvalue. ToString());

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

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

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

              //object result = Activator.Creat eInstance(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 MethodParameter s

              )
              {
              string result = string.Empty;
              DynamicWebServi ceProxy ws = new DynamicWebServi ceProxy();


              ws.Wsdl = WDSL;
              //"http://localhost/EHLO/Service1.asmx?W SDL";
              ws.TypeName = TypeName;
              ws.MethodName = Method;

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

              MethodInfo[] mi = types[0].GetMethods(Bin dingFlags.Publi c |
              BindingFlags.In stance |
              BindingFlags.De claredOnly);

              ParameterInfo[] pt = null;

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

              foreach(object o in MethodParameter s){
              object mo;

              if (!pt[mko++].ParameterType. ToString().Equa ls("System.Int3 2"))
              mo = ((methodParams) o).paramvalue.T oString();
              else
              mo = Convert.ToInt32 (((methodParams )o).paramvalue. ToString());

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

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

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

              //object result = Activator.Creat eInstance(t);

              try
              {

              ws.InvokeCall() ;

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



              [color=blue]
              >
              > Kevin
              >
              > <jabailo@texeme .com> wrote in message
              > news:F9SdnS52r4 n2p1HfRVn-ig@speakeasy.ne t...
              >[color=green]
              >>Kevin Yu wrote:
              >>[color=darkred]
              >>>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[/color][/color]
              >
              > do
              >[color=green][color=darkred]
              >>>that?
              >>>
              >>>Kevin
              >>>
              >>>
              >>>[/color]
              >>
              >>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.[/color]
              >
              >
              >[/color]

              Comment

              Working...