HTTP SOAP Remoting Problem

I am developing a simple .NET remoting server using an HTTP channel and SOAP formatter, and ran into a problem earlier with invalid SOAP actions.  When invoking a method on a remoted object I was getting the following error message:

Unhandled Exception: System.Runtime.Remoting.RemotingException:
 Invalid SOAPAction specified: blah blah blah

After trawling the web for an hour I established that many other developers are running into the same problem.  Now that I’ve resolved the issue I wanted to share the solution with everyone else.

My simple remoting server is a MarshalByRef class, called MyAgent,
hosted in a Windows service.  The HTTP channel, SOAP formatter, and
exposed remoted class are configured in the service application
configuration file as follows.

<system.runtime.remoting>
        <application name=”RPCServer”>
            <service>
                <wellknown mode=”SingleCall” type=”MyNamespace.MyAgent, MyAgentLib” objectUri=”MyAgent” />
            </service>
            <channels>
                <channel port=”8050″ ref=”http”>
                    <serverProviders>
                        <formatter ref=”soap”/>
                    </serverProviders>
                </channel>
            </channels>
        </application>
    </system.runtime.remoting>

In my client application, I configure the HTTP channel, SOAP formatter, and remote service class as follows:

<system.runtime.remoting>
        <application name=”RPCClient”>
            <client url=”http://localhost:8050/RPCServer”>
                <wellknown type=”MyNamespace.MyAgent, MyAgentLib” url=”MyAgent”/>
            </client>
            <channels>
                <channel ref=”http” port=”0″>
                    <clientProviders>
                        <formatter ref=”soap”/>
                    </clientProviders>
                </channel>
            </channels>
        </application>
    </system.runtime.remoting>

Originally, the MyAgent class
was a shared C# code file, compiled into both client and server
projects (in remoting, both client and server require the remoted class
type) – this worked fine in another remoting project I wrote, which
used IPC and TCP channels.  When using the HTTP channel and SOAP
provider this approach does not work (using HTTP and binary formatter
gave me a different cryptic error).  For some reason, the remoting
proxy (generated by the .NET remoting infrastructure) gets confused and
sees the client version of MyAgent class to be different to that of the MyAgent class hosted in the remote server.  To fix the problem I created a shared class library, called MyAgentLib, and included the MyAgent class. I then pointed both client and server projects to the shared class library.     Tada!

One thought on “HTTP SOAP Remoting Problem

  1. http://

    Thanks a lot for sharing that! I did exactly the same mistake (split projects) without creating the Agent as a library but it just didnt occur to me that this might be the problem. Now I can get on with thing 🙂

Comments are closed.