联通VAC定制包解析userIdType和updateType数据碰到的一个问题解决
因为没有使用java平台,也就没有使用建议的axis对提供的wsdl文件做处理,所有关于数据包的解析只能自己写程序做解析处理。
华为提供的vac请求样例包request.xml
-
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://soap.bossagent.vac.unicom.com">
-
<soapenv:Header/>
-
<soapenv:Body>
-
<soap:orderRelationUpdateNotify soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
-
<orderRelationUpdateNotifyRequest xsi:type="req:OrderRelationUpdateNotifyRequest" xmlns:req="http://req.sync.soap.bossagent.vac.unicom.com">
-
<recordSequenceId xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">11</recordSequenceId>
-
<userIdType xsi:type="soapenc:int" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">1</userIdType>
-
<userId xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">1</userId>
-
<serviceType xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">1</serviceType>
-
<spId xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">1</spId>
-
<productId xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">2</productId>
-
<updateType xsi:type="soapenc:int" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">3</updateType>
-
<updateTime xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">44444444</updateTime>
-
<updateDesc xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">444</updateDesc>
-
<linkId xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">44</linkId>
-
<content xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</content>
-
<effectiveDate xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">333333</effectiveDate>
-
<expireDate xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">2222222</expireDate>
-
<time_stamp xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">3333</time_stamp>
-
<encodeStr xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">111gg</encodeStr>
-
</orderRelationUpdateNotifyRequest>
-
</soap:orderRelationUpdateNotify>
-
</soapenv:Body>
-
</soapenv:Envelope>
实际在网络上收到的数据包
-
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-
<soapenv:Body>
-
<ns1:orderRelationUpdateNotify soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://soap.bossagent.vac.unicom.com">
-
<orderRelationUpdateNotifyRequest href="#id0"/>
-
</ns1:orderRelationUpdateNotify>
-
<multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:OrderRelationUpdateNotifyRequest" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="http://req.sync.soap.bossagent.vac.unicom.com">
-
<recordSequenceId xsi:type="soapenc:string">200903181622360043</recordSequenceId>
-
<userIdType href="#id1"/>
-
<userId xsi:type="soapenc:string">8613004849965</userId>
-
<serviceType xsi:type="soapenc:string">5</serviceType>
-
<spId xsi:type="soapenc:string">90000001</spId>
-
<productId xsi:type="soapenc:string">050002</productId>
-
<updateType href="#id2"/>
-
<updateTime xsi:type="soapenc:string">20090313110400</updateTime>
-
<updateDesc xsi:type="soapenc:string"></updateDesc>
-
<linkId xsi:type="soapenc:string"></linkId>
-
<content xsi:type="soapenc:string"></content>
-
<effectiveDate xsi:type="soapenc:string">20080301000000</effectiveDate>
-
<expireDate xsi:type="soapenc:string">20100301000000</expireDate>
-
<time_stamp xsi:type="soapenc:string">0318162236</time_stamp>
-
<encodeStr xsi:type="soapenc:string"></encodeStr>
-
</multiRef>
-
<multiRef id="id2" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="soapenc:int" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">1</multiRef>
-
<multiRef id="id1" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="soapenc:int" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">1</multiRef>
-
</soapenv:Body>
-
</soapenv:Envelope>
通过对数据包的分析,可以看到在实际包里面,采用了multiRef方式,对userIdType和updateType数据的值使用了href引用,这样在分析数据包时,就同时要根据节点的href属性值来判断处理所引用的值节点,然后再遍历multiRef的节点找匹配id属性值的,从而找出正确的值所在。
——-
虽然现在解析正确了,但是没有使用标准的xml开发包工具开发,缺少开发包所做的类型验证,数据包还原等处理,如果以后接口数据格式有发生变化还是要再次进行解析代码的修改处理,不过不想只为了一个xml解析目的就为服务器添加上java的一堆环境和东西,只好先忍受着自己手工分析xml数据吧。
Popularity: 32% [?]
Random Posts
使用postfix发邮件被拒(UBE)的处理
公司邮箱发出到QQ邮件有发不出,然后收到一份主题为Considered UNSOLICITED BULK EMAIL, apparently from you的邮件:
A message fromto: -> 439386@qq.com was considered unsolicited bulk e-mail (UBE). Our internal reference code for your message is 14395-03/IiCsmVeSBHvn The message carried your return address, so it was either a genuine mail from you, or a sender address was faked and your e-mail address abused by third party, in which case we apologize for undesired notification. We do try to minimize backscatter for more prominent cases of UBE and for infected mail, but for less obvious cases of UBE some balance between losing genuine mail and sending undesired backscatter is sought, and there can be some collateral damage on both sides. First upstream SMTP client IP address: [127.0.0.1] According to a ‘Received:’ trace, the message originated at: [127.0.0.1], localhost.localdomain mail.cn [127.0.0.1] Return-Path: From: “=?GB2312?B?bWFzdGVy?=” Message-ID: <20090311013925.CBA7AB805@mail-corp.cn> Subject: =?GB2312?B?v7S/tLLZ1/fPtc2z?= Delivery of the email was stopped!
通过到提供邮件打包安装的 www.extmail.org 论坛上查找原因,发现如下解决方法。
论坛中的地址:http://www.extmail.org/forum/thread-8949-1-1.html
修改/etc/amavisd.conf配置文件
- 1. 修改$final_spam_destiny配置值
- 2.$sa_kill_level_deflt
将其从默认的D_BOUNCE修改为D_PASS
将其从默认的5.0修改为8.0,降低反垃圾邮件能力
修改完以后,执行 amavisd reload 重新应用规则。
Popularity: 25% [?]
Random Posts
linux命令后面常见的>/dev/null 和 2>&1 的含义
为了避免在开发服务器使用ftp上传代码文件,导致文件不一致问题的现象。今天做一个从版本库中自动同步文件到开发服务器的脚本,同时可以规范版本库的使用。
简单编写了一下脚本,通过ssh登陆在命令行下运行正常,可是将脚本添加到crontab中就不正常。想记录一下输出信息,分析一下错误原因。
将脚本通过使用 > info.log 重定向输出,结果发现一些在命令行下可以看到的文本信息没有记录到 info.log 文件中,研究了一下,那些输出估计是输出到了标准错误上。
研究了一下通常添加命令后面几个输出含义
- >/dev/null
- 2 > &1
输出到空设备,表示丢掉输出信息。
将输出到标准错误的信息输出到标准输出设备(通常是屏幕)
有3个默认的i/o,
- 0 是标准输入,一般是键盘
- 1 是标准输出,一般是屏幕了
- 2 是标准错误,有时候屏幕上可以看到,但是重定向的文件中看不到的就是它了
Popularity: 24% [?]
Random Posts
Nginx常见应用技术指南(Nginx Tips) - 转
Nginx 常见应用技术指南(Nginx Tips)[定期更新]
作者:NetSeek http://www.linuxtone.org(IT运维专家网|集群架构|性能调优)
欢迎转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本声明.
更新时间:[2008-12-4] 第一版:[2008-11-25]
目录:
一. Nginx基础知识
二. Nginx安装配置
三. Nginx Rewrite
四. Nginx Redirect
五. Nginx 目录自动加斜线
六. Nginx 防盗链
七. Nginx expires
八. Nginx 访问控制
九. Nginx Location
十. Nginx 日志处理
十一. Nginx Cache服务配置
十二. Nginx 负载均衡
十三. Nginx 优化
十四. Nginx 相关参考文档
Read more
Popularity: 28% [?]
Related
Web中一些不利于做缓存的因素
Web中不利于做缓存的一些因素,以及怎样尽可能的减小这些不利因素对缓存处理的影响。
- 使用SSL做通信的页面
- 使用Http验证的保护页面
- 使用Cookie的页面
- 限制使用Cookie的目录
- 对静态资源比如图片尽量不要让cookie沾上
- 使用动态内容的页面
作为安全通信,不做缓存处理,这个时候我们要考虑是否所有的页面内容都是否必须做安全通讯保护的,根据需要可以努力将一部分(如图片等)静态资源内容通过http协议走,而不是全部通过SSL协议走,这样就可以使部分没有必要通过SSL协议走的内容可以做缓存处理,减少服务器的负载和降低网络流量的使用。
这个和SSL处理有点类似,同时也可以通过 Cache-Control中的public命令来做一些控制。
一般使用Cookie是为了保存一部分个人设置信息。
在Cookie的设置中,注意domain和path值的设置,path值不设置就是默认都整个domain下的了
可以设立独立的域名做文件服务器,这样原有域上的Cookie信息就不会跟着走
可以使用头信息来设置动态内容的一些过期失效时间,但一般来说,动态内容只是一个页面中的一部分,其他大部分还是相同,可以采取模板化处理,在页面中使用嵌入脚本嵌入动态内容,这样可以方便达到部分缓存处理的目的,同时减低一些网络流量。
Popularity: 28% [?]
Related
http以trunked编码方式传输的数据表示规则
一般HTTP通信时会使用是Content-Length头信息性来指定小,但是有时候无法确定信息大小,就要使用trunked编码动态的提供body内容的长度。
进行Chunked编码传输的HTTP数据要在消息头部设置:
Transfer-Encoding: chunked
表示Content Body将用chunked编码传输内容。
Chunked编码一般使用若干个chunk串连而成,最后由一个标明长度为0的chunk标示结束。
每个chunk分为头部和正文两部分,
头部内容指定下一段正文的字符总数(非零开头的十六进制的数字)和数量单位(一般不写,表示字节).
正文部分就是指定长度的实际内容,两部分之间用回车换行(CRLF)隔开。
在最后一个长度为0的chunk中的内容是称为footer的内容,是一些附加的Header信息(通常可以直接忽略)。具体的chunk编码格式如下:
-
chunked-body = *chunk
-
"0" CRLF
-
footer
-
CRLF
-
chunk = chunk-size [ chunk-ext ] CRLF
-
chunk-data CRLF
-
hex-no-zero = <HEX excluding "0">
-
chunk-size = hex-no-zero *HEX
-
chunk-ext = *( ";" chunk-ext-name [ "=" chunk-ext-value ] )
-
chunk-ext-name = token
-
chunk-ext-val = token | quoted-string
-
chunk-data = chunk-size(OCTET)
-
footer = *entity-header
RFC文档中的chunked解码过程如下:
-
length := 0
-
read chunk-size, chunk-ext (if any) and CRLF
-
while (chunk-size > 0) {
-
read chunk-data and CRLF
-
append chunk-data to entity-body
-
length := length + chunk-size
-
read chunk-size and CRLF
-
}
-
read entity-header
-
while (entity-header not empty) {
-
append entity-header to existing header fields
-
read entity-header
-
}
-
Content-Length := length
-
Remove "chunked" from Transfer-Encoding
Popularity: 26% [?]
Random Posts
IdHttp访问返回非2XX代码的地址后Response.Stream中无数据问题解决
直接使用IdHttp编写使用WebService方式交互数据的MMS客户端,发现在正常Post数据返回200错误代码时,Response中包含Xml Soap的数据包,但是当服务端返回Http 500这样有错误代码时,Response中没有数据。
是服务端真的没有返回数据吗?使用转包工具抓了一下数据包,发现服务器端在返回 Http 500错误代码后,仍然是返回了包含错误信息的xml soap数据包的。出现这样的情况应该是IdHttp在接收数据时出错。
打开idHttp文件分析了一下,发现其在 ProcessResponse 函数中存在如下一段判断处理
-
if LResponseDigit <> 2 then
-
begin
-
result := wnGoToURL;
-
case Response.ResponseCode of
-
401:
-
….
-
407:
-
….
-
else begin
-
RaiseException;
-
end;
-
end;
-
end;
在返回值不是以2开头的时候,会直接抛掉后面接受到的数据,从而得不到想要的数据。
修改这个函数里面的子函数 RaiseException, 使其由原先的:
-
procedure RaiseException;
-
var
-
LRespStream: TStringStream;
-
LTempStream: TStream;
-
LTemp: Integer;
-
begin
-
LTemp := FHTTP.ReadTimeout;
-
FHTTP.ReadTimeout := 2000; // Lets wait 2 seconds for any kind of content
-
LRespStream := TStringStream.Create('');
-
LTempStream := Response.ContentStream;
-
Response.ContentStream := LRespStream;
-
try
-
FHTTP.ReadResult(Response);
-
raise EIdHTTPProtocolException.CreateError(Response.ResponseCode, FHTTP.ResponseText, LRespStream.DataString);
-
finally
-
Response.ContentStream := LTempStream;
-
LRespStream.Free;
-
FHTTP.ReadTimeout := LTemp;
-
end;
-
end;
变为
-
procedure RaiseException;
-
var
-
LTemp: Integer;
-
begin
-
LTemp := FHTTP.ReadTimeout;
-
FHTTP.ReadTimeout := 2000; // Lets wait 2 seconds for any kind of content
-
try
-
FHTTP.ReadResult(Response);
-
raise EIdHTTPProtocolException.CreateError(Response.ResponseCode, FHTTP.ResponseText, '');
-
finally
-
FHTTP.ReadTimeout := LTemp;
-
end;
-
end;
至此,Response.Stream中存放了返回后的数据,可以继续程序上的处理了。
Popularity: 30% [?]
