配置 WCF 服务并从一台机器访问该服务到另一台机器
Configuration of WCF service and accessing that service from one machine to another
我正在尝试设置接受简单字符串值和 returns 字符串的 WCF 服务。我遵循了这里的教程 --> WCF Walkthrough 但我正在尝试做一件与示例不同的事情。我正在尝试从运行 Windows 7 的主机进行通信,其中 WcfServiceLibrary1 正在运行,我已经确认它正在与 WCF 测试客户端一起工作,并且我得到了回复 - 一切都很好。
我创建了一个 Forms 应用程序,如示例中所述,并通过在命令提示符下执行 netstat 来引用主机的本地地址。这返回了 192.168.1.104,所以我将下面的 link 插入到我的 Forms 应用程序中的 ServiceReference 中,然后找到了该服务。
http://192.168.1.104:8733/Design_Time_Addresses/WcfServiceLibrary1/Service1/mex
我在 Windows 7 机器上运行我的 WCF 服务,然后我在我的 XP 虚拟机上执行 Forms 应用程序。根据示例,我通过使用以下代码单击按钮来调用服务。
private void btnSend_Click(object sender, EventArgs e)
{
ServiceReference1.Service1Client client = new ServiceReference1.Service1Client();
string response = client.GetData(txtData.Text);
lblResponse.Text = response;
}
我收到以下错误,我不确定如何解决。
ERROR: There was no endpoint listening at http://localhost:8733/Design_Time_Addresses/WcfServiceLibrary1/Service1/ that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details. INNER EXCEPTION: No connection could be made because the target machine actively refused it 127.0.0.1:8733
令我奇怪的是为什么IP地址从我输入的以192开头的值变成了localhost。
有什么想法吗?
表单应用程序配置文件中服务引用元素的客户端部分需要更新。它看起来应该与此类似:
<client>
<endpoint address="http://192.168.1.104:8733/Design_Time_Addresses/WcfServiceLibrary1/Service1/mex" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1" contract="WcfServiceLibrary1.Service1"
name="BasicHttpBinding_IService1" />
</client>
我正在尝试设置接受简单字符串值和 returns 字符串的 WCF 服务。我遵循了这里的教程 --> WCF Walkthrough 但我正在尝试做一件与示例不同的事情。我正在尝试从运行 Windows 7 的主机进行通信,其中 WcfServiceLibrary1 正在运行,我已经确认它正在与 WCF 测试客户端一起工作,并且我得到了回复 - 一切都很好。
我创建了一个 Forms 应用程序,如示例中所述,并通过在命令提示符下执行 netstat 来引用主机的本地地址。这返回了 192.168.1.104,所以我将下面的 link 插入到我的 Forms 应用程序中的 ServiceReference 中,然后找到了该服务。
http://192.168.1.104:8733/Design_Time_Addresses/WcfServiceLibrary1/Service1/mex
我在 Windows 7 机器上运行我的 WCF 服务,然后我在我的 XP 虚拟机上执行 Forms 应用程序。根据示例,我通过使用以下代码单击按钮来调用服务。
private void btnSend_Click(object sender, EventArgs e)
{
ServiceReference1.Service1Client client = new ServiceReference1.Service1Client();
string response = client.GetData(txtData.Text);
lblResponse.Text = response;
}
我收到以下错误,我不确定如何解决。
ERROR: There was no endpoint listening at http://localhost:8733/Design_Time_Addresses/WcfServiceLibrary1/Service1/ that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details. INNER EXCEPTION: No connection could be made because the target machine actively refused it 127.0.0.1:8733
令我奇怪的是为什么IP地址从我输入的以192开头的值变成了localhost。
有什么想法吗?
表单应用程序配置文件中服务引用元素的客户端部分需要更新。它看起来应该与此类似:
<client>
<endpoint address="http://192.168.1.104:8733/Design_Time_Addresses/WcfServiceLibrary1/Service1/mex" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1" contract="WcfServiceLibrary1.Service1"
name="BasicHttpBinding_IService1" />
</client>