2016-01-31 12 views
5

Server app.config:WCF: Podany schemat identyfikatora URI "https" jest nieprawidłowy; oczekiwano "http". Nazwa parametru: via, gdy zadzwonię IInternal proxy = factory.CreateChannel(); na Client

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <system.web> 
    <compilation debug="true"/> 
    </system.web> 
    <system.serviceModel> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="NewBehaviour"> 
      <serviceMetadata httpsGetEnabled="True"/> 
      <serviceDebug includeExceptionDetailInFaults="True"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <bindings> 
     <wsHttpBinding> 
     <binding name="Binding"> 
      <security mode="Transport"> 
      <transport clientCredentialType="None"></transport> 
      </security> 
     </binding> 
     </wsHttpBinding> 
    </bindings> 

    <services> 
     <service name="Server.InternalClass" behaviorConfiguration="NewBehaviour"> 
     <endpoint address="IInternal" binding="wsHttpBinding" bindingConfiguration="Binding" contract="Common.IInternal"> 
      <identity> 
      <dns value="MyMachine"/> 
      </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/> 
     <host> 
      <baseAddresses> 
      <add baseAddress="https://MyMachine:8733/"/> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 
    </system.serviceModel> 


</configuration> 

Client

static ChannelFactory<IInternal> factory = new ChannelFactory<IInternal>(new WSHttpBinding(), new EndpointAddress("https://MyMachine:8733/IInternal")); 

Kiedy wywołać metodę factory.CreateChannel(), otrzymuję błąd

skonfigurować certyfikatowi

enter image description here

+0

Czy usługa rozpocznie się poprawnie? Jaką konfigurację masz dla klienta w pliku app.config klienta? –

+0

Uruchomienie usługi poprawnie. Nie mam pliku konfiguracyjnego dla klienta. – user3661837

Odpowiedz

3

Musisz poinformować klienta, aby korzystał z bezpiecznego kanału transportowego, aby korzystał z https zamiast http. Jest to prawdą, ponieważ ustawienia wiązania na kliencie muszą być zgodne z ustawieniami po stronie usługi.

Można to zrobić za pomocą konfiguracji w pliku app.config klienta, czy można to zrobić za pomocą kodu:

var ws_http_binding = new WSHttpBinding(); 

ws_http_binding.Security.Mode = SecurityMode.Transport; 

ChannelFactory<IInternal> factory = 
    new ChannelFactory<IInternal>(
     ws_http_binding, 
     new EndpointAddress("https://MyMachine:8733/IInternal")); 

var channel = factory.CreateChannel(); 
+0

Dziękuję bardzo! To działa! :)) – user3661837

+0

Nie ma za co –

Powiązane problemy