我有一个休息WCF服务。它使用一个webHttpBinding,配置如下所示:
<service name="IndexingService.RestService" behaviorConfiguration="IndexingService.Service1Behavior">
<endpoint
address=""
binding="webHttpBinding"
bindingConfiguration="CustomMapper"
contract="IndexingService.IIndexingService"
behaviorConfiguration="webby"/>
</service>CustomMapper用于应用自定义WebContentTypeMapper,我尝试这样配置它:
<binding name="CustomMapper">
<webMessageEncoding webContentTypeMapperType="IndexingService.CustomContentTypeMapper, IndexingService" />
<httpTransport manualAddressing="true" />
</binding>但我不知道在我的web.config中应该在哪里插入以下几行:
。
有人能解释一下如何与webHttpBinding一起使用自定义类型映射器吗?
发布于 2009-09-12 13:23:13
如果您定义了一个完整的自定义绑定(就像在这里使用CustomMapper一样):
<binding name="CustomMapper">
<webMessageEncoding webContentTypeMapperType=
"IndexingService.CustomContentTypeMapper, IndexingService" />
<httpTransport manualAddressing="true" />
</binding>然后,您需要在服务端点中使用自定义绑定-而不是webHttpBinding!这个配置部分不只是定义一个bindingConfiguration!
在这里尝试这个配置:
<system.serviceModel>
<bindings>
<customBinding>
<binding name="CustomMapper">
<webMessageEncoding webContentTypeMapperType=
"IndexingService.CustomContentTypeMapper, IndexingService" />
<httpTransport manualAddressing="true" />
</binding>
</customBinding>
</bindings>
<services>
<service name="IndexingService.RestService"
behaviorConfiguration="IndexingService.Service1Behavior">
<endpoint
address=""
binding="customBinding"
bindingConfiguration="CustomMapper"
contract="IndexingService.IIndexingService"
behaviorConfiguration="webby"/>
</service>
</services>
</system.serviceModel>Marc
https://stackoverflow.com/questions/1415097
复制相似问题