Due to some very specific requirements for submitting messages to the IRS, I am having to use a custom encoding to create an MTOM message. Problem is, after that encoder is done processing, the message is no longer XML since it has to create the boundaries and headers for the attachment.
This is very problematic because this custom encoding is executed PRIOR to the endpoint behavior I have configured to sign the outbound message with our X509 cert. Configuration here:
<behaviors>
<endpointBehaviors>
<behavior name="SigningBehavior">
<clientCredentials>
<clientCertificate findValue="serial goes here" x509FindType="FindBySerialNumber"
storeLocation="CurrentUser" storeName="My" />
<serviceCertificate>
<defaultCertificate findValue="serial goes here" x509FindType="FindBySerialNumber"
storeLocation="CurrentUser" storeName="My" />
<authentication certificateValidationMode="PeerTrust"/>
</serviceCertificate>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
Is there a way to have the WCF client sign and add the WS-security header BEFORE the custom encoding is executed?