I'm just now beginning to experiment with WCF, and I've run into an odd
hiccup right at the beginning. I presume it's just something I'm doing
wrong, but I can't figure it out.
I've created a simple "Hello World" service, hosted in a console app, and if
I call that service via a ChannelFactory<> generated proxy, life is good:
using (ChannelFactory<IHelloWorld> helloFactory = new
ChannelFactory<IHelloWorld>("MyClient"))
{
HelloInterface.IHelloWorld proxy = helloFactory.CreateChannel();
Console.WriteLine(proxy.SayHello());
Console.ReadLine();
}
However, if I reference the web service in VS 2005, allow it to generate the
proxies for me, and then call the method, it hangs on the method call until
it times out:
helloworld.HelloWorld hello = new helloworld.HelloWorld();
Console.WriteLine(hello.SayHello()) // Here is where it hangs.
Console.ReadLine();
I believe that I've got my config file setup correctly, since if the service
isn't running, or is listening on a different endpoint, or with a different
encoding, it throws an exception immediately, instead of timing out. Still,
just for the record, here's my server config file:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="HelloService.HelloWorld"
behaviorConfiguration="metadataSupport">
<endpoint address="" binding="wsHttpBinding"
contract="HelloInterface.IHelloWorld" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/helloworld" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="metadataSupport">
<serviceMetadata httpGetEnabled="true" httpGetUrl=""/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
And here's my client config file:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings"
type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="HelloClient.Properties.Settings"
type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<system.serviceModel>
<client>
<endpoint address="http://localhost:8080/helloworld"
binding="wsHttpBinding" contract="HelloInterface.IHelloWorld" name="MyClient"
/>
</client>
</system.serviceModel>
<applicationSettings>
<HelloClient.Properties.Settings>
<setting name="HelloClient_helloworld_HelloWorld"
serializeAs="String">
<value>http://localhost:8080/helloworld</value>
</setting>
</HelloClient.Properties.Settings>
</applicationSettings>
</configuration>
Any thoughts on what I'm running into? I'm sure it's a basic mistake, but
danged if I know what it is.
Ken
Mariano Omar Rodriguez - 30 Jan 2007 23:25 GMT
You need to use Add Service Reference or generate the proxy with svcutil,
the standard Web Services don't interoperate with WCF by default (You need
put specific configuration).
http://msdn2.microsoft.com/en-us/library/ms735103.aspx
http://msdn2.microsoft.com/en-us/library/ms751433.aspx
http://www.microsoft.com/downloads/details.aspx?familyid=F54F5537-CC86-4BF5-AE44
-F5A1E805680D&displaylang=en
> I'm just now beginning to experiment with WCF, and I've run into an odd
> hiccup right at the beginning. I presume it's just something I'm doing
[quoted text clipped - 96 lines]
>
> Ken
smithkl42 - 31 Jan 2007 01:38 GMT
Thank you -- that fixed it. Nice to know it was just a rookie mistake.
Ken
> You need to use Add Service Reference or generate the proxy with svcutil,
> the standard Web Services don't interoperate with WCF by default (You need
[quoted text clipped - 104 lines]
> >
> > Ken