zoukankan      html  css  js  c++  java
  • WCF之 结案陈词

    ServiceHosthost = newServiceHost(typeof(Service), http://localhost:8080/ddd);

    只适用于自托管,"http://localhost:8080/ddd"是baseAddress,也可以把地址放到配置文件中:

    ServiceHost host = new ServiceHost(typeof(Service));

          <service name="WcfServiceLibrary2.Service1" behaviorConfiguration="WcfServiceLibrary2.Service1Behavior">
            <host>
              <baseAddresses>
                <add baseAddress = "http://localhost:8080/ddd/" />
              </baseAddresses>
            </host>
            <endpoint address ="" binding="wsHttpBinding" contract="WcfServiceLibrary2.IService1">
    

    注意,不要这么设置:

    ServiceHost host = new ServiceHost(typeof(Service), "http://localhost:8080/ddd");

          <service name="WcfServiceLibrary2.Service1" behaviorConfiguration="WcfServiceLibrary2.Service1Behavior">
            <host>
              <baseAddresses>
                <add baseAddress = "http://localhost:8731/Design_Time_Addresses/WcfServiceLibrary2/Service1/" />
              </baseAddresses>
            </host>
            <endpoint address ="" binding="wsHttpBinding" contract="WcfServiceLibrary2.IService1">
    

    我测试过,运行时报错了,不能同时设置两个baseAddress,在运行ServiceHost 的ctor时,会发现baseAddress已经存在了(就是配置文件中的那个)。

    在IIS中,不需要baseAddress,我试着加了一下,发现即使加了Host和baseAddress,也不会生效。

              <identity>
                <dns value="localhost"/>
              </identity>
    

    identity这个标签,不要也罢,它是为开发阶段而设计的,deploy时remove掉。

    1.不在Client端添加Server Reference,也能得到服务么?

    如果Server端的Service不具有MEX绑定,那就不能在Client端添加Server Reference了,不信你就试试。

    在这种情况下,我们该如何在Client端得到Service呢?

    这时候,我们就要使用svcutil命令行工具,手动生成Service的代理类:

    比如说,我写了一个ClassLibrary,注意,仅仅是一个ClassLibrary,然后我添加了System.ServiceModel命名空间,定义了契约及其实现,并把它们

    3.MEX究竟是干什么用的?

    4.如果我把svc和cs代码分成两个project?

    6.究竟是App.config还是web.config?

    7.Add Service Reference只针对IIS托管么?

    8.

  • 相关阅读:
    nyoj_518_取球游戏_201404161738
    nyoj_528_找球号(三)_201404152050
    nyoj_68_三点顺序_201404152013
    nyoj_123_士兵杀敌(四)_201404131143
    树状数组
    nyoj_116_士兵杀敌(二)_201404131107
    hdu_1024_糖果大战_201404021640
    hdu_1205_吃糖果_201404021440
    nyoj_278_排队_201403282135
    nyoj_127_星际之门(一)_201403282033
  • 原文地址:https://www.cnblogs.com/Jax/p/1588866.html
Copyright © 2011-2022 走看看