0

假设我有一个 wcf 服务 web 配置文件。

<bindings>
  <webHttpBinding>
    <!-- if you cross domain,here is necessary-->
    <binding name="MyAjaxBind" crossDomainScriptAccessEnabled="true" />
  </webHttpBinding>
</bindings>
<behaviors>
  <endpointBehaviors>
    <behavior  name="WebApplication2.Service1AspNetAjaxBehavior">
       <!-- here is necessary-->
      <enableWebScript />
    </behavior>
  </endpointBehaviors>
  <serviceBehaviors >
    <behavior name="MyServiceTypeBehaviors" >
      <serviceMetadata httpGetEnabled="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>
 <!-- here is necessary-->
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
  multipleSiteBindingsEnabled="true"  />
<services>
  <service  name="WcfService1.Service1" behaviorConfiguration="MyServiceTypeBehaviors">
    <endpoint address=""  behaviorConfiguration="WebApplication2.Service1AspNetAjaxBehavior"
      binding="webHttpBinding" bindingConfiguration="MyAjaxBind" contract="WcfService1.IService" />
  </service>
</services>

例如:

    <binding name="MyAjaxBind"

“MyAjaxBind”是一个随机名称还是有一些含义?和

  <behavior name="MyServiceTypeBehaviors" >

MyServiceTypeBehaviors 是随机名称还是与项目名称有某些含义?

编辑: 另外我想知道我是否有内部无文件激活的代码,那么应该改变什么?

 <serviceActivations>
          <add service="service.wservice"
                relativeAddress="wscccService.svc"
               factory="System.ServiceModel.Activation.WebServiceHostFactory"
         />
       </serviceActivations>
4

1 回答 1

1

这里的绑定名称

<binding name="MyAjaxBind" crossDomainScriptAccessEnabled="true" />

必须匹配

<service ...><endpoint ... bindingConfiguration="MyAjaxBind" ... /> </service>

行为名称

<behavior name="MyServiceTypeBehaviors" >

必须匹配

<service behaviorConfiguration="MyServiceTypeBehaviors">....</service>

但是,您使用的具体名称并不重要。

于 2013-07-22T15:24:17.157 回答