Cant connect to WCF Service. Missing EndPointElemt - c#

i'm trying to create my own WCF service and client. I've created my Service with the following app.config settings:
<system.serviceModel>
<services>
<service name="Interface.MyWCFService">
<endpoint address="http://localhost:9999/MyService" binding="basicHttpBinding"
bindingConfiguration="" name="MyServiceEndpoint" contract="Interface.IMyWCFService" />
</service>
</services>
</system.serviceModel>
The service starts without an exception.
My client should connect to this service. His app.config is this one:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<client>
<endpoint address="http://localhost:9999/MyService" binding="basicHttpBinding"
bindingConfiguration="" contract="Interface.IMyWCFService"
name="MyServiceEndpoint" kind="" endpointConfiguration="" />
</client>
</system.serviceModel>
</configuration>
In the c# code i try to create a channelfactory in the client.cs with the following code:
ChannelFactory<IMyWCFService> channelFactory = new ChannelFactory<IMyWCFService>("MyServiceEndpoint", new EndpointAddress("http://localhost:9999/MyService"));
IMyWCFService proxy = channelFactory.CreateChannel();
This is not working. Every time i try to start the program i get the following exception:
No Endpointelement with the name "MyServiceEndpoint" and contract
"Interface.IMyWCFService" was found in
ServiceModel-Clientconfigurationsection.
I hope you can help me.

This is how I have my service configured:
<service name="foo.bar.BlaService">
<host>
<baseAddresses>
<add baseAddress="http://localhost/BlaService" />
</baseAddresses>
</host>
<endpoint address="" binding="basicHttpBinding" contract="foo.bar.IBlaService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
And here the client:
<client>
<endpoint name="BlaService" address="http://localhost/BlaService" binding="basicHttpBinding" contract="foo.bar.IBlaService" />
</client>

Related

How to handle Request Entity Too Large in WPF services

Im receiving the following error in my WCF program when I send too many xml files:
System.ServiceModel.ProtocolException: The remote server returned an unexpected response: (413) Request Entity Too Large. ---> System.Net.WebException: The remote server returned an error: (413) Request Entity Too Large.
All the other stack overflow answers don't seem to offer me a solution as they mention binding elements in the app.config and my app.config uses services so I'm unsure where to stick the changes. This also makes me wonder if I'm also writing my config file wrong for a production service.
app.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" />
</system.web>
<system.serviceModel>
<services>
<service name="ConfigService.UserService">
<endpoint address="" binding="basicHttpBinding" contract="ConfigService.IUserService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/Design_Time_Addresses/ProductionProgrammerWebService/UserService/" />
</baseAddresses>
<timeouts openTimeout="00:00:30" />
</host>
</service>
<service name="ConfigService.ConfigurationService">
<endpoint address="" binding="basicHttpBinding" contract="ConfigService.IConfigurationService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/Design_Time_Addresses/ProductionProgrammerWebService/ConfigurationService/" />
</baseAddresses>
<timeouts openTimeout="00:00:30" />
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>

WCF REST Service for ANdroid Client Producing Error

Hi I want to make a WCF Rest service to be consumed by an android client.
Can somebody please post a easy helpful solution for the same problem step by step.
As far as I see
Web.config:
<service name="ServifyCoreModulesService.Service1">
<endpoint address="" behaviorConfiguration="restfulBehavior"
binding="webHttpBinding" bindingConfiguration="" contract="ServifyCoreModulesService.IService1" />
<host>
<baseAddresses>
<add baseAddress="http://localhost/service1" />
</baseAddresses>
</host>
</service>
App.config:
<client>
<endpoint
name="endpoint1"
address="http://localhost/ServifyCoreModulesService/Service1.svc"
binding="webHttpBinding"
bindingConfiguration=""
behaviorConfiguration="restfulBehavior"
contract="ServifyCoreModulesService.IService1" >
<metadata>
<wsdlImporters>
<extension
type="Microsoft.ServiceModel.Samples.WsdlDocumentationImporter, WsdlDocumentation"/>
</wsdlImporters>
</metadata>
<identity>
<servicePrincipalName value="host/localhost" />
</identity>
</endpoint>
</client>
I am getting issue with metadata.
I dont understand all of these tags does anybody have a start to finish tutorial on this ? Or any clue about why i should configure in a particular way?

wcf service host run only on port number 8080

I have a wcf service and used a console app as the host for my service. when I use base address like this: <baseaddres ="http://ipaddress:8080/" />. When I check my service operation through a web browser I can open the service WSDL and it works fine.
But, as I change the port number to something else. The service host starts fine (with no exception of used port number or anything else). As I go to check if the service is running through web browser the service is not shown. eventually my client also could not locate the service.
app.config configuration
<services>
<service name="Natatorium_WCF.NatatoriumService"
behaviorConfiguration="ServiceBehavior">
<endpoint address="NatatoriumService"
binding="wsHttpBinding"
contract="Natatorium_WCF.INatatoriumService"
bindingConfiguration="wsHttpBindingConfig">
</endpoint>
<endpoint address="NatatoriumService"
binding="netTcpBinding"
contract="Natatorium_WCF.INatatoriumService"
bindingConfiguration="netTcpBindingConfig" >
</endpoint>
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://[ServerName]:[PortNO.1]"/>
<add baseAddress="net.tcp://[ServerName]:[PortNO.2]"/>
</baseAddresses>
</host>
</service>
</services>
this is the host code to start the service (console application).
static void Main(string[] args)
{
ChangeServerConfigFileAttributeValue("8080", "8090");
using (ServiceHost host = new ServiceHost(typeof(Natatorium_WCF.NatatoriumService)))
{
host.Open();
Console.WriteLine("Listening...");
Console.ReadLine();
}
}
<configuration>
<system.serviceModel>
<services>
<service name="HelloService.HelloService" behaviorConfiguration="mexBehaviour">
<endpoint address="HelloService" binding="basicHttpBinding" contract="HelloService.IHelloService" ></endpoint>
<endpoint address="HelloService" binding="netTcpBinding" contract="HelloService.IHelloService" ></endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" ></endpoint>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/"/>
<add baseAddress="net.tcp://localhost:8090/"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="mexBehaviour">
<remove name="serviceDebug"/>
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>

Visual Studio 2012 + IIS 8.0 = how to deploy WCF service on localhost?

I have a Wcf Service Application project that is referenced by and used in different projects. Everything works fine when started Visual Studio 2012 - IIS Express is launched, hosted on localhost.
I tried to use Publish option in right-click menu of my Wcf Service Application. I created a new profile for publishing:
Hitting Publish works. I can access it through internet browser through http://localhost. However, when I launch my application normally, through the executable in bin/Debug - it doesn't work (app crashes). What should I do? Can I upload it and configure it easily with IIS Manager (tried it, but get some access errors)? I would need that in my virtual machine which doesn't have any VS installed.
What's troubling me is that in my Wcf Service Application project's Web.config file I have base addresses specified like this: http://localhost:8733/WcfServiceLibrary/MailingListService/ and in clients App.config I have endpoints with addresses like this: http://localhost/MailingListService.svc. Is it ok to have different ports and addresses (one is in root, the other in WcfServiceLibrary)? It works fine when run in Visual Studio.
Web.config:
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="NewsletterEntities" connectionString="metadata=res://*/NewsletterDAL_EF.csdl|res://*/NewsletterDAL_EF.ssdl|res://*/NewsletterDAL_EF.msl;provider=System.Data.SqlClient;provider connection string="Data Source=(local)\SQLEXPRESS;Initial Catalog=Newsletter;Integrated Security=True;Pooling=False;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient"/>
</connectionStrings>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<services>
<service name="WCFHost.MessageService">
<endpoint address="" binding="basicHttpBinding" contract="WCFHost.IMessageService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/WcfServiceLibrary/MessageService/" />
</baseAddresses>
</host>
</service>
<service name="WCFHost.MailingListService">
<endpoint address="" binding="basicHttpBinding" contract="WCFHost.IMailingListService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/WcfServiceLibrary/MailingListService/" />
</baseAddresses>
</host>
</service>
<service name="WCFHost.RecipientService">
<endpoint address="" binding="basicHttpBinding" contract="WCFHost.IRecipientService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/WcfServiceLibrary/RecipientService/" />
</baseAddresses>
</host>
</service>
<service name="WCFHost.SenderService">
<endpoint address="" binding="basicHttpBinding" contract="WCFHost.ISenderService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/WcfServiceLibrary/SenderService/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
App.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IMessageService" />
<binding name="BasicHttpBinding_IRecipientService" />
<binding name="BasicHttpBinding_IMailingListService" />
<binding name="BasicHttpBinding_ISenderService" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:2433/MessageService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMessageService"
contract="MessageServiceReference.IMessageService" name="BasicHttpBinding_IMessageService" />
<endpoint address="http://localhost/RecipientService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IRecipientService"
contract="RecipientServiceReference.IRecipientService" name="BasicHttpBinding_IRecipientService" />
<endpoint address="http://localhost/MailingListService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMailingListService"
contract="MailingListServiceReference.IMailingListService"
name="BasicHttpBinding_IMailingListService" />
<endpoint address="http://localhost/SenderService.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_ISenderService" contract="SenderServiceReference.ISenderService"
name="BasicHttpBinding_ISenderService" />
</client>
</system.serviceModel>
</configuration>
dont bother anything. just do the following:
1) enter localhost in service url field.
2) The name of the website you have added inside the inetmgr in the site field.

Could not find default endpoint element that references contract

I have self hosted a WCF service from a console application (HOST). I am calling HOST from another console application (PARENT). When I run PARENT, everything works fine like the WCF hosted successfully and instance of service reference is also getting created. The PARENT application is actually a plug-in for another big unmanaged application(BIG A). When I start the PARENT application from BIG A , the console application self hosts the service successfully. However I am getting following error while creating the instance of service.
Could not find default endpoint element that references contract 'CalculatorServiceReference.ICalculatorService' 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.
The configuration files are as follows.
•Configuration file of HOST
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="NewBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="NewBehavior" name="HybridCalcService.CalculatorService">
<clear />
<endpoint address="mex" binding="mexHttpBinding" name="Mex" contract="IMetadataExchange"
listenUriMode="Explicit">
</endpoint>
<endpoint address="net.tcp://localhost:8523/CalcService" binding="netTcpBinding"
name="Tcp" contract="HybridCalcService.ICalculatorService" listenUriMode="Explicit">
</endpoint>
<endpoint address="HTTP" binding="basicHttpBinding" bindingConfiguration=""
name="HTTP" contract="HybridCalcService.ICalculatorService" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/Hybridservice" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>
•And the config of PARENT is
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="NewBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="NewBehavior" name="HybridCalcService.CalculatorService">
<clear />
<endpoint address="mex" binding="mexHttpBinding" name="Mex" contract="IMetadataExchange"
listenUriMode="Explicit">
</endpoint>
<endpoint address="net.tcp://localhost:8523/CalcService" binding="netTcpBinding"
name="Tcp" contract="HybridCalcService.ICalculatorService" listenUriMode="Explicit">
</endpoint>
<endpoint address="HTTP" binding="basicHttpBinding" bindingConfiguration=""
name="HTTP" contract="HybridCalcService.ICalculatorService" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/Hybridservice" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>
Can anyone help me in this issue?
I believe that the config info has to be in the config file of the main application. Adding that info to the config of BigA should solve the problem.
This looks pretty similar to what I did for a custom channel. if i remember correctly this would go into HOST, and then you wouldn't need anything in the other configs.

Categories