Rob Garrett - Blogs

Welcome to Rob Garrett - Blogs Sign in | Join | Help
in Search
Google

Software/Technology Discussion

Software and Technology Tid-bits

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!
Share this post: Email it! | bookmark it! | digg it! | reddit!
Published Thursday, February 23, 2006 2:02 PM by Rob Garrett

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

Sascha said:

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 :-)
March 22, 2008 7:10 AM

Leave a Comment

(required) 
(optional)
(required) 
Submit

Blurb


Head Shot
Rob Garrett is a British Expat living in Maryland USA. Rob is a trained software engineer and experienced in Windows .NET development.

Rob enjoys listening to Rock music, posting to blogs, driving in the country with the sunroof open, beer (not in conjunction with country driving) and spending time with his family.

This Blog

Syndication

Powered by Community Server, by Telligent Systems