Error requesting metadata with sample about CustomToken

Hello everybody,
I'm working on a custom SecurityToken, starting from the sample provided with the Feb CTP drop (TechnologySamples\Extensibility\Security\CustomToken).

The sample works fine and my custom SecurityToken too, by the way when I try to browse, via a web browser, the service.svc in order to get metadata (HTML documentation or autogenerated WSDL) I get an error "The service encountered an error while generating metadata. See the trace files for more details.".

I turned on tracing and I saw, using SvcTraceViewer, that the error (not only in my custom SecurityToken implementation, but also in the sample one) is:

  • Exception: System.InvalidOperationException
  • Message: An exception was thrown in a call to a policy export extension. Extension: System.ServiceModel.Channels.SymmetricSecurityBindingElement Error: Specified argument was out of the range of valid values. Parameter name: parameters

Any idea about the problem

Thanks,
Paolo




Answer this question

Error requesting metadata with sample about CustomToken

  • dilibu

    What I was trying to say in my previous post is that you need to implement your own BindingElement, that means inherit directly from BindingElement. In your implementation you need to instanciate the SymmetricSecurityBindingElement in the same way the custom token sample creates it and delegate methods from your BindingElement to the SymmetricSecurityBindingElement.

    In addition to this you need to implement IPolicyExportExtension on your BindingElement and take care about security policy generation or just not generate anything. In this case you will get WSDL without any security policy in it. Since you are using custom token you will need to create your custom security policy assertion to represent the custom token in the generated policy as the WS-SecurityPolicy spec does not have assertion defined for your custom token.

    I hope this helps to clarify my previous post.

    Thanks,

    --Jan


  • Tim HK Wong

    The sample does not show how to generate service WSDL when custom token is being used. This is not goal of this custom token sample.

    Unfortunately we will not be adding any new samples to the SDK but I'll try to get a sample showing how to do this on our community web site (http://wcf.netfx3.com/).

    Cheers,

    --Jan


  • danwsc

    We are investigating the issue with the sample, and we will get back to you when the issue is resolved.

    Have you tried the sample with our more recent SDK releases

    Daniel Roth



  • wadezone

    Hi Jan,


    Your post is interesting. If we do want to use "SymmetricSecurityBindingElement" as used in the custom token sample, how do we implement solution for "IPolicyExportExtension" I tried to sub-class the SymmetricSecurityBindingElement, but it is sealed. Then I tried to sub-class SecurityBindingElement and tried to delegate all calls to internally created "SymmetricSecurityBindingElement" instance. Since "SymmetricSecurityBindingElement" has a protected method called "BuildChannelFactoryCore", even this method failed. I do not want to re-implement this method myself.


    How can I overcome the above issues in providing the implementation for "IPolicyExportExtension" on WCF provided "SymmetricSecurityBindingElement"

    Thanks.



  • Olcay

    Paolo,

    the sample is designed to work like this, the metadata generation for this sample does not work. The reason is that there is a custom token configured on the binding and WCF does not know how to generate a security policy assertion for this custom token type.

    In order to enable metadata generation you would need to implement your own binding element and use it instead of SecurityBindingElement in your binding. You would have to implement IPolicyExportExtension interface in your binding element to generate the security policy statements by yourself and delegate all other operations to a SecurityBindingElement instance.

    Unfortunately we don't provide an extensibility point in WCF v1 that would allow you to implement policy export just for your custom token, if you want to have WSDL support with binding that uses custom tokens you need to reimplement the whole security policy generation.

    Best regards,

    --Jan


  • Greg Thomas - UK

    I tried it in beta2. Please see the my question: http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=454541&SiteID=1



  • Alex-MSFT

    Is the CustomToken sample fixed in July CTP The problem was related to WSDL generation. Wondering if it is fixed



  • Error requesting metadata with sample about CustomToken