当前位置:编程学习 > C#/ASP.NET >>

WCF 部署在WindowsService 上 求助

刚学 WCF,有几个问题想请教
请问WCF服务的APP.CONFIG 和 做的windows service的app.config,两者需要注意什么吗?
我将WCF部署在WindowsService 上.service 也已经可以正常启动,但是在调用的时候报错.


我怀疑service的那个app.config 档案内容有问题,但是我找不出来啊.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <connectionStrings>
    <!--业务数据库链接字符串-->
    <add name="SQLServerConnectionString"
         connectionString="Data Source=devwfvm1\bpmdev;Initial Catalog=Diodes_UUM2;Persist Security Info=True;User ID=sa;Password=pass!"
         providerName="using System.Data.SqlClient;"/>
  </connectionStrings>
  <appSettings>
    <add key="LogPath" value="E:\"/>
  </appSettings>
  <system.web>
    <compilation debug="true" />
  </system.web>
  <!-- 部署服务库项目时,必须将配置文件的内容添加到 
  主机的 app.config 文件中。System.Configuration 不支持库的配置文件。-->
  <system.serviceModel>
    <services>
      <service name="Diodes.BPMService.ADHelper" behaviorConfiguration="Diodes.BPMService.ADHelperBehavior">
        <endpoint address="" binding="wsHttpBinding" bindingConfiguration="wsHttpBindingConfiguration" contract="Diodes.BPMService.BPMInterface.IADHelper">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8732/ADHelper" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name ="Diodes.BPMService.ADHelperBehavior">
          <!-- 为避免泄漏元数据信息,
          请在部署前将以下值设置为 false 并删除上面的元数据终结点  -->
          <serviceMetadata httpGetEnabled="True"/>
          <!-- 要接收故障异常详细信息以进行调试,
          请将以下值设置为 true。在部署前设置为 false 
            以避免泄漏异常信息-->
          <serviceDebug includeExceptionDetailInFaults="True" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <wsHttpBinding>
        <binding name="wsHttpBindingConfiguration" maxReceivedMessageSize="20971510">
          <readerQuotas maxStringContentLength="20971520" maxArrayLength="20971520"/>
          <security mode="None" />
        </binding>
      </wsHttpBinding>
      <basicHttpBinding>
        <binding name="ADServiceSoap" closeTimeout="00:05:00" openTimeout="00:05:00"
            receiveTimeout="00:10:00" sendTimeout="00:05:00" allowCookies="false"
            bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
            maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
            messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
            useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
              maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
                realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
  </system.serviceModel>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v2.0"/>
  </startup>
</configuration>
--------------------编程问答-------------------- 服务能启动不一定WCF正常运行,首先判断下问题在发布的服务上还是客户端,用WCF Test Client测试下服务是不是可以正确调用,如果能调用那就是客户端的问题,如果不能就是服务端的问题。看这个报错我感觉是客户端的配置问题,具体得你自己查找。 --------------------编程问答-------------------- 一般来说,问题不大,因为app.config的写法,其实msdn都有的。你在网上查找一下就是了。
一般不会出错。对于wshttpbinding,你可以使用vs2010的wcf测试工具,测试一下。客户端的话,你可以单步调测就可以了。我觉得, 主要还是看你封装的类,是不是正确了。
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,