• 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.

  • 相关阅读:
    iOS学习22之视图控制器
    操作系统
    UITableView总结
    IOS-- UIView中的坐标转换
    iOS UIPopoverView的使用
    真机调试(A valid provisioning profile for this executable was not found.)
    svn 命令
    Github使用总结(添加ssh-key,新建仓库,添加协作者) 转
    swift(五)swift的函数
    swift(四)swift的广义匹配
  • 原文地址:https://www.cnblogs.com/Jax/p/1588866.html
Copyright © 2020-2023  润新知