发布于 2025-01-27 10:33:21 字数 5283 浏览 1 评论 0原文

我正在尝试使用使用MTOM格式上传文档的Web服务。我使用了此自定义绑定:

    Dim myBinding As New CustomBinding()
    myBinding.Elements.Clear()
    myBinding.Elements.Add(New MtomMessageEncodingBindingElement(MessageVersion.Soap11, Encoding.UTF8))
    myBinding.Elements.Add(New HttpsTransportBindingElement() With {.TransferMode = TransferMode.Streamed})

事实是文件上传正载,我从服务中得到响应,说上传还可以,但是似乎自定义贴布无法读取响应并返回一个例外:

“错误创建错误MTOM消息的阅读器“

和内部的启动是:

“ MIME零件,带有content-id< a35854a.245c5.5f.180a95c85a5a5.n7ff5> gt;”

这是MTOM请求发送给我与Fiddler获得的WS的:

--uuid:8efb8701-5bad-4205-b58a-40fe4d0d75b2+id=2
Content-ID: <http://tempuri.org/0>
Content-Transfer-Encoding: 8bit
Content-Type: application/xop+xml;charset=utf-8;type="text/xml"

    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
        <s:Header>
            <VsDebuggerCausalityData xmlns="http://schemas.microsoft.com/vstudio/diagnostics/servicemodelsink">uIDPo6ss1HAFeW9PqjRwYpVfFJkAAAAAEWdHJBMAdU6HTEvorpDrFI/tlMXgYDlIsj9+kfCyhgYACQAA</VsDebuggerCausalityData>
        </s:Header>
        <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
            <altaDocument xmlns="http://www.openuri.org">
                <altaDoc xmlns="cat/gencat/justicia/cee/model/xmlbeans">
                    <identificacio>
                        <identificadorUsuari>111111111</identificadorUsuari>
                        <token>1182c59b-d1ee-0000-0000-29955741af001652108888340</token>
                    </identificacio>
                    <contingutDoc>
                        <xop:Include href="cid:http://tempuri.org/1/637877128927000384" xmlns:xop="http://www.w3.org/2004/08/xop/include"/>
                    </contingutDoc>
                    <nomFitxer>001_14_escrito prueba 1</nomFitxer>
                    <extensio>pdf</extensio>
                </altaDoc>
            </altaDocument>
        </s:Body>
    </s:Envelope>
--uuid:8efb8701-5bad-4205-b58a-40fe4d0d75b2+id=2
Content-ID: <http://tempuri.org/1/637877128927000384>
Content-Transfer-Encoding: binary
Content-Type: application/octet-stream

<< more document content>>

这是WS响应,自定义响应无法正确阅读:

--MIME_Boundary
Content-ID: a35854a.245cd7c5.5f.180a95c85a5.N7ff5
Content-Type: application/xop+xml; type="text/xml"; charset=utf-8
Content-Transfer-Encoding: 8bit

<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
    <env:Header/>
    <S:Body>
        <w:altaDocumentResponse xmlns:w="http://www.openuri.org">
            <xb:altaDocResposta xmlns:xb="cat/gencat/justicia/cee/model/xmlbeans">
                <xb:identificadorDoc>20220509170812_3ff837ca-23cd-49b5-ad70-1c748c76a3bf</xb:identificadorDoc>
                <xb:dataFiDisponibilitat>2022-05-10T05:08:15.031+02:00</xb:dataFiDisponibilitat>
                <xb:dadesRetorn>
                    <xb:codiRetorn>0</xb:codiRetorn>
                    <xb:descRetorn>Operació efectuada correctament.</xb:descRetorn>
                </xb:dadesRetorn>
            </xb:altaDocResposta>
        </w:altaDocumentResponse>
    </S:Body>
</S:Envelope>

--MIME_Boundary--

有什么想法,为什么我会在响应中遇到错误?

我还注意到,当我从服务中遇到错误时,我使用的自定义订阅能够使服务的响应逐渐化,响应是:

--MIME_Boundary
Content-ID: <http://tempuri.org/0>
Content-Type: application/xop+xml; type="text/xml"; charset=utf-8
Content-Transfer-Encoding: 8bit

    <?xml version="1.0" encoding="UTF-8"?>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
        <s:Header xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
            <VsDebuggerCausalityData xmlns="http://schemas.microsoft.com/vstudio/diagnostics/servicemodelsink">uIDPozqpRTQoVkZMjQKdloD5UTAAAAAASJUzd7a5+EqRgnDWlWggz02OAU3BpDJMoYtfqyJl/wgACQAA</VsDebuggerCausalityData>
        </s:Header>
        <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
            <open:altaDocumentResponse xmlns:open="http://www.openuri.org">
                <xb1:altaDocResposta xmlns:xb1="cat/gencat/justicia/cee/model/xmlbeans">
                    <xb1:codiRetorn>OSB_ERR2</xb1:codiRetorn>
                    <xb1:descripcioRetorn>Servei de CEE no disponible en aquests moments</xb1:descripcioRetorn>
                </xb1:altaDocResposta>
            </open:altaDocumentResponse>
        </s:Body>
    </soapenv:Envelope>

--MIME_Boundary--

但是有什么区别?为什么可以在没有错误的情况下处理此响应,但第一个响应却没有?例外说,“ Mime的含量为content-iD&lt; a35854a.245c5.5f.180a95c85a5a5.n7ff5&gt;找不到”, 为什么找不到,而是“ content-id: http://tempuri.org/0 ”没有产生同样的例外吗?

I'm trying to consume a web service that uses MTOM format to upload a document. I used this custom binding:

    Dim myBinding As New CustomBinding()
    myBinding.Elements.Clear()
    myBinding.Elements.Add(New MtomMessageEncodingBindingElement(MessageVersion.Soap11, Encoding.UTF8))
    myBinding.Elements.Add(New HttpsTransportBindingElement() With {.TransferMode = TransferMode.Streamed})

The thing is the file is uploaded just fine and I get the response from the service saying that the upload was OK, but it seems that the custombinding is unable to read the response and returns an exception:

"Error creating reader for MTOM message"

And the inner expcetion is:

"MIME part with Content-ID <a35854a.245cd7c5.5f.180a95c85a5.N7ff5>"

This is the MTOM request send to the WS that I obtained with fiddler:

--uuid:8efb8701-5bad-4205-b58a-40fe4d0d75b2+id=2
Content-ID: <http://tempuri.org/0>
Content-Transfer-Encoding: 8bit
Content-Type: application/xop+xml;charset=utf-8;type="text/xml"

    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
        <s:Header>
            <VsDebuggerCausalityData xmlns="http://schemas.microsoft.com/vstudio/diagnostics/servicemodelsink">uIDPo6ss1HAFeW9PqjRwYpVfFJkAAAAAEWdHJBMAdU6HTEvorpDrFI/tlMXgYDlIsj9+kfCyhgYACQAA</VsDebuggerCausalityData>
        </s:Header>
        <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
            <altaDocument xmlns="http://www.openuri.org">
                <altaDoc xmlns="cat/gencat/justicia/cee/model/xmlbeans">
                    <identificacio>
                        <identificadorUsuari>111111111</identificadorUsuari>
                        <token>1182c59b-d1ee-0000-0000-29955741af001652108888340</token>
                    </identificacio>
                    <contingutDoc>
                        <xop:Include href="cid:http://tempuri.org/1/637877128927000384" xmlns:xop="http://www.w3.org/2004/08/xop/include"/>
                    </contingutDoc>
                    <nomFitxer>001_14_escrito prueba 1</nomFitxer>
                    <extensio>pdf</extensio>
                </altaDoc>
            </altaDocument>
        </s:Body>
    </s:Envelope>
--uuid:8efb8701-5bad-4205-b58a-40fe4d0d75b2+id=2
Content-ID: <http://tempuri.org/1/637877128927000384>
Content-Transfer-Encoding: binary
Content-Type: application/octet-stream

<< more document content>>

And this is the WS response, which the custombinding is unable to properly read:

--MIME_Boundary
Content-ID: a35854a.245cd7c5.5f.180a95c85a5.N7ff5
Content-Type: application/xop+xml; type="text/xml"; charset=utf-8
Content-Transfer-Encoding: 8bit

<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
    <env:Header/>
    <S:Body>
        <w:altaDocumentResponse xmlns:w="http://www.openuri.org">
            <xb:altaDocResposta xmlns:xb="cat/gencat/justicia/cee/model/xmlbeans">
                <xb:identificadorDoc>20220509170812_3ff837ca-23cd-49b5-ad70-1c748c76a3bf</xb:identificadorDoc>
                <xb:dataFiDisponibilitat>2022-05-10T05:08:15.031+02:00</xb:dataFiDisponibilitat>
                <xb:dadesRetorn>
                    <xb:codiRetorn>0</xb:codiRetorn>
                    <xb:descRetorn>Operació efectuada correctament.</xb:descRetorn>
                </xb:dadesRetorn>
            </xb:altaDocResposta>
        </w:altaDocumentResponse>
    </S:Body>
</S:Envelope>

--MIME_Boundary--

Any ideas why I'm getting an error on the response?

I also noticed that when I get an error from the service, the custombinding I use is able to deserialize the response from the service, the response being:

--MIME_Boundary
Content-ID: <http://tempuri.org/0>
Content-Type: application/xop+xml; type="text/xml"; charset=utf-8
Content-Transfer-Encoding: 8bit

    <?xml version="1.0" encoding="UTF-8"?>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
        <s:Header xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
            <VsDebuggerCausalityData xmlns="http://schemas.microsoft.com/vstudio/diagnostics/servicemodelsink">uIDPozqpRTQoVkZMjQKdloD5UTAAAAAASJUzd7a5+EqRgnDWlWggz02OAU3BpDJMoYtfqyJl/wgACQAA</VsDebuggerCausalityData>
        </s:Header>
        <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
            <open:altaDocumentResponse xmlns:open="http://www.openuri.org">
                <xb1:altaDocResposta xmlns:xb1="cat/gencat/justicia/cee/model/xmlbeans">
                    <xb1:codiRetorn>OSB_ERR2</xb1:codiRetorn>
                    <xb1:descripcioRetorn>Servei de CEE no disponible en aquests moments</xb1:descripcioRetorn>
                </xb1:altaDocResposta>
            </open:altaDocumentResponse>
        </s:Body>
    </soapenv:Envelope>

--MIME_Boundary--

But what's the difference? Why this response can be processed without error but the first one isn't? The exception said that "MIME part with Content-ID <a35854a.245cd7c5.5f.180a95c85a5.N7ff5> not found",
why that isn't found, but the "Content-ID: http://tempuri.org/0" doesn't produce the same exception?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文