2013-06-13

SAP PI 7.31 SOAP receiver adapter不能正常发送数据

在SAP PI 7.31 AEX (SP4)下一个简单的IDoc ->SOAP 的应用场景,其中SOAP receiver adapter使用HTTPS,验证使用用户名和密码的方式。在测试环境中运行正常,但是移到生产环境就不能发送数据到接收方了。

在没有部署接收方的SSL证书之前,得到错误:
Peer certificate rejected by ChainVerifier。
在导入SSL证书链(一共三个)并重启SSL provider之后,这个错误没有了,不过却得到另一个错误:

Failed to call the endpoint: Error in call over HTTP: HTTP 400 Bad Request
SOAP: call failed: java.io.IOException: invalid content type for SOAP: TEXT/HTML; HTTP 400 Bad Request
SOAP: error occured: com.sap.engine.interfaces.messaging.api.exception.MessagingException: java.io.IOException: invalid content type for SOAP: TEXT/HTML; HTTP 400 Bad Request
MP: exception caught with cause com.sap.engine.interfaces.messaging.api.exception.MessagingException: java.io.IOException: invalid content type for SOAP: TEXT/HTML; HTTP 400 Bad Request

尝试修改SOAP adapter指向测试环境的接收方和相应的用户名+密码,一切正常。在SAP PI的测试环境下发送数据到接收方的生产环境,得到的错误与上面一样。可是用SOAP UI 4.51却能正常发送同样payload的数据到接收方。

正常工作:
SAP PI QA   -->  Receiver QA
SAP PI Prod --> Receiver QA
SOAP UI       --> 
Receiver Prod

不能工作:
SAP PI QA   -->  Receiver Prod
SAP PI Prod --> Receiver Prod


查看了SOAP FAQ note 856597,里面提到:
For SOAP adapter initialization problem, component com.sap.aii.af.mp.soap must be set to DEBUG. For runtime problem, additionally component com.sap.aii.messaging must be set to DEBUG.
可是找半天却不知如何设置com.sap.aii.af.mp.soapcom.sap.aii.messaging成DEBUG模式。网上提到的多是使用visual adaministrator,适用于低一点版本的PI。

自己无法设置tcp gateway去查看SOAP请求,请求接收方安装了一个程序来查看SOAP adapter发出的请求,发现了问题的原因。接收方返回的应答是:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">

<html>
<head>
    <title>400 Bad Request</title>
</head>
<body>
    <h1>Bad Request</h1>
    <p>
        Your browser sent a request that this server could not understand.
        <br />
        Request header field is missing ':' separator.
        <br />
        <pre>OA==</pre>
    </p>
    <hr>
    <address>Apache/2.2.16 (Debian) Server at hostname Port 443</address>
</body>
</html> 


查看HTTP的头:
    User-Agent: SAP-Messaging-com.sap.aii.af.sdk.xi/1.0505
    CallingType: SJM
    Authorization: Basic c3RuX2FwL3N0bl9hcF9pbnRlZ3JhdGlvbjo1Zjg1MTljNzk4NjQ0YjI0OGZiOTFkY2ZkY2VjNDBk
    OA==

在Authorization这个字段,值因为太长被错误地截断了,变成了两行,导致请求无法被接收方服务器接受。
SAP note 1153210提到了类似的问题:
The base64 encoding was implemented according to rfc2045, where there is a
limitation on line length. So the encoded user:password string has been
separated by a CRLF chars and this breaks the request

2013-06-04

vim下选择文本

有人在superuser问,如何在vim下实现sublime text的Expand selection to scope功能,http://superuser.com/questions/586076/vi-vim-alternative-to-sublimetexts-expand-selection-to-scope。运用vim下的text objects可以很轻松地实现这种功能。不过在这个帖子的回复中学了一招,如何选择当前文字所在的标签文本及其父标签。vat会选择光标所在文字和标签,v2at则会选择包括父标签在内的文本,依此类推。

vaw means a word
vas means a sentence
vap means a paragraph
va< means a <> block
va' means a single-quoted string
va" means a double-quoted string
vat means a tag