Transport security Mode of WCF wsHttpBinding, clientCredentialType = "Basic", wcfwshttpbinding

Source: Internet
Author: User

Transport security Mode of WCF wsHttpBinding, clientCredentialType = "Basic", wcfwshttpbinding

 

Address: http://www.cnblogs.com/jfzhu/p/4071342.html

Reprinted please indicate the source

 

For more information about how to use Transport Security Mode in WCF and how to create a certificate, see [Transport Security Mode of WCF basicHttpBinding, clientCredentialType = "None"]. This article describes how to use Basic clientCredentialType.

 

Server web. config

<?xml version="1.0"?> <configuration>     <system.web>       <compilation debug="true" targetFramework="4.0" />     </system.web>     <system.serviceModel>       <bindings>         <wsHttpBinding>           <binding name="wsHttpBindingConfig">             <security mode="Transport">               <transport clientCredentialType="Basic" />             </security>           </binding>         </wsHttpBinding>       </bindings>       <services>         <service name="WCFDemo.DemoService" behaviorConfiguration="CustomBehavior">           <endpoint address="DemoService" binding="wsHttpBinding" contract="WCFDemo.IDemoService" bindingConfiguration="wsHttpBindingConfig" />                    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>         </service>       </services>         <behaviors>             <serviceBehaviors>                 <behavior name="CustomBehavior">                     <serviceMetadata httpsGetEnabled="true" />                     <serviceDebug includeExceptionDetailInFaults="false" />                                    </behavior>             </serviceBehaviors>         </behaviors>         <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />     </system.serviceModel> </configuration>


 

<? Xml version = "1.0" encoding = "UTF-8"?> <Configuration> <system. serviceModel> <bindings> <wsHttpBinding> <binding name = "WSHttpBinding_IDemoService"> <security mode = "Transport"> <transport clientCredentialType = "Basic"/> </security> </binding> </wsHttpBinding> </bindings> <client> <endpoint address = "https://win-ounm08eqe64.henry.huang/DemoService.svc/DemoService" binding = "wsHttpBinding" bindingConfiguration = "WSHttpBinding_IDemoService" contract = "DemoServiceReference. IDemoService "name =" WSHttpBinding_IDemoService "/> </client> </system. serviceModel> </configuration>

public partial class Form1 : Form {     DemoServiceReference.DemoServiceClient demoServiceClient;    public Form1()     {         InitializeComponent();         demoServiceClient = new DemoServiceReference.DemoServiceClient();         demoServiceClient.ClientCredentials.UserName.UserName = "alex";         demoServiceClient.ClientCredentials.UserName.Password = "123456";     }    private void buttonCalculate_Click(object sender, EventArgs e)     {         try         {             textBoxResult.Text = demoServiceClient.Divide(Convert.ToInt32(textBoxNumerator.Text), Convert.ToInt32(textBoxDenominator.Text)).ToString();         }         catch (FaultException<DemoServiceReference.DivideByZeroFault> fault)         {             MessageBox.Show(fault.Detail.Error + " - " + fault.Detail.Detail);         }     } }

 

The call is successful.

 


How does wcf configure an external server? Some localhosts do not solve the problem?

This should be the server configuration, right? Do not use the class library. baseAddress is the Endpoint of the WCF Service you want to open. It is generally the local IP address + port + a name that can represent the service content. For example:

The local WCF has passed the test and is placed on another test server. The following message is displayed: "The Security Support Provider Interface (SSPI) negotiation fails." Why?

Incorrect Security Verification Mode

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.