0
我有Uri模板參數中的ComplexType的服務,我已將CanConvert()和ConvertStringToValue()方法覆蓋到類MyQueryStringConverter。如何將自定義服務行爲添加到WCF配置
我需要將該行爲添加到web.config文件。
這裏是行爲
public class MyWebHttpBehavior : WebHttpBehavior
{
protected override QueryStringConverter GetQueryStringConverter(OperationDescription operationDescription)
{
return new MyQueryStringConverter();
}
}
這裏是配置文件:
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="webHttp"
maxReceivedMessageSize="20000000" >
<security mode="None">
<transport clientCredentialType = "None"/>
</security>
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="mexBehaviour">
<serviceMetadata httpGetEnabled="true"/>
<useRequestHeadersForMetadataAddress>
<defaultPorts>
<add scheme="http" port="80" />
</defaultPorts>
</useRequestHeadersForMetadataAddress>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="Service.Service1" behaviorConfiguration="mexBehaviour">
<endpoint address="" binding="webHttpBinding" contract="Service.IService1" bindingConfiguration="webHttp" behaviorConfiguration="web"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange">
</endpoint>
</service>
</services>
</system.serviceModel>
請幫助如何添加行爲。
獲取錯誤無法加載爲擴展名'MyWebHttpBehavior'註冊的類型'Service.MyWebHttpBehavior,Service,Version = 1.0.0.0,Culture = neutral'。 @Ricadro – KousiK
您必須確保名稱空間和程序集名稱正確,並且該程序集位於服務二進制文件的相同文件夾中(例如,bin文件夾)。 –
是的,所有的都是正確的。名稱空間和程序集名稱相同。 @Ricardo Pontual – KousiK