I have a WCF service which I'm trying to access via a browser. It works fine via the test client, but my breakp[oints are not called when using a browser. My web.config has
<system.serviceModel>
<client>
<endpoint address="http://localhost:84/BillService.svc"
binding="webHttpBindingConfig" bindingConfiguration="BasicHttpBinding_IBillService"
behaviorConfiguration="json"
contract="iBillService.IBillService" name="BasicHttpBinding_IBillService" />
</client>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="Behavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="json">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<!-- turn off authentication in WCF, we get the client from the HttpContext -->
<bindings>
<basicHttpBinding>
<binding name="CustomBasicAuth">
<security mode="None">
<transport clientCredentialType="None" />
</security>
</binding>
<binding name="BasicHttpBinding_IBillService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
<wsHttpBinding>
<binding name="WsHttpBindingConfig">
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None" />
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>
<webHttpBinding>
<binding name="webHttpBindingConfig">
<security mode="None"/>
</binding>
</webHttpBinding>
</bindings>
<!-- to enable IIS authentication for WCF, we have to switch to compatibility mode -->
<serviceHostingEnvironment aspNetCompatibilityEnabled="false"
multipleSiteBindingsEnabled="true" />
<services>
<service name="WcfService"
behaviorConfiguration="Behavior">
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="CustomBasicAuth"
contract="IWcfService" />
</service>
</services>
</system.serviceModel>
My interface definition has this:
<OperationContract()>
<WebInvoke(BodyStyle:=WebMessageBodyStyle.Bare, RequestFormat:=WebMessageFormat.Json, ResponseFormat:=WebMessageFormat.Json, Method:="GET")>
<WebGet(BodyStyle:=WebMessageBodyStyle.Bare, ResponseFormat:=ResponseFormat.Json)>
<ScriptMethod(UseHttpGet:=True, ResponseFormat:=ResponseFormat.Json)>
Function GetBills(ByVal userName As String, ByVal passwordHash As S开发者_开发知识库tring) As List(Of Bill)
Yet when I visit the URL
http://localhost:84/BillService.svc/GetBills?userName=demo&passwordHash=dummy
I get a blank page and my breakpoints aren't triggered
Change this
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="CustomBasicAuth"
contract="IWcfService" />
to
<endpoint address=""
binding="webHttpBinding"
bindingConfiguration="CustomBasicAuth"
contract="IWcfService" />
this might help you access your service using URL
The problem might not be in your code, but in your annotations. WCF can get very frustrating since there are a lot of switches your can turn on and off. Start by adding a
[ServiceBehavior(IncludeExceptionDetailInFaults = true)]
to you service implementation. If you still don't see any error, you can enable WCF tracing: MSDN: Configuring WCF Tracing
For WCF Tracing:
<configuration>
<system.diagnostics>
<sources>
<source name="System.ServiceModel"
switchValue="Information, ActivityTracing"
propagateActivity="true">
<listeners>
<add name="traceListener"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData= "c:\log\Traces.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>
</configuration>
精彩评论