从IIS使用WCF服务

时间:2013-06-20 10:44:27

标签: wcf iis windows-mobile

我在WCF Service Library中创建了VS2012并将其加载到我当地的IIS
我的客户端是Windows-Mobile 6.5设备,客户端的配置文件是使用netcfsvcutil.exe生成的。在调试期间,一切工作都很顺利但是当我将服务上传到外部IIS时,即使There was no endpoint listening...从外部URL生成了文件,我仍然会收到netcfsvcutil.exe异常。这是位于远程服务器上的web.config文件:

<system.serviceModel>
<bindings>
  <basicHttpBinding>
    <binding name="TestBinding" receiveTimeout="00:01:00" sendTimeout="00:01:00">
      <security mode="None" />
    </binding>
  </basicHttpBinding>
</bindings>
<services>
  <service name="MyService.CollectionService">
    <endpoint address="" binding="basicHttpBinding" contract="MyService.ICollectionService" bindingConfiguration="TestBinding">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8733/Design_Time_Addresses/MyService/CollectionService/" />
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior>
      <serviceMetadata httpGetEnabled="True" />
      <serviceDebug includeExceptionDetailInFaults="True" />
    </behavior>
  </serviceBehaviors>
</behaviors>

,客户端端点生成如下:

public static System.ServiceModel.EndpointAddress EndpointAddress = 
    new System.ServiceModel.EndpointAddress("http://1.2.3.4/MyService/MyService.CollectionService.svc");

当我将服务上传到外部IIS时,我没有进行任何配置更改,我只是复制了&amp;将文件从一个虚拟目录粘贴到另一个虚拟目录。 可能有帮助的一点是异常是在没有任何超时的情况下引发的。

1 个答案:

答案 0 :(得分:1)

基地址路径和端口与客户端配置中的端点地址不匹配。

您的配置中的地址:http://localhost:8733/Design_Time_Addresses/MyService/CollectionService/"

您的终端中的地址:

http://1.2.3.4/MyService/MyService.CollectionService.svc

您需要将端点代码更改为

public static System.ServiceModel.EndpointAddress EndpointAddress = new System.ServiceModel.EndpointAddress("http://1.2.3.4:8733/Design_Time_Addresses/MyService/CollectionService");