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.

  • 相关阅读:
    26种激发人创造力的天使商标设计
    TopFreeTheme精选免费模板【20130703】
    解决插入到MySql数据库中乱码问题
    商务名片创意搜罗
    10个优质PSD文件资源下载
    TopFreeTheme精选免费模板【20130701.特别版】
    【原创】关于java对象需要重写equals方法,hashcode方法,toString方法 ,compareto()方法的说明
    谨慎使用keySet:对于HashMap的2种遍历方式比较
    有关google的guava工具包详细说明
    java消除 list重复值及交集,并集,差集
  • 原文地址:https://www.cnblogs.com/Jax/p/1588866.html
Copyright © 2011-2022 走看看