0
我是通過2程序回覆,直到當前的消息完成處理
第一(WCF服務)的web.config
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name ="svcbh">
<serviceDiscovery>
<announcementEndpoints>
<endpoint kind="udpAnnouncementEndpoint"></endpoint>
</announcementEndpoints>
</serviceDiscovery>
<serviceMetadata httpGetEnabled="False"/>
<serviceDebug includeExceptionDetailInFaults="False"/>
</behavior>
</serviceBehaviors>
</behaviors>
<!--<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />-->
<services>
<service name ="WCF.Service.Service1" behaviorConfiguration ="svcbh" >
<host>
<baseAddresses>
<add baseAddress = "http://localhost:9000/Service1/" />
</baseAddresses>
</host>
<endpoint name ="duplexendpoint"
address =""
binding ="wsDualHttpBinding"
contract ="WCF.Service.IService1"/>
<endpoint name ="MetaDataTcpEndpoint"
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"/>
</service>
</services>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
和我的客戶項目(應用程序創建一個WCF服務項目的.config)
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<wsDualHttpBinding>
<binding name="SecureBinding">
<security mode="Message">
<message clientCredentialType="Windows" />
</security>
</binding>
<binding name="duplexendpoint" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false"
transactionFlow="false" maxBufferPoolSize="524288" maxReceivedMessageSize="1073741824"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" />
<binding name="duplexendpoint1" />
</wsDualHttpBinding>
</bindings>
<client>
<endpoint address="http://92.168.1.199:9000/Service1/" binding="wsDualHttpBinding"
bindingConfiguration="duplexendpoint" contract="ServiceReference1.IService1"
name="duplexendpoint">
<identity>
<userPrincipalName value="[email protected]" />
</identity>
</endpoint>
<endpoint address="http://localhost:9000/Service1/" binding="wsDualHttpBinding"
bindingConfiguration="duplexendpoint1" contract="ServiceReference1.IService1"
name="duplexendpoint1">
<identity>
<userPrincipalName value="MyName" />
</identity>
</endpoint>
</client>
</system.serviceModel>
<appSettings>
<add key="connectionstring" value="Provider=SQLOLEDB.1;Password=a;Persist Security Info=True;User ID=sa;Initial Catalog=Serita;Data Source=.;" />
</appSettings>
</configuration>
我運行它成功ñ本地運行 但我遇到了域名,我討厭梅託德proxy.open();開放代理 代碼
public partial class HQMSSyncForm : Form, IService1Callback
{
Service1Client proxy;
public HQMSSyncForm()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
try
{
InstanceContext context = new InstanceContext(this);
proxy = new Service1Client(context);
proxy.Open(); // Error this Line
proxy.RegisterClient();
ClinicService.Instance.SetConnectionString(ConfigurationSettings.AppSettings["connectionstring"]);
}
catch (Exception ex)
{
MessageBox.Show("Error in HQMS is : " + ex.Message);
}
}