假设我有一个wcf服务网络配置文件。
<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>
答案 0 :(得分:1)
此处的绑定名称
<binding name="MyAjaxBind" crossDomainScriptAccessEnabled="true" />
必须匹配
<service ...><endpoint ... bindingConfiguration="MyAjaxBind" ... /> </service>
行为名称
<behavior name="MyServiceTypeBehaviors" >
必须匹配
<service behaviorConfiguration="MyServiceTypeBehaviors">....</service>
但是,您使用的具体名称并不重要。