Problem Description
I am trying to code a simple proof of concept app (zip code available) based samples from various programming examples and texts.
1. A PC WinForm (.NET 2.0) client synchronously calls a HelloWorld() WebService method (http, wse 3.0). This works.
2. The same WinForm PC client can also call a different HelloWorld() method exposed in a separate Console Server app using .NET 2.0 Remoting; IpcChannel. This also works.
3. Finally (this is the purpose of the exercise), the PC client calls a wrapper HelloEcho() method in the WebService. The WebService method (with no changes) calls the Colsole Server’s HelloWorld() via .NET Remoting / IpcChannel.
The third chain (client via http to WS via IpcChannel to Server) will work the first time it is run. (Rebuild all, etc.) Subsequent calls invariably fail. With the exception:
System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Runtime.Remoting.RemotingException: Cannot create channel sink to connect to URL 'ipc://ConServerIpcChannel/ServerAppObject.rem'. An appropriate channel has probably not been registered.
at System.Runtime.Remoting.RemotingServices.Unmarshal(Type classToProxy, String url, Object data)
at System.Activator.GetObject(Type type, String url, Object state)
at System.Activator.GetObject(Type type, String url)
at Service.HelloEcho(String s) in c:\Data Files\Development\SimpleWebTest\WebService\App_Code\Service.cs:line 111
--- End of inner exception stack trace ---
A first chance exception of type 'System.Web.Services.Protocols.SoapException' occurred in System.Web.Services.dll
Additional Information
If I start the ConsoleServer.exe outside of VS 2005 and also start an ie browser I can call the HelloEcho() routine repeatedly; usually without the exception, but not always. If I start a second browser window or close and re-open ie the exception is thrown.
I am running WinXP SP2, IIS 5.1 and VS 2005 with all service packs, patches, etc. applied. Fully up to date (as of 15jan2007).
All executables, components, etc. are running on a single PC. The plan is to put the WS and the ConsoleServer app on a separate box.
The plan is to flow the user’s identity through to the ConsoleServer app. We will turn on full security for WSE 3.0 and Remoting. In fact this has already led to some complications:
1. The deployment environment is a Windows domain, with Kerberos for authentication. Because of this (and some previous help from Mark Fussell & Sidd Shenoy, I am running the WebService in native IIS / ASP.NET, not Cassini—not the VS 2005 ASP.NET Development Server.
2. I intend to use policy / config files in the solution. I have not had success with either code or policy approaches.
My Thoughts
I think the problem has something to do with the way I’ve coded the WebService. Initialization or startup problems. Which is why I am posting in this forum (WebService) and not the .NET Remoting one. But it could also be something to do with incorrectly registering the Ipc channel. Too many settings and switches, and I’m lost.
Any thoughts Help Thanks! Some partial code below:
from WebService (client for IpcChannel):
public class Service : System.Web.Services.WebService
{
[WebMethod]
public string HelloEcho(string s)
{
IpcClientChannel ipc = new IpcClientChannel();
if (!IsIpcClientChannelRegistered())
{
try
{
// setup / config channel
// includes impersonation
System.Runtime.Remoting.RemotingConfiguration.Configure("Web.Config", false);
}
catch (Exception)
{
}
}
else
{
s = "(IpcReg)" + s;
}
// get server object
try
{
ConServerInterface.IRemoteType serverObject = (ConServerInterface.IRemoteType)Activator.GetObject(typeof(ConServerInterface.IRemoteType), "ipc://ConServerIpcChannel/ServerAppObject.rem");
// say hello
s = "Hello(Ws), " + serverObject.Hello(s);
}
finally
{
// and cleanup after ourselves
foreach (IChannel channel in ChannelServices.RegisteredChannels)
{
if (channel is IpcClientChannel || channel is IpcChannel)
ChannelServices.UnregisterChannel(channel);
}
}
// all done, but what have we done !
return s;
}
}
from web.config
<system.runtime.remoting>
<application>
<channels>
<channel ref="ipc" secure="true" tokenImpersonationLevel="impersonation" />
</channels>
</application>
</system.runtime.remoting>
Server:
class ServerApp
{
[SecurityPermission(SecurityAction.Demand)]
static void Main(string[] args)
{
try
{
System.Console.WriteLine("Starting Console Server (POC)...");
System.Runtime.Remoting.RemotingConfiguration.Configure("ConServer.exe.config", false);
}
from server app.config:
< xml version="1.0" encoding="utf-8" >
<configuration>
<system.runtime.remoting>
<application name="ConServer">
<service>
<wellknown type="ConServer.ServerAppObject, ConServer" objectUri="ServerAppObject.rem" mode="SingleCall" />
</service>
<channels>
<channel ref="ipc" portName="ConServerIpcChannel" authorizedGroup="Everyone" />
</channels>
</application>
</system.runtime.remoting>
</configuration>
.NET Development19