c# - wsHttpBinding app config for ServiceContract sessions -
hallo want user sessionmode = sessionmode.required
, read wcf service must has wshttpbinding
because supports sessions. make 1 app.config
configuration , make 1 function in windows form start servives. when click button , call startwcfserver()
exception:
invalidoperationexception unhandled
could not find base address matches scheme https endpoint binding wshttpbinding. registered base address schemes [http].
here codes:
app.config
<?xml version="1.0"?> <configuration> <system.servicemodel> <services> <service behaviorconfiguration="servicebehaviour" name="wcf_server.wcfservice"> <endpoint address="" behaviorconfiguration="web" binding="wshttpbinding" bindingconfiguration="wshttpbindings" contract="wcf_server.iwcfservice"/> </service> </services> <behaviors> <servicebehaviors> <behavior name="servicebehaviour"> <servicemetadata httpgetenabled="true" httpsgetenabled="false"/> <servicedebug httpshelppageenabled="true" httphelppageenabled="true" includeexceptiondetailinfaults="true"/> </behavior> </servicebehaviors> <endpointbehaviors> <behavior name="web"> </behavior> </endpointbehaviors> </behaviors> <protocolmapping> <add binding="wshttpbinding" scheme="https"/> </protocolmapping> <servicehostingenvironment aspnetcompatibilityenabled="true" multiplesitebindingsenabled="true"/> <bindings> <wshttpbinding> <binding name="wshttpbindings"> <security mode="transportwithmessagecredential"> <message clientcredentialtype="username"/> </security> </binding> </wshttpbinding> </bindings> </system.servicemodel> <system.webserver> <modules runallmanagedmodulesforallrequests="true"/> <directorybrowse enabled="true"/> </system.webserver> <startup><supportedruntime version="v4.0" sku=".netframework,version=v4.0"/></startup></configuration>
startwcfserver()
servicehost host; private void startwcfserver() { if (host == null) { uri baseaddress = new uri("http://localhost:8000/"); host = new servicehost(typeof(wcfservice), baseaddress); host.addserviceendpoint(typeof(iwcfservice), new wshttpbinding("wshttpbinding"), "services"); host.open();//<-- exception here } }
here setting <add binding="wshttpbinding" scheme="https"/>
in host using uri baseaddress = new uri(http+ site's url);
so change scheme="https"
scheme="http"
Comments
Post a Comment