Mam usługę WCF, którą przetestowałem , kopiując jej interfejsy do przykładowego projektu klienta.
Teraz chcę działać poprawnie, dodając odwołanie do usługi.
Usługa jest hostowana w systemie Windows Hosting (przy użyciu installUtil
).
Usługa ma 2 projekty - zewnętrzne (interfejsy + datacontracts) i wewnętrzne (implementacje).
Z jakiegoś powodu to nie miało app.config więc dodałem jedną ręcznie:Dodaj odwołanie do usługi podczas używania wiązania netTcp
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="ExecutionService" behaviorConfiguration="Default">
<endpoint name="TCPEndpoint" address="" binding ="netTcpBinding" contract="Externals.IExecutionService"/>
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:3040/ExecutionService"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="Default">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
Próbując dodać odwołanie usług od mojego klienta próbki powoduje następujący błąd:
Metadata contains a reference that cannot be resolved: 'net.tcp://localhost:3040/ExecutionService/Externals.IExecutionService'.
There was no endpoint listening at net.tcp://localhost:3040/ExecutionService/Externals.IExecutionService that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
If the service is defined in the current solution, try building the solution and adding the service reference again.
I zobaczyłem here, że nie ma potrzeby w app.config.
Jestem trochę zdezorientowany i jestem początkującym z WCF
.
W jaki sposób miła aplikacja WPF
może odwoływać się do mojej usługi? Chcę, aby usługa była hostowana w systemie Windows i nie chcę przeciągać bibliotek DLL ze mną.
Edit
Dodałem punkt końcowy metadanych i mój appconfig teraz wygląda tak:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="ExecutionService" behaviorConfiguration="Default">
<endpoint name="TCPEndpoint"
address=""
binding ="netTcpBinding"
contract="Externals.IExecutionService"/>
<endpoint address="mex"
binding="maxHttpBinding"
contract="Externals.IExecutionService"/>
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:3040/ExecutionService"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="Default">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
Próbowałem dodanie odniesienia usługa, za pomocą net.tcp://localhost:3040/ExecutionService
net.tcp://localhost:3040/ExecutionService/Externals
i net.tcp://localhost:3040/ExecutionService/Externals/IExecutionService
a ja wciąż się samo błąd.
Witam, dodałem jeden, wciąż otrzymuję ten sam wyjątek, proszę zobaczyć edycję w poście. – Noich