C# 当有';这是个例外吗?

C# 当有';这是个例外吗?,c#,.net,xml,soap,xmlexception,C#,.net,Xml,Soap,Xmlexception,我想在文件中写入System.ServiceModel.Channels.Message类型的请求的内容,即使因为XML异常而无法读取它 例如:我调用request.CreateBufferedCopy(int.MaxValue)其中请求是我的频道。我收到的消息返回以下错误: System.Xml.XmlException: The token '>' was expected but found 'a'. Line 80, position 19. at System.Xml.Xm

我想在文件中写入System.ServiceModel.Channels.Message类型的请求的内容,即使因为XML异常而无法读取它

例如:我调用
request.CreateBufferedCopy(int.MaxValue)其中请求是我的频道。我收到的消息返回以下错误:

System.Xml.XmlException: The token '>' was expected but found 'a'. Line 80, position 19.
   at System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader reader, String res, String arg1, String arg2, String arg3)
   at System.Xml.XmlExceptionHelper.ThrowTokenExpected(XmlDictionaryReader reader, String expected, Char found)
   at System.Xml.XmlUTF8TextReader.ReadEndElement()
   at System.Xml.XmlUTF8TextReader.Read()
   at System.Xml.XmlBinaryWriter.WriteTextNode(XmlDictionaryReader reader, Boolean attribute)
   at System.Xml.XmlDictionaryWriter.WriteNode(XmlDictionaryReader reader, Boolean defattr)
   at System.ServiceModel.Channels.ReceivedMessage.OnWriteBodyContents(XmlDictionaryWriter writer)
   at System.ServiceModel.Channels.Message.OnWriteMessage(XmlDictionaryWriter writer)
   at System.ServiceModel.Channels.Message.OnCreateBufferedCopy(Int32 maxBufferSize, XmlDictionaryReaderQuotas quotas)
   at System.ServiceModel.Channels.Message.CreateBufferedCopy(Int32 maxBufferSize)
我希望能够将请求的内容写入一个文件中,这样我就可以看到实际的问题是什么。(这是一个简单的例子,但我想写这个文件可能还有其他原因)

我尝试使用
BinaryFormatter
在字节数组中转换我的请求,但通道。消息不可序列化


这是我测试的请求,我接受了一个有效的soap请求,并删除了
末尾的一个“>”,你如何调用你的服务,你能提供准确的消息吗?这是一个从外部调用的服务。所以我们不知道我们可能会收到什么,这就是我们想要记录的。在这个例子中,我在请求中删除了一个'>',我希望能够在收到请求时写入请求,这样我就可以在没有'>'的情况下查看我的请求。你找到解决方案了吗?不,对不起,我不再在那个地方工作了。你如何调用你的服务,你能提供确切的消息吗?这是一个从外部调用的服务。所以我们不知道我们可能会收到什么,这就是我们想要记录的。在本例中,我在请求中删除了一个“>”,我希望能够在收到请求时写入请求,这样我就可以在没有此“>”的情况下查看我的请求。您是否找到了解决方案?不,对不起,我不再在那个地方工作了
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
    <Security s:actor="IntervenantEmetteur" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
        <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
            <SignatureValue>ofb/GTvjhT5Jqyl5x2D</SignatureValue>
        </Signature>
    </Security>
</s:Header>
<s:Body wsu:Id="_0" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
    <PRPA_IN1 xmlns="urn:hl7-org:v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:hl7-org:v3 ../PRP1.xsd"
ITSVersion="XML_1.0">
        <id root="BB7321A1-33" />
        <creationTime value="20070" />
        <receiver typeCode="RCV">
            <device classCode="DEV" determinerCode="INSTANCE">
                <id root="2.16.124" extension="RU" use="BUS" />
            </device>
        </receiver>
        <sender typeCode="SND">
            <device classCode="DEV" determinerCode="INSTANCE">
                <id root="2.16.124.10." extension="APPTEST" />
                <name>App</name>
            </device>
        </sender>
        <controlActEvent classCode="CACT" moodCode="EVN">
            <responsibleParty typeCode="RESP" contextControlCode="AP">
                <assignedEntity classCode="ASSIGNED">
                </assignedEntity>
            </responsibleParty>
            <author typeCode="AUT" contextControlCode="AP">
            </author>
            <location typeCode="LOC" contextControlCode="AP">
            </location>
            <queryByParameter>
                <queryId root="BB7321A1-3" />
                <parameterList>
                </parameterList>
            </queryByParameter>
        </controlActEvent
    </PRPA_IN1>
</s:Body>