如何使用使用自托管方法的远程wcf服务 [英] how to consume the remote wcf service that uses self hosting approach

查看:93
本文介绍了如何使用使用自托管方法的远程wcf服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个wcf服务并托管在我自己的计算机上。如果我在同一台计算机上使用该服务,它工作正常,但如果我尝试从另一台计算机上使用该服务,则显示错误...主机和客户端的配置文件附在下面...我应该在配置中更改为什么从局域网中的其他计算机上使用此服务







客户端配置文件:



i have created a wcf service and hosted in my own computer . it is working fine if i consume that service in the same computer but if i try to consume that service from another computer it shows error ... configuration files of host and client is attached below ... what should i change in the configuration to consume this service from other computer in local area network



client configuration file :

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <services />
        <bindings>
            <wsHttpBinding>
                <binding name="configration" />
            </wsHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://192.168.1.167:8732/Design_Time_Addresses/WcfServiceLibrary1/Service1/"

                binding="wsHttpBinding" bindingConfiguration="configration"

                contract="ServiceReference1.IService1" name="configration">
                <identity>
                    <dns value="192.168.1.167" />
                </identity>
            </endpoint>
        </client>
    </system.serviceModel>
</configuration>







主机配置文件:








host configuration file :


<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <system.web>
    <compilation debug="true" />
  </system.web>
  <!-- When deploying the service library project, the content of the config file must be added to the host's 
  app.config file. System.Configuration does not support config files for libraries. -->
  <system.serviceModel>
    <services>
      <service behaviorConfiguration="WcfServiceLibrary1.Service1Behavior"

        name="WcfServiceLibrary1.Service1">
        <endpoint address="" binding="wsHttpBinding" name="configration"

          contract="WcfServiceLibrary1.IService1">
          <identity>
            <dns value="192.168.1.167" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://*:8732/Design_Time_Addresses/WcfServiceLibrary1/Service1/" />
          </baseAddresses>
          <timeouts openTimeout="00:10:00" />
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="WcfServiceLibrary1.Service1Behavior">
          <!-- To avoid disclosing metadata information, 
          set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="True"/>
          <!-- To receive exception details in faults for debugging purposes, 
          set the value below to true.  Set to false before deployment 
          to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

</configuration>

< br $>








我得到的错误是..... .........



您的申请中发生未处理的异常。无法连接到http://192.168.1.99/Design_Time_Address/WcfServiceLibrary1/Service1 /.Tcp错误代码10060:连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立的连接失败,因为连接的主机无法响应192.168.1.99:8732






the error i am getting is..............

unhandled exception has occurred in your application .could not connect to http://192.168.1.99/Design_Time_Address/WcfServiceLibrary1/Service1/.Tcp error code 10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to repond 192.168.1.99:8732

推荐答案

确保两台计算机都在局域网中连接并展示了相同的IP地址192.168.1。(任何东西)。

你可以再做一件事......用netTCP绑定再创建一个端点尝试。另外,请在访问其他计算机上的服务时发布您获得的错误。
Make sure that both computers are connected in LAN and exhibit in the same IP address that is 192.168.1.(anything).
You can do one more thing... Create one more endpoint with netTCP binding and then try. Also please post the error you are getting while accessing the service on other computer.


这篇关于如何使用使用自托管方法的远程wcf服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆