使用自定义编码器时,格式错误的MTOM(重复的Content-Type标头) [英] Malformed MTOM (duplicate Content-Type header) when using custom encoder

查看:148
本文介绍了使用自定义编码器时,格式错误的MTOM(重复的Content-Type标头)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在客户端使用自定义编码器与新服务器通信.过去,其他端点都很好地接受了我们的消息,但是与我们通信的新实现(在JAX-WS上实现)在抱怨,因为我们发送了 两个Content-Type标头,其中之一不完整-没有mime边界信息.这是我们发送的内容的有线跟踪:

I am using a custom encoder on the client side to communicate with a new server.  In the past, other endpoints have accepted our messages just fine, but a new implementation we communicate with (implemented on JAX-WS) is complaining because we send two Content-Type headers, one of which is incomplete - does not have mime boundary information. Here is a wireshark trace of what we are sending:

POST/dev-ce/wcf/respondinggateway.svc/mtom HTTP/1.1
主机:192.168.190.119
Content-Type:多部分/相关; type ="application/xop + xml"
期望:100次继续
通过:1.1 dev.myorg.org
X-Forwarded-For:192.168.190.119
X-Forwarded-Host:dev.myorg.org
X转发服务器:dev.myorg.org
连接:保持活动
内容长度:9639

MIME版本:1.0
Content-Type:multipart/related; type ="application/xop + xml"; boundary ="dfaaeaeb-d839-4884-b8d8-111975550b7e + id = 2"; start =< http://tempuri.org/0/634243983490693389>";start-info="application/soap+xml"

--dfaaeaeb-d839-4884-b8d8-111975550b7e + id = 2
内容ID:< http://tempuri.org/0/634243983490693389>
内容传输编码:8bit
内容类型:application/xop + xml; charset = utf-8; type ="application/soap + xml"

POST /dev-ce/wcf/respondinggateway.svc/mtom HTTP/1.1
Host: 192.168.190.119
Content-Type: multipart/related; type="application/xop+xml"
Expect: 100-continue
Via: 1.1 dev.myorg.org
X-Forwarded-For: 192.168.190.119
X-Forwarded-Host: dev.myorg.org
X-Forwarded-Server: dev.myorg.org
Connection: Keep-Alive
Content-Length: 9639

MIME-Version: 1.0
Content-Type: multipart/related;type="application/xop+xml";boundary="dfaaeaeb-d839-4884-b8d8-111975550b7e+id=2";start="<http://tempuri.org/0/634243983490693389>";start-info="application/soap+xml"

--dfaaeaeb-d839-4884-b8d8-111975550b7e+id=2
Content-ID: <http://tempuri.org/0/634243983490693389>
Content-Transfer-Encoding: 8bit
Content-Type: application/xop+xml;charset=utf-8;type="application/soap+xml"

... SOAP内容...

... SOAP Content ...

 

控制传出请求消息的方法只是委托给innerEncoder对象(我们已配置MtomMessageEncoder).我们只需要编码器就可以对回复进行处理.这是我们写的实现 方法和ContentType属性:

The methods that control our outgoing request message are simply delegating to the innerEncoder object (we have MtomMessageEncoder configured).  We only need the encoder to do processing on the reply.  Here are our implementations of the write method, and ContentType property:

 


    public override ArraySegment<byte> WriteMessage(Message message, int maxMessageSize, BufferManager bufferManager, int messageOffset)
    {
      //Use the inner encoder to encode a Message into a buffered byte array
      ArraySegment<byte> buffer = innerEncoder.WriteMessage(message, maxMessageSize, bufferManager, messageOffset);

      string messageContents = Utf8Encoding.GetString(buffer.Array, 0, buffer.Count);

      System.Diagnostics.Debug.WriteLine(messageContents, "Original WCF Request Message (Mtom Encoded)");

      return buffer;
    }


    public override string ContentType
    {
      get { return innerEncoder.ContentType; }
    }


推荐答案

这仍然引起我们问题.我正在努力拼凑我从Reflector所能得到的一切,但是我觉得我现在只是在旋转轮子.关于可能出什么问题或如何解决的任何想法?

This is still causing us issues.  I'm trying to piece together what I can from Reflector, but I feel like I'm just spinning my wheels at this point.  Any ideas on what might be going wrong, or how to fix it?

 

这是返回的错误:

---内部异常:级别1 ---
FaultException:由于异常而无法创建SOAP消息:javax.xml.ws.WebServiceException:找不到MIME边界参数. type ="application/xop + xml"
---内部异常列表的结尾---

--- Inner exception : Level 1 ---
FaultException: Couldn't create SOAP message due to exception: javax.xml.ws.WebServiceException: MIME boundary parameter not foundmultipart/related; type="application/xop+xml"
--- End of inner exception list ---

 

来自接收端点的反馈,即他们正在选择第一个Content-Type标头,该标头不包含Mime边界信息.如最初发布的那样:

The feedback from receiving endpoint that they are picking up the first Content-Type header, which does not contain the Mime boundary information.  As posted originally:

POST/dev-ce/wcf/respondinggateway.svc/mtom HTTP/1.1
主机:192.168.190.119
Content-Type:多部分/相关; type ="application/xop + xml"
期望:100次继续
通过:1.1 dev.myorg.org
X-Forwarded-For:192.168.190.119
X-Forwarded-Host:dev.myorg.org
X转发服务器:dev.myorg.org
连接:保持活动
内容长度:9639

MIME版本:1.0
Content-Type:multipart/related; type ="application/xop + xml"; boundary ="dfaaeaeb-d839-4884-b8d8-111975550b7e + id = 2"; start =< http://tempuri.org/0/634243983490693389>";start-info="application/soap+xml"

--dfaaeaeb-d839-4884-b8d8-111975550b7e + id = 2
内容ID:< http://tempuri.org/0/634243983490693389>
内容传输编码:8bit
内容类型:application/xop + xml; charset = utf-8; type ="application/soap + xml"

POST /dev-ce/wcf/respondinggateway.svc/mtom HTTP/1.1
Host: 192.168.190.119
Content-Type: multipart/related; type="application/xop+xml"
Expect: 100-continue
Via: 1.1 dev.myorg.org
X-Forwarded-For: 192.168.190.119
X-Forwarded-Host: dev.myorg.org
X-Forwarded-Server: dev.myorg.org
Connection: Keep-Alive
Content-Length: 9639

MIME-Version: 1.0
Content-Type: multipart/related;type="application/xop+xml";boundary="dfaaeaeb-d839-4884-b8d8-111975550b7e+id=2";start="<http://tempuri.org/0/634243983490693389>";start-info="application/soap+xml"

--dfaaeaeb-d839-4884-b8d8-111975550b7e+id=2
Content-ID: <http://tempuri.org/0/634243983490693389>
Content-Transfer-Encoding: 8bit
Content-Type: application/xop+xml;charset=utf-8;type="application/soap+xml"

... SOAP内容...

... SOAP Content ...

 

 


这篇关于使用自定义编码器时,格式错误的MTOM(重复的Content-Type标头)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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