带附件内容的Soap数据包格式分析

MMS彩信发送在正常的soap xml包体外还需要附加彩信数据,经过抓包分析,发现采用 multipart/related 方式发送。
start部分发送的是Soap的数据包,其他为附加的彩信文件, 采用头部的boundary设定来做多块数据的分隔。
一个抓下来的部分包
post的header头部分

POST /wespa_mms/services/SendMessage HTTP/1.1
Content-Type: multipart/related; boundary=MIMEBoundaryurn_uuid_31E20DB13F6FA8BB9A1234336210043;
  type="text/xml"; start="<0.urn:uuid:31E20DB13F6FA8BB9A1234336210044@apache.org>"
SOAPAction: ""
User-Agent: Axis2
Host: 127.0.0.1:5555
Transfer-Encoding: chunked

post的数据体部分

--MIMEBoundaryurn_uuid_31E20DB13F6FA8BB9A1234336210043
Content-Type: text/xml; charset=UTF-8
Content-Transfer-Encoding: 8bit
Content-ID: <0.urn:uuid:31E20DB13F6FA8BB9A1234336210044@apache.org>

<?xml version='1.0' encoding='UTF-8'?>xml包体内容
--MIMEBoundaryurn_uuid_31E20DB13F6FA8BB9A1234336210043
Content-Type: text/plain
Content-Transfer-Encoding: binary
Content-ID: <att_file2>

file2文件内容
--MIMEBoundaryurn_uuid_31E20DB13F6FA8BB9A1234336210043
Content-Type: text/plain
Content-Transfer-Encoding: binary
Content-ID: <file_1>

file_1文件内容
--MIMEBoundaryurn_uuid_31E20DB13F6FA8BB9A1234336210043--

Popularity: 6% [?]

Related

Indy 的 ReadTimeOut 设置失效?

最近在做MMS彩信接口程序,因为不使用Java平台,运营商所提供的Java版的MMS开发包无用,只好按照通信协议用indy直接连接服务端发送拼装好的数据封包来做处理。

为了将自己程序发出的封包和使用java开发包发出的数据包做对比,使用indy做了一个简单的tcpserver来接收发出的封包数据做保存。发现设置的ReadTimeOut设置无效,到了设置的超时时间仍然会处于阻塞状态,只有连接断开才可以继续下去。

网上搜索了一下,发现这个问题是Indy早期版本存在的Bug,indy采用的是阻塞模式,如果Server端未返回信息,这个readln会一直等下去,设置的TimeOut不会起作用(处于死循环中,没有跳出条件),是个BUG。
INDY团队给出的解决办法如下:
第一种:
对ReadFromStack函数的最后一小段做修改:

until   (LByteCount   <>   0)   or   (Connected   =   False);

修改为:

until   (LByteCount   <>   0)   or   (Connected   =   False)   or   (Result  =   -1);

第二种:
在  ReadFromStack()  的后面 // TimeOut 后面位置

//   Timeout
if   ARaiseExceptionOnTimeout   then   begin
raise   EIdReadTimeout.Create(RSReadTimeout);
end;
Result   :=   -1;

修改为:

//   Timeout
Result   :=   -1;   //   MOVED!
if   ARaiseExceptionOnTimeout   then   begin
raise   EIdReadTimeout.Create(RSReadTimeout);
end   else   //   ADDED!
break;   //   ADDED!

按照以上方法中的一个做了修改,再次接受数据内容,不会处于死等问题。

Popularity: 6% [?]

Related