开发者

How to add Metadata support when enableWebScript is Set?

I'm trying to create wcf service hosted by ASP.NET (I did that some time ago, but now I can't...)

On this step I want to add Meta-data support. Once I've added the following endpoint to configuration:

<endpoint address="mex" behaviorConfiguration="McActivationApp.EnrollmentServiceAspNetAjaxBehavior"
 binding="mexHttpBinding" contract="IMetadataExchange" />

I've got the following error:

The endpoint at 'http://MyPcName/MCActivation/EnrollmentService.svc/mex' does not have a Binding with the None MessageVersion. 'System.ServiceModel.Description.WebScriptEnablingBehavior' is only intended for use with WebHttpBinding or similar bindings.

I've tried to change 'IMetadataExchange' contract to ''. That cause another error:

The endpoint at 'http://MyPcName/MCActivation/EnrollmentService.svc/mex' does not have a Binding with the None MessageVersion. 'System.ServiceModel.Description.Web开发者_StackOverflow中文版ScriptEnablingBehavior' is only intended for use with WebHttpBinding or similar bindings.

Please advise, how can I add support for meta data properly?


Here is full 'system.serviceModel' section.

<system.serviceModel>
 <behaviors>
   <endpointBehaviors>
    <behavior name="McActivationApp.EnrollmentServiceAspNetAjaxBehavior">
     <enableWebScript />
    </behavior>
   </endpointBehaviors>
    <serviceBehaviors>
      <behavior name="McActivationApp.EnrollmentServiceAspNetAjaxBehavior">
        <serviceMetadata httpGetEnabled="True"/>
      </behavior>
    </serviceBehaviors>
  </behaviors>
  <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
  <services>
   <service behaviorConfiguration="McActivationApp.EnrollmentServiceAspNetAjaxBehavior"
    name="McActivationApp.EnrollmentService">
    <endpoint address="" behaviorConfiguration="McActivationApp.EnrollmentServiceAspNetAjaxBehavior"
     binding="webHttpBinding" contract="McActivationApp.EnrollmentService" />
    <endpoint address="mex" behaviorConfiguration="McActivationApp.EnrollmentServiceAspNetAjaxBehavior"
     binding="mexHttpBinding" contract="McActivationApp.EnrollmentService" />
   </service>
  </services>
 </system.serviceModel>
</configuration>


What happens if you remove behaviorConfiguration="McActivationApp.EnrollmentServiceAspNetAjaxBehavior" from the service tag. I would also try giving the behaviors unique names, that might lead to some confusion.


What I did to resolve an issue: Create new WcfServiceLibrary project and analyzed it's app config.

Based on it I did the following:

<system.serviceModel>
<behaviors>
  <serviceBehaviors>
    <behavior name="McActivationApp.EnrollmentServicBehavior">
      <serviceMetadata httpGetEnabled="True"/>
      <serviceDebug includeExceptionDetailInFaults="False" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<services>
  <service name="McActivationApp.EnrollmentService" behaviorConfiguration="McActivationApp.EnrollmentServicBehavior">
    <endpoint address="" binding="webHttpBinding" contract="McActivationApp.EnrollmentService"/>
    <endpoint address="mex" binding="mexHttpBinding" contract="McActivationApp.EnrollmentService" />
  </service>
</services>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
</system.serviceModel>

The MAJOR difference is that I've moved specification of behavior configuration from service endpoints into service itself.

Also I've deleted 'endpoints' behavior and used the only 'service' endpoint

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜