c# - "An exception of type 'System.ServiceModel.ProtocolException' occurred in mscorlib.dll but was not handled in user code" error -


i want make web service in visual studio 2013 application.

i following error : "an exception of type 'system.servicemodel.protocolexception' occurred in mscorlib.dll not handled in user code".

wcf service web.config:

<?xml version="1.0"?> <configuration>    <appsettings>     <add key="aspnet:usetaskfriendlysynchronizationcontext" value="true" />   </appsettings>   <system.web>     <compilation debug="true" targetframework="4.5" />     <httpruntime targetframework="4.5"/>   </system.web>   <system.servicemodel>     <behaviors>       <servicebehaviors>         <behavior>           <!-- avoid disclosing metadata information, set values below false before deployment -->           <servicemetadata httpgetenabled="true" httpsgetenabled="true"/>           <!-- receive exception details in faults debugging purposes, set value below true.  set false before deployment avoid disclosing exception information -->           <servicedebug includeexceptiondetailinfaults="false"/>         </behavior>       </servicebehaviors>     </behaviors>     <protocolmapping>         <add binding="basichttpsbinding" scheme="https" />     </protocolmapping>         <servicehostingenvironment aspnetcompatibilityenabled="true" multiplesitebindingsenabled="true" />   </system.servicemodel>   <system.webserver>     <modules runallmanagedmodulesforallrequests="true"/>      <bindings>       <basichttpbinding>         <binding name="basichttpbinding_iservice1" />       </basichttpbinding>     </bindings>     <client>       <endpoint address="http://localhost:8095/service1.svc" binding="basichttpbinding"         bindingconfiguration="basichttpbinding_iservice1" contract="servicereference1.iservice1"         name="basichttpbinding_iservice1" />     </client>     <!--         browse web app root directory during debugging, set value below true.         set false before deployment avoid disclosing web app folder information.       -->     <directorybrowse enabled="true"/>   </system.webserver>  </configuration> 

website project service client web.config:

 <?xml version="1.0"?> <configuration>   <system.web>     <compilation debug="true" targetframework="4.5.1"/>     <httpruntime targetframework="4.5.1"/>   </system.web>   <system.servicemodel>     <bindings>       <basichttpbinding>         <binding name="basichttpbinding_iservice1" />       </basichttpbinding>     </bindings>     <client>       <endpoint address="http://localhost:8095/service1.svc" binding="basichttpbinding"         bindingconfiguration="basichttpbinding_iservice1" contract="servicereference1.iservice1"         name="basichttpbinding_iservice1" />     </client>   </system.servicemodel> </configuration> 

it looks have copy pasted lot of stuff wrong places.

at simple minimum, wcf service config's system.servicemodel section should more this...

<system.servicemodel>     <behaviors>       <servicebehaviors>         <behavior name="">          <servicemetadata httpgetenabled="true" />          <servicedebug includeexceptiondetailinfaults="false" />         </behavior>       </servicebehaviors>     </behaviors>     <bindings>     </bindings>     <services>       <service name="service1">         <endpoint address="service1.svc" name="service1endpoint"            binding="basichttpbinding" contract="servicereference1.iservice1" />         <host>          <baseaddresses>            <add baseaddress="http://localhost:8095/service1.svc" />          </baseaddresses>         </host>       </service>     </services> </system.servicemodel> 

try adjusting config this, , viewing url using web browser. if see page lets generate wsdl, need create client binding matches.

an example of client configuration this...

<system.servicemodel>   <behaviors>   </behaviors>   <bindings>   </bindings>   <client>    <endpoint address="http://localhost:8095/service1.svc"     binding="basichttpbinding" contract="servicereference1.iservice1"         name="myserviceclient" />   </client> </system.servicemodel> 

then create in-code client, code this...

var factory = new channelfactory<iservice1>("myserviceclient"); var channel = factory.createchannel(); 

wcf configuration can painful @ times, due potential settings combinations. takes bit of tweaking working way expect.


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -