开发者

Calling WCF service with forms authentication

I have wpf application that calls wcf service with forms authentication. I added Service Reference to my solution, and in service configuration checked Generate asynchronous operations.

In code behind I created 开发者_如何学JAVAclient to that reference, than I attached event to fire after async method is completed, then username and pass is setted:

        client.ClientCredentials.UserName.UserName = txtUser.Text;
        client.ClientCredentials.UserName.Password = passbox.Password;
        client.IsAuthenticatedAsync(txtUser.Text, passbox.Password);
        client.Close();

in IsAuthenticatedCompletedEventArgs I get error: "The communication object, System.ServiceModel.Channels.HttpsChannelFactory+HttpsRequestChannel, cannot be used for communication because it has been Aborted."

Does anyone knows why this happens?

Thanks in advance!


To be honest, I haven't had a chance to test your scenario, but that error is a general error stating something went wrong while communicating with the service (this answer is more of a comment, but it's extensive and can't fit). You could get more info by putting the following lines at the end of the <configuration> section in your web.config and app.config:

<system.diagnostics>
<trace autoflush="true" />
<sources>
  <source name="System.ServiceModel"
          switchValue="Information, ActivityTracing"
          propagateActivity="true">
    <listeners>
      <add name="sdt"
          type="System.Diagnostics.XmlWriterTraceListener"
          initializeData= "ServiceTestWCFTrace.svclog" />
    </listeners>
  </source>
</sources>

After you get the error use svc log viewer to view the log: C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\SvcTraceViewer.exe There you'll probably find the exact error that caused the Abort on the channel. Hope it helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜