1

我一直在尝试使用 WCF 服务部署我的 Silverlight 应用程序,并且在调用该服务时不断收到通信错误。我希望大家看看我的配置文件,看看你们是否发现任何不合适的地方。我的 WCF 服务位于同一个项目中。

网络配置

<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="PCCWITCGenerator.Web.Services.ITCGeneratorService.customBinding0"
                 closeTimeout="03:00:00"
                 openTimeout="03:00:00"
                 receiveTimeout="03:00:00"
                 sendTimeout="03:00:00">
        </binding>
      </basicHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ITCGeneratorService">
          <serviceMetadata httpGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service behaviorConfiguration="ITCGeneratorService" name="ITCGeneratorService">
        <endpoint address="/ITCGeneratorService/"
                  binding="basicHttpBinding"
                  bindingConfiguration="PCCWITCGenerator.Web.Services.ITCGeneratorService.customBinding0"
                  contract="PCCWITCGenerator.Web.Services.ITCGeneratorService">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
        <host>
          <baseAddresses>
            <add    baseAddress="http://localhost:38095/ITCGeneratorService/PCCWITCGenerator.Web.Services.ITCGeneratorService.svc"/>
          </baseAddresses>
        </host>
      </service>
    </services>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

ServiceReferences.ClientConfig

<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="CustomBinding_ITCGeneratorService" closeTimeout="03:00:00"
                    openTimeout="03:00:00" receiveTimeout="03:00:00" sendTimeout="03:00:00"
                    maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"/>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://10.30.20.58:38095/ITCGeneratorService/PCCWITCGenerator.Web.Services.ITCGeneratorService.svc"
                binding="basicHttpBinding" bindingConfiguration="CustomBinding_ITCGeneratorService"
                contract="ITCGeneratorServiceReference.ITCGeneratorService"
                name="CustomBinding_ITCGeneratorService" />
        </client>
    </system.serviceModel>
</configuration>

客户端访问策略.xml

<?xml version="1.0" encoding="utf-8"?>
<access-policy>
  <cross-domain-access>
    <policy>
      <allow-from http-request-headers="SOAPAction">
        <domain uri="http://*"/>
      </allow-from>
      <grant-to>
        <resource path="/" include-subpaths="true"/>
        <socket-resource port="38095" protocol="tcp" />
      </grant-to>
    </policy>
  </cross-domain-access>
</access-policy>
4

0 回答 0