2016-05-22 8 views
0

Ich verfüge über eine einfache Konsolenanwendung, die einen von mir erstellten und in IIS gehosteten WCF-Dienst verwendet. Wenn ich die Konsolen-App direkt starte/debugge, funktioniert alles einwandfrei. Wenn ich die Konsolenanwendung durch den Task-Scheduler laufen lasse, erhalte ich folgende Fehlermeldung:Konnte WCF nicht konsumieren, wenn ich die Konsolenanwendung über den Taskplaner ausführe

22/05/2016 12:46:08 PM - Error getting profiles: There was no endpoint listening at http://localhost/ServiceABC that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.

22/05/2016 12:46:08 PM - Inner Exception: System.Net.WebException: The remote server returned an error: (404) Not Found. at System.Net.HttpWebRequest.GetResponse() at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)

Meine Konsole App ist wie folgt:

Sub Main() 
    GetProfiles() 
End Sub 

Sub GetProfiles() 
    Try 
     WriteToFile("Getting Profiles") 
     Dim client As New WcfServiceLibraryABCIIS.ServiceABCClient 
     client.Endpoint.Binding.SendTimeout = New TimeSpan(0, 20, 0) 
     client.GetProfiles() 
     WriteToFile("Finished Getting Profiles") 
    Catch ex As Exception 
     'WriteToFile("Error getting profiles: " + ex.Message + ex.StackTrace) 
     WriteToFile("Error getting profiles: " + ex.Message) 
     WriteToFile("Inner Exception: " + ex.InnerException.ToString) 
    End Try 

End Sub 

Private Sub WriteToFile(text As String) 
    text = DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss tt") + " - " + text 
    Dim path As String = "C:\Users\abcuser\Documents\ServiceLog.txt" 
    Using writer As New StreamWriter(path, True) 
     writer.WriteLine(String.Format(text, DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss tt"))) 
     writer.Close() 
    End Using 
End Sub 

Meine App.config-Datei ist wie folgt:

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <startup> 
     <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /> 
    </startup> 
    <system.serviceModel> 
     <bindings> 
      <wsHttpBinding> 
       <binding name="WSHttpBinding_IServiceABC" /> 
      </wsHttpBinding> 
     </bindings> 
     <client> 
      <endpoint address="http://localhost/ServiceABC" binding="wsHttpBinding" 
       bindingConfiguration="WSHttpBinding_IServiceABC" contract="WcfServiceLibraryABCIIS.IServiceABC" 
       name="WSHttpBinding_IServiceABC"> 
       <identity> 
        <userPrincipalName value="ABCCOMPUTER\abcuser" /> 
       </identity> 

      </endpoint> 
     </client> 
    </system.serviceModel> 
</configuration> 

Irgendwelche Gedanken?

Antwort

0

Problem gelöst!

Ich verwendete die falsche Endpunktadresse. Ich habe einen netTcpBinding Endpunkt meiner WCF-Dienst, so dass die Datei App.config Konsole App enthält jetzt einen Verweis auf:

<endpoint address="net.tcp://localhost/ServiceABC" binding="netTcpBinding" 
      bindingConfiguration="netTcpEndpoint" contract="WcfServiceLibraryABCIIS.IServiceABC" 
      name="netTcpEndpoint"> 

Und ich schaffe den Client als:

Dim client As New WcfServiceLibraryABCIIS.ServiceABCClient("netTcpEndpoint")