Unable to use HTTP Channel


A

Ashutosh

Hi,
Facing issue with HttpChannel....I have always used TcpChannel...using
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.microsoft.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.RegisterChannel(new HttpChannel(3324),false);
//ChannelServices.RegisterChannel(new TcpChannel(3324), false);

RemotingConfiguration.RegisterWellKnownServiceType(Type.GetType("RemotingServer.TestClass,
RemotingServer"), "RemotingServer", WellKnownObjectMode.Singleton);
Console.WriteLine("Server Initialized");
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
}
interface ITestInterface
{
void SayHello();
void OutputMessage(string msg);
}
class TestClass : MarshalByRefObject,ITestInterface
{
public void SayHello()
{
Console.WriteLine("Say Hello");
}
public void OutputMessage(string msg)
{
Console.WriteLine(msg);
}
}
}
=========================================
And this is the client code
namespace RemotingServer
{
interface ITestInterface
{
void SayHello();
void OutputMessage(string msg);
}
}
namespace RemotingClient1
{
class Program
{
static void Main(string[] args)
{
object o =
RemotingServices.Connect(typeof(RemotingServer.ITestInterface),
@"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
 
Ad

Advertisements

A

Ashutosh

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

Jialiang Ge [MSFT]

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 ([email protected], 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:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#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/default.aspx?target=assistance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Ad

Advertisements

J

Jialiang Ge [MSFT]

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 ([email protected], 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:
(e-mail address removed).

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top