Skip to main content

Indigo client: Channel not found error

Posted by arungupta on May 2, 2005 at 6:48 PM PDT

Now that my Indigo Web service is correctly deployed, I tried importing the metadata and generate a client proxy. I tried the following command:

"c:\Program Files\Microsoft Indigo
Preview\SvcUtil.exe" /config http://localhost/gettingstarted/HelloService/mex

but it gave an error:

Generating files...
E:\arung\indigo\client\output
Error: Unable to save config to file 'E:\arung\indigo\client\'.

So I specified an output directory explicitly and also the name of the config file as follows:

"c:\Program Files\Microsoft Indigo
Preview\SvcUtil.exe" /
config:App.config /d:. \

http://localhost/gettingstarted/HelloService.svc/mex

This command generated a proxy and App.config file in my current directory. Then I compiled the client code (given at the end), along with the generated proxy (renamed for convenience) using the following command:

c:csc /R:"C:\Program Files\Microsoft Indigo Preview\System.ServiceModel.dll" Client.cs generatedProxy.cs

Note, I had to explicitly include System.ServiceModel.dll in the compiler's classpath. Now the compiler generated an executable file. Now is when the rubber meets the road ... I invoked the generated executable and got the following error:

Unhandled Exception: System.InvalidOperationException: Could not find Channel element 
for configuration name IHelloService and contract IHelloService, HelloClient,
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
  at System.ServiceModel.Design.ConfigLoader.LoadChannelDescription(ChannelDescription channelDescription,
ContractDescription contract, String configurationName, EndpointAddress address)
  at System.ServiceModel.Design.ChannelLoader..ctor(Type contractType, String configurationName, EndpointAddress address)
  at System.ServiceModel.ChannelFactory`1..ctor(String configurationName)
  at System.ServiceModel.ProxyBase`1..ctor(String configurationName)
  at HelloClient.Main()

Learning from my previous experience, I searched for this error in Indigo newsgroup and found this. However the thread is closed stating it is an environment configuration problem. I still need to debug what kind of environment configuration is causing this error for me though and I'll get it to sometime later now.

Here is the code that I'm using:

-- Service endpoint --

<%@Service class="HelloService" Debug="true" language="cs"%>
using System;
using System.ServiceModel;

[ServiceContract()]
public interface IHelloService {

  [OperationContract]
  string Hello(string name);

}

public class HelloService : IHelloService {
  public string Hello(string name) {
    return "Hello: " + name;
  }
}

-- web.config --

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <services>
      <service serviceType="HelloService">
        <endpoint address=""
          bindingSectionName="wsProfileBinding"
          contractType="IHelloService" />
      </service>
    </services>
    <bindings>
      <wsProfileBinding>
      </wsProfileBinding>
    </bindings>
  </system.serviceModel>
</configuration>

-- client --

using System;

class HelloClient {

  public static void Main() {
    HelloServiceProxy myProxy = new HelloServiceProxy("IHelloService");
    String echoout  = myProxy.Hello("Duke!");
    Console.WriteLine(echoout);
  }
}

-- app.config --

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.serviceModel>
    <client>
      <endpoint address="http://localhost/gettingstarted/HelloWorld.svc"
        bindingSectionName="wsProfileBinding"
        configurationName="IHelloService"
        contractType="IHelloService">
        <addressProperties
          actingAs="http://localhost/gettingstarted/HelloWorld.svc"
          identityData=""
          identityType="None"
          isAddressPrivate="False" />
      </endpoint>
    </client>
    <bindings>
      <wsProfileBinding>
      </wsProfileBinding>
    </bindings>
  </system.serviceModel>
</configuration>
Related Topics >>