0
I’m trying to host a Web Service on a Windows service. And when setting up serviceModel
in the App.config
I’m getting the following error warning from the editor:
Webservice is a project of the kind Biblioteca de Serviço do WCF
and the project that will host Webservice is of the type Windows Service
.
Below follows the contract interface code:
using System.ServiceModel;
namespace FoxMovieStoreWebService
{
[ServiceContract]
public interface IDataPersistance<in T> where T : new ( )
{
[OperationContract]
bool Insert ( T value );
[OperationContract]
bool Change ( T value );
[OperationContract]
bool Delete ( T value );
// TODO: Adicione suas operações de serviço aqui
}
// Use um contrato de dados como ilustrado no exemplo abaixo para adicionar tipos compostos a operações de serviço.
// Você pode adicionar arquivos XSD ao projeto. Depois de criar o projeto, use os tipos de dados definidos nele diretamente, com o namespace "FoxMovieStoreWebService.ContractType".
}
Here the App.config
Windows Service where I set up Webservice:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<system.serviceModel>
<services>
<service name="FoxMovieStoreWebService.CrudAddress" behaviorConfiguration="ServiceConfig">
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:9876"/>
<add baseAddress="http://localhost:8766"/>
</baseAddresses>
</host>
<endpoint address="srv" binding="netTcpBinding" contract="FoxMovieStoreWebService.IDataPersistance"/>
<endpoint address="srv" binding="basicHttpBinding" contract="FoxMovieStoreWebService.IDataPersistance"/>
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
</service>
<service name="FoxMovieStoreWebService.CrudBooking" behaviorConfiguration="ServiceConfig">
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:9876"/>
<add baseAddress="http://localhost:8766"/>
</baseAddresses>
</host>
<endpoint address="srv" binding="netTcpBinding" contract="FoxMovieStoreWebService.IDataPersistance"/>
<endpoint address="srv" binding="basicHttpBinding" contract="FoxMovieStoreWebService.IDataPersistance"/>
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
</service>
<service name="FoxMovieStoreWebService.CrudCashDesk" behaviorConfiguration="ServiceConfig">
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:9876"/>
<add baseAddress="http://localhost:8766"/>
</baseAddresses>
</host>
<endpoint address="srv" binding="netTcpBinding" contract="FoxMovieStoreWebService.IDataPersistance"/>
<endpoint address="srv" binding="basicHttpBinding" contract="FoxMovieStoreWebService.IDataPersistance"/>
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
</service>
<service name="FoxMovieStoreWebService.CrudClient" behaviorConfiguration="ServiceConfig">
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:9876"/>
<add baseAddress="http://localhost:8766"/>
</baseAddresses>
</host>
<endpoint address="srv" binding="netTcpBinding" contract="FoxMovieStoreWebService.IDataPersistance"/>
<endpoint address="srv" binding="basicHttpBinding" contract="FoxMovieStoreWebService.IDataPersistance"/>
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
</service>
<service name="FoxMovieStoreWebService.Dependent" behaviorConfiguration="ServiceConfig">
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:9876"/>
<add baseAddress="http://localhost:8766"/>
</baseAddresses>
</host>
<endpoint address="srv" binding="netTcpBinding" contract="FoxMovieStoreWebService.IDataPersistance"/>
<endpoint address="srv" binding="basicHttpBinding" contract="FoxMovieStoreWebService.IDataPersistance"/>
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
</service>
<service name="FoxMovieStoreWebService.CrudDevolution" behaviorConfiguration="ServiceConfig">
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:9876"/>
<add baseAddress="http://localhost:8766"/>
</baseAddresses>
</host>
<endpoint address="srv" binding="netTcpBinding" contract="FoxMovieStoreWebService.IDataPersistance"/>
<endpoint address="srv" binding="basicHttpBinding" contract="FoxMovieStoreWebService.IDataPersistance"/>
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
</service>
<service name="FoxMovieStoreWebService.CrudFunctionary" behaviorConfiguration="ServiceConfig">
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:9876"/>
<add baseAddress="http://localhost:8766"/>
</baseAddresses>
</host>
<endpoint address="srv" binding="netTcpBinding" contract="FoxMovieStoreWebService.IDataPersistance"/>
<endpoint address="srv" binding="basicHttpBinding" contract="FoxMovieStoreWebService.IDataPersistance"/>
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
</service>
<service name="FoxMovieStoreWebService.CrudGame" behaviorConfiguration="ServiceConfig">
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:9876"/>
<add baseAddress="http://localhost:8766"/>
</baseAddresses>
</host>
<endpoint address="srv" binding="netTcpBinding" contract="FoxMovieStoreWebService.IDataPersistance"/>
<endpoint address="srv" binding="basicHttpBinding" contract="FoxMovieStoreWebService.IDataPersistance"/>
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
</service>
<service name="FoxMovieStoreWebService.CrudMovCashDesk" behaviorConfiguration="ServiceConfig">
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:9876"/>
<add baseAddress="http://localhost:8766"/>
</baseAddresses>
</host>
<endpoint address="srv" binding="netTcpBinding" contract="FoxMovieStoreWebService.IDataPersistance"/>
<endpoint address="srv" binding="basicHttpBinding" contract="FoxMovieStoreWebService.IDataPersistance"/>
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
</service>
<service name="FoxMovieStoreWebService.CrudMovie" behaviorConfiguration="ServiceConfig">
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:9876"/>
<add baseAddress="http://localhost:8766"/>
</baseAddresses>
</host>
<endpoint address="srv" binding="netTcpBinding" contract="FoxMovieStoreWebService.IDataPersistance"/>
<endpoint address="srv" binding="basicHttpBinding" contract="FoxMovieStoreWebService.IDataPersistance"/>
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
</service>
<service name="FoxMovieStoreWebService.CrudRent" behaviorConfiguration="ServiceConfig">
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:9876"/>
<add baseAddress="http://localhost:8766"/>
</baseAddresses>
</host>
<endpoint address="srv" binding="netTcpBinding" contract="FoxMovieStoreWebService.IDataPersistance"/>
<endpoint address="srv" binding="basicHttpBinding" contract="FoxMovieStoreWebService.IDataPersistance"/>
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceConfig">
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
I’m pretty sure this error is because I created the contract interface as a Generic Interface, because I don’t know how it looks on App.config
in that case. If my suspicion is confirmed I will change the title of the question.
This kind of implementation doesn’t really work by generic type...
– novic
What exactly do you say doesn’t work? Just because the interface is generic? project console and this time I left the settings no longer on
App.config
but I did it imperatively, that is, I performed the settings via C#code. I did not receive any compilation error.– Matheus Saraiva
Good try to perform change recording operations and also try to make available to third parties in this way...
– novic
Complemented by what @Virgilionovic commented, it might not work that way, with such a "generic" interface. Remember that a contract is a way for the client and the service server to define as clearly as possible the rules, that is, the service will receive what will return. This interface does not respect this concept of contract, would be the equivalent to say "Send me something I insert, alter, etc", do you understand? This may work well in a class, but not in a service contract.
– Ricardo Pontual