c# - Rewrite WCF binding from app.config to code -
i try rewrite wcf custom binding app.config code.
app.config
<custombinding> <binding name="cb"> <security defaultalgorithmsuite="default" authenticationmode="issuedtokenovertransport" requirederivedkeys="true" includetimestamp="true" messagesecurityversion="wssecurity11wstrust13wssecureconversation13wssecuritypolicy12basicsecurityprofile10"> <issuedtokenparameters keytype="bearerkey" tokentype="http://docs.oasis-open.org/ws/oasis-wss-saml-token-profile-1.1#samlv2.0"> <additionalrequestparameters> <trust:secondaryparameters xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512"> <trust:tokentype xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#samlv2.0</trust:tokentype> <trust:keytype xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">http://docs.oasis-open.org/ws-sx/ws-trust/200512/bearer</trust:keytype> </trust:secondaryparameters> </additionalrequestparameters> <issuer address="xxx" /> </issuedtokenparameters> <localclientsettings detectreplays="false" /> <localservicesettings detectreplays="false" /> </security> <textmessageencoding messageversion="soap12" /> <httpstransport /> </binding> </custombinding>
code:
var binding = new custombinding(); var issuedtokenparameters = new issuedsecuritytokenparameters(); issuedtokenparameters.keytype = securitykeytype.bearerkey; issuedtokenparameters.tokentype = "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#samlv2.0"; xnamespace trust = "http://docs.oasis-open.org/ws-sx/ws-trust/200512"; var secondaryparameters = new xelement(trust + "secondaryparameters", new xelement(trust + "tokentype") { value = "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#samlv2.0" }, new xelement(trust + "keytype") { value = "http://docs.oasis-open.org/ws-sx/ws-trust/200512/bearer" }); issuedtokenparameters.additionalrequestparameters.add(secondaryparameters.toxmlelement()); issuedtokenparameters.issueraddress = new endpointaddress("xxx"); var securityelement = securitybindingelement.createissuedtokenovertransportbindingelement(issuedtokenparameters); securityelement.defaultalgorithmsuite = securityalgorithmsuite.default; securityelement.includetimestamp = true; securityelement.messagesecurityversion = messagesecurityversion.wssecurity11wstrust13wssecureconversation13wssecuritypolicy12basicsecurityprofile10; securityelement.localclientsettings.detectreplays = false; securityelement.localservicesettings.detectreplays = false; binding.elements.add(securityelement); binding.elements.add(new textmessageencodingbindingelement()); binding.elements.add(new httpstransportbindingelement()); return binding;
code binding not because when call service error:
system.servicemodel.faultexception: message action '' cannot processed @ receiver, due contractfilter m ismatch @ endpointdispatcher. may because of either contract mismatch (mismatched actions between sender , r eceiver) or binding/security mismatch between sender , receiver. check sender , receiver have same co ntract , same binding (including security requirements, e.g. message, transport, none).
any advice? can not find wrong or missing in code binding.
Comments
Post a Comment