检查 WCF SOAP 消息负载 [英] Inspect WCF SOAP message payload

查看:22
本文介绍了检查 WCF SOAP 消息负载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在调试 WCF SOAP 客户端.我可以修改客户端,但对服务器没有任何控制权.我想检查发送和接收的实际消息,以找出在客户端发送时在 SoapUI 中工作的消息失败的原因.

I am debugging a WCF SOAP client. I can modify the client, but don't have any control over the server. I would like to inspect the actual messages sent and received in order to find out why a message which works in SoapUI fails when sent by the client.

通信是通过 SSL 进行的,因此我无法使用 Wireshark 来检查线路上的消息.

The communication is over SSL, so I can't use Wireshark to inspect the messages on the wire.

我已启用 wcf 跟踪(使用 logEntireMessage="true"),但是虽然记录了大量数据,但似乎并未记录实际的响应负载.它在跟踪查看器中仅显示为... stream ...".此外,我似乎无法在跟踪中找到传出消息的 HTTP 标头.

I have enabled wcf tracing (with logEntireMessage="true"), but while an enormous amount of data is logged, the actual response payload does not seem to be logged. It is just shown as "... stream ..." in Trace Viewer. Also I cant seem to find the HTTP headers for the outgoing message in the trace.

有人知道如何更接近检查实际消息吗?

Anybody have an idea how to get closer to inspecting the actual messages?

Fiddler 帮我找到了问题.(这是有效负载中的 UTF-8 字节顺序标记,服务器不喜欢.)另一方面,WFC 跟踪太高级",无法发现此类问题,据我所知.

Fiddler helped me find the problem. (It was a UTF-8 byte order mark in the payload, that the server didn't like.) WFC tracing on the other hand is too "high level" to find this kind of problem, as far as I can tell.

推荐答案

一种选择是使用 Fiddler.另一种选择是 WCF 日志记录(如您所说),确保在传输和消息级别标记为日志.以下是对我有用的方法:

One option is to use Fiddler. Another option is WCF logging (as you said), make sure you mark to log at both transport and message level. Here's what works for me:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.diagnostics>
        <sources>
            <source name="System.ServiceModel.MessageLogging" switchValue="Warning, ActivityTracing">
                <listeners>
                    <add type="System.Diagnostics.DefaultTraceListener" name="Default">
                        <filter type="" />
                    </add>
                    <add name="ServiceModelMessageLoggingListener">
                        <filter type="" />
                    </add>
                </listeners>
            </source>
        </sources>
        <sharedListeners>
            <add initializeData="C:\messages.svclog"
                type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
                name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp">
                <filter type="" />
            </add>
        </sharedListeners>
    </system.diagnostics>
    <system.serviceModel>
        <diagnostics>
            <messageLogging logEntireMessage="true" logMalformedMessages="true"
                logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" />
        </diagnostics>
    </system.serviceModel>
</configuration>

这篇关于检查 WCF SOAP 消息负载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆