2016-04-25 10 views
1

私はTransportWithMessageCredentialセキュリティモードを持つWCFクライアントを持っています。どのように私はクライアントに完全な生の要求をログに記録することができますクライアント側から完全な生のWCFクライアント要求をログに記録する方法は?

<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> 

セキュリティタグなし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; 
    } 

を使用して要求をログに記録しようとするには、結果を持っている場合は?このようなものでなければならない。

<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 mode="TransportWithMessageCredential"> 
    <transport clientCredentialType="None" proxyCredentialType="None" 
     realm="" /> 
    <message clientCredentialType="Certificate" algorithmSuite="Basic256" /> 
</security> 

答えて

1

を私はC#でこれを行う方法を見つけませんでしたが、 Charles SSL proxying

要求は、すべてのセキュリティが含まれているを使用して、生の要求を捕獲していましたタグ。

くれます。また、無料でFiddlerを使用することができますTracing-WCF-Messages

1

Thisを結合するためのセキュリティオプションが役立つことがあります。

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; 
} 
+0

同じ結果です。 タグにのみ、セキュリティタグなし – TNomade

+0

スープのヘッダーにセキュリティがないことが表示されます。 –

+0

セキュリティオプションが正しく追加されているかどうかを確認することができます。 –

0

そんなに助けた記事。 あなたのエンドポイントがある場合は、HTTPSフィドラーは、あなたの接続のために無効である、独自の証明書を使用しているため、この

ServicePointManager.ServerCertificateValidationCallback = delegate {return true;}; 

で証明書の検証をバイパスするようにしてください。

関連する問題