Unable to use HTTP Channel

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

    Unable to use HTTP Channel

    Hi,
    Facing issue with HttpChannel.... I have always used TcpChannel...us ing
    it for the first time..

    This code works fine for TcpChannel but gives exception when using
    HttpChannel on calling the SayHello method in client. Exception details:
    "Invalid SOAPAction specified:
    "http://schemas.microso ft.com/clr/nsassem/RemotingServer. ITestInterface/RemotingClient1 #SayHello""

    Do we need to do something extra here to use HttpChannel? I have tried
    applying SoapMethod attributes to the method and/or SoapType to the
    class & interface.

    I have this simple server code....
    namespace RemotingServer
    {
    class Program
    {
    static void Main(string[] args)
    {
    ChannelServices .RegisterChanne l(new HttpChannel(332 4),false);
    //ChannelServices .RegisterChanne l(new TcpChannel(3324 ), false);

    RemotingConfigu ration.Register WellKnownServic eType(Type.GetT ype("RemotingSe rver.TestClass,
    RemotingServer" ), "RemotingServer ", WellKnownObject Mode.Singleton) ;
    Console.WriteLi ne("Server Initialized");
    Console.WriteLi ne("Press any key to exit");
    Console.ReadKey ();
    }
    }
    interface ITestInterface
    {
    void SayHello();
    void OutputMessage(s tring msg);
    }
    class TestClass : MarshalByRefObj ect,ITestInterf ace
    {
    public void SayHello()
    {
    Console.WriteLi ne("Say Hello");
    }
    public void OutputMessage(s tring msg)
    {
    Console.WriteLi ne(msg);
    }
    }
    }
    =============== =============== ===========
    And this is the client code
    namespace RemotingServer
    {
    interface ITestInterface
    {
    void SayHello();
    void OutputMessage(s tring msg);
    }
    }
    namespace RemotingClient1
    {
    class Program
    {
    static void Main(string[] args)
    {
    object o =
    RemotingService s.Connect(typeo f(RemotingServe r.ITestInterfac e),
    @"http://localhost:3324/RemotingServer" , null);
    RemotingServer. ITestInterface t = o as
    RemotingServer. ITestInterface;
    if (t != null)
    {
    t.SayHello();
    t.OutputMessage ("Hi From Client");
    }
    Console.ReadKey ();
    }
    }
    }


    Can someone please point out the problem here?

    Thanks & Regards,
    Ashutosh
  • Ashutosh

    #2
    Re: Unable to use HTTP Channel

    Gets the same exception when I run the sample code provided in the MSDN
    for HttpChannel class or HttpClientChann el class.

    Ashutosh wrote:
    Hi,
    Facing issue with HttpChannel.... I have always used TcpChannel...us ing
    it for the first time..
    >
    This code works fine for TcpChannel but gives exception when using
    HttpChannel on calling the SayHello method in client. Exception
    details: "Invalid SOAPAction specified:
    "http://schemas.microso ft.com/clr/nsassem/RemotingServer. ITestInterface/RemotingClient1 #SayHello""
    >
    >
    Do we need to do something extra here to use HttpChannel? I have tried
    applying SoapMethod attributes to the method and/or SoapType to the
    class & interface.
    >
    I have this simple server code....
    namespace RemotingServer
    {
    class Program
    {
    static void Main(string[] args)
    {
    ChannelServices .RegisterChanne l(new HttpChannel(332 4),false);
    //ChannelServices .RegisterChanne l(new TcpChannel(3324 ),
    false);
    >
    RemotingConfigu ration.Register WellKnownServic eType(Type.GetT ype("RemotingSe rver.TestClass,
    RemotingServer" ), "RemotingServer ", WellKnownObject Mode.Singleton) ;
    Console.WriteLi ne("Server Initialized");
    Console.WriteLi ne("Press any key to exit");
    Console.ReadKey ();
    }
    }
    interface ITestInterface
    {
    void SayHello();
    void OutputMessage(s tring msg);
    }
    class TestClass : MarshalByRefObj ect,ITestInterf ace
    {
    public void SayHello()
    {
    Console.WriteLi ne("Say Hello");
    }
    public void OutputMessage(s tring msg)
    {
    Console.WriteLi ne(msg);
    }
    }
    }
    =============== =============== ===========
    And this is the client code
    namespace RemotingServer
    {
    interface ITestInterface
    {
    void SayHello();
    void OutputMessage(s tring msg);
    }
    }
    namespace RemotingClient1
    {
    class Program
    {
    static void Main(string[] args)
    {
    object o =
    RemotingService s.Connect(typeo f(RemotingServe r.ITestInterfac e),
    @"http://localhost:3324/RemotingServer" , null);
    RemotingServer. ITestInterface t = o as
    RemotingServer. ITestInterface;
    if (t != null)
    {
    t.SayHello();
    t.OutputMessage ("Hi From Client");
    }
    Console.ReadKey ();
    }
    }
    }
    >
    >
    Can someone please point out the problem here?
    >
    Thanks & Regards,
    Ashutosh

    Comment

    • Jialiang Ge [MSFT]

      #3
      Re: Unable to use HTTP Channel

      Good afternoon Ashutosh,

      I just tried your example code and reproduced the error. After debugging
      into the HttpChannel class, I figure out the reason and solution for your
      reference:

      ====== SOLUTION =======

      The interface ITestInterface and the class TestClass need to be defined in
      a separate assembly. Then both server app and client app reference the
      assembly.

      ====== CAUSE =======
      HttpChannel not only checks the object type's namespace and class name, but
      also its assembly name. In our original code, though TestClass and
      ITestInterface defined on both sides have the same namespace
      "RemotingServer ", their assembly names are still different: on the server
      side, the assembly name is RemotingServer, and on the client side, the
      assembly name is RemotingClient. The solution above puts the class
      definition in a shared assembly to make sure the assembly name is the same.

      Please try the above and let me know whether it works for you or not. If
      you have any other concerns or questions, please feel free to tell me. I
      will spare no effort to help you.

      Regards,
      Jialiang Ge (jialge@online. microsoft.com, remove 'online.')
      Microsoft Online Community Support

      Delighting our customers is our #1 priority. We welcome your comments and
      suggestions about how we can improve the support we provide to you. Please
      feel free to let my manager know what you think of the level of service
      provided. You can send feedback directly to my manager at:
      msdnmg@microsof t.com.

      =============== =============== =============== =====
      Get notification to my posts through email? Please refer to
      http://msdn.microsoft.com/en-us/subs...#notifications.

      Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
      where an initial response from the community or a Microsoft Support
      Engineer within 1 business day is acceptable. Please note that each follow
      up response may take approximately 2 business days as the support
      professional working with you may need further investigation to reach the
      most efficient resolution. The offering is not appropriate for situations
      that require urgent, real-time or phone-based interactions or complex
      project analysis and dump analysis issues. Issues of this nature are best
      handled working with a dedicated Microsoft Support Engineer by contacting
      Microsoft Customer Support Services (CSS) at
      http://support.microsoft.com/select/...tance&ln=en-us.
      =============== =============== =============== =====
      This posting is provided "AS IS" with no warranties, and confers no rights.


      Comment

      • Jialiang Ge [MSFT]

        #4
        Re: Unable to use HTTP Channel

        Hello Ashutosh,

        I am writing to check the status of the issue on your side. Would you mind
        letting me know the result of the suggestions? If you need further
        assistance, feel free to let me know. I will be more than happy to be of
        assistance.

        Have a great day!

        Regards,
        Jialiang Ge (jialge@online. microsoft.com, remove 'online.')
        Microsoft Online Community Support

        =============== =============== =============== ====
        Delighting our customers is our #1 priority. We welcome your comments and
        suggestions about how we can improve the support we provide to you. Please
        feel free to let my manager know what you think of the level of service
        provided. You can send feedback directly to my manager at:
        msdnmg@microsof t.com.

        This posting is provided "AS IS" with no warranties, and confers no rights.
        =============== =============== =============== ====

        Comment

        Working...