c# - How to log full raw WCF client request from client side? -
i have wcf client transportwithmessagecredential security mode. when try log request using beforesendrequest
public object beforesendrequest(ref message request, iclientchannel channel) { system.io.streamwriter file = new system.io.streamwriter("c:\\tmp\\request_log.xml"); file.writeline(request.tostring()); file.close(); return null; }
have result without security tags
<s:envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:header> <action s:mustunderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">https://(skiped)</action> </s:header> <s:body> ... </s:body> </s:envelope>
how can log full raw request in client? must this
<s:envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> <s:header> <o:security s:mustunderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> <u:timestamp u:id="_0"> <u:created>...</u:created> <u:expires>..</u:expires> </u:timestamp> <o:binarysecuritytoken> <!-- removed--> </o:binarysecuritytoken> <signature xmlns="http://www.w3.org/2000/09/xmldsig#"> <signedinfo> ... </signedinfo> <signaturevalue>...</signaturevalue> <keyinfo> <o:securitytokenreference> ... </o:securitytokenreference> </keyinfo> </signature> </o:security> <action s:mustunderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">skiped</action> </s:header> <s:body> ... </s:body> </s:envelope>
upd. security options binding
<security mode="transportwithmessagecredential"> <transport clientcredentialtype="none" proxycredentialtype="none" realm="" /> <message clientcredentialtype="certificate" algorithmsuite="basic256" /> </security>
this may help:
public object beforesendrequest(ref message request, iclientchannel channel) { messagebuffer buffer = request.createbufferedcopy(int32.maxvalue); request = buffer.createmessage(); log("request:" + environment.newline + buffer.createmessage()); return null; }
Comments
Post a Comment