服务器端配置文件
<?xml version="1.0" encoding="utf-8" ?> <configuration> <system.serviceModel> <services> <service name="SampleContract.Bird" behaviorConfiguration="Messagebehavior"> <host> <baseAddresses> <add baseAddress = "http://localhost:23451/SampleContract/" /> </baseAddresses> </host> <endpoint address="" binding="wsHttpBinding" contract ="SampleContract.IFly" bindingConfiguration="WSHttpBinding_IFly"> </endpoint> </service> </services> <bindings> <wsHttpBinding> <binding name="WSHttpBinding_IFly"> <security mode="None"></security> </binding> </wsHttpBinding> </bindings> <behaviors> <serviceBehaviors> <behavior name="Messagebehavior"> <serviceMetadata httpGetEnabled="true"></serviceMetadata> <serviceDebug includeExceptionDetailInFaults="true"></serviceDebug> </behavior> </serviceBehaviors> </behaviors> </system.serviceModel> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" /> </startup> </configuration>
客户端配置文件
<?xml version="1.0" encoding="utf-8" ?> <configuration> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" /> </startup> <system.serviceModel> <bindings> <wsHttpBinding> <binding name="WSHttpBinding_IFly"> <security mode="None"></security> </binding> </wsHttpBinding> </bindings> <client> <endpoint address="http://192.168.0.106:23451/SampleContract/" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IFly" contract="MyServiceReference2.IFly" name="WSHttpBinding_IFly"> <identity> <userPrincipalName value="LAPTOP-UUEOUOBAlex" /> </identity> </endpoint> </client> </system.serviceModel> </configuration>