About one week ago I started with WCF for the first time, and so far I don't feel like I'm making any progress. I'm using Visual Studio 2010, .NET 4.0 (as far as I know, 4.5 is also installed) and Windows 7 professional.
The current issue is, I have a WCF service, and a client. When I run the client, the following line results in an exception:
Dim client As ABC_webservice.IService1 = New ABC_webservice.Service1Client
I changed the actual name of the service a bit before posting the code here.
This results in the following exception:
Could not find default endpoint element that references contract
'ABC_webservice.IService1' in the ServiceModel client configuration section.
This might be because no configuration file was found for your application, or
because no endpoint element matching this contract could be found in the client
element.
This is the relevant part of App.config for the webservice project:
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="MEX">
<serviceMetadata/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<netNamedPipeBinding>
<binding name="NamedPipeBinding" receiveTimeout="10:01:00" sendTimeout="00:01:00" transferMode="Streamed" maxReceivedMessageSize="4294967294" maxBufferSize="65536"/>
</netNamedPipeBinding>
<netTcpBinding>
<binding name="NetTcpBindingConf" receiveTimeout="10:01:00" sendTimeout="10:01:00" transferMode="Streamed" maxBufferSize="65536" maxReceivedMessageSize="4294967294"/>
</netTcpBinding>
</bindings>
<services>
<service behaviorConfiguration="MEX" name="ABC.ABC_webservice.ABC_webservice">
<endpoint address="IService1" binding="netTcpBinding" name="NetTcpFileTransfer" contract="ABC.ABC_webservice.IService1"/>
<endpoint address="IService1" binding="netNamedPipeBinding" bindingConfiguration="NamedPipeBinding" name="NetPipeFileTransfer" contract="ABC.ABC_webservice.IService1"/>
<endpoint address="MEX" binding="mexTcpBinding" bindingConfiguration="" name="MetadatEndpoint" contract="IMetadataExchange" kind="" endpointConfiguration=""/>
<host>
<baseAddresses>
<!-- <add baseAddress="http://localhost:8732/Design_Time_Addresses/ABC_webservice/Service1/"/> -->
<add baseAddress="net.tcp://localhost:8732"/>
<add baseAddress="net.pipe://localhost"/>
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
And this is the relevant part of app.config for the client project:
<?xml version="1.0"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
<system.serviceModel>
<bindings>
<netNamedPipeBinding>
<binding name="NetPipeFileTransfer" transferMode="Streamed" />
</netNamedPipeBinding>
<netTcpBinding>
<binding name="NetTcpFileTransfer" />
</netTcpBinding>
</bindings>
<client>
<endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
contract="IMetadataExchange" />
<endpoint address="net.tcp://localhost:8732/IService1" binding="netTcpBinding"
bindingConfiguration="NetTcpFileTransfer" contract="ABC_webservice.IService1"
name="NetTcpFileTransfer">
<identity>
<userPrincipalName value="LAPTOP-XYZ\XYZ" />
</identity>
</endpoint>
<endpoint address="net.pipe://localhost/IService1" binding="netNamedPipeBinding"
bindingConfiguration="NetPipeFileTransfer" contract="ABC_webservice.IService1"
name="NetPipeFileTransfer">
<identity>
<userPrincipalName value="LAPTOP-XYZ\XYZ" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
The config-files are derived from http://www.gonetdotnet.info/posts/wcf-articles/transfer-huge-file-to-wcf, but to be honest I don't really know what I'm doing.
First of all I would like to get a solution for this error. Eventually I'm trying to build a webservice and client combo that will be able to download files from the service to the client. At the moment the service as well as the client are running on my laptop and I want to get that working first while avoiding difficult security issues, but eventually the client and service will be on different servers on the internet, and I guess the process has to be secured with certificates. Any help will be greatly appreciated.