开发者

How to apply two Endpoint Behaviors to one behavior configuration?

开发者 https://www.devze.com 2022-12-17 05:02 出处:网络
This question is a follow up to @joshperry\'s answer on CustomQueryStringConverter.I implemented this solution with a small modification.My version converts System.Int32[] instead of string[].

This question is a follow up to @joshperry's answer on CustomQueryStringConverter. I implemented this solution with a small modification. My version converts System.Int32[] instead of string[].

H开发者_如何学编程owever, I have a problem with my WCF configuration. My service dishes out SOAP, XML and JSON. SOAP wasn't a problem, this solution works for XML, but JSON is still messed up. I tried found out that the class that does JSON conversion automatically (enableWebScript behavior) is a sealed class, so I can't override it like you did for WebHttpBehavior. I also tried adding two behaviors, but that didn't work either:

    <behaviors>
      <endpointBehaviors>
        <behavior name="xmlBehavior">          
          <ArrayQuerystring />
        </behavior>
        <behavior name="jsonBehavior">                    
          <ArrayQuerystring />
          <enableWebScript />
        </behavior>
      </endpointBehaviors>      
    </behaviors>

I think it might be an ordering issue? If I put the ArrayQuerystring behavior first, I get no results. If I put it second, then I get the same results as the XML endpoint. How do I apply your CustomQuerystringConverter to a JSON endpoint?


The JSON parser already supports arrays. You can pass them on the URL line like this:

...?ID=2&includedCollections=["Addresses","Phones"]
0

精彩评论

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

关注公众号