ImageVerifierCode 换一换
格式:DOCX , 页数:17 ,大小:137.58KB ,
资源ID:6946157      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/6946157.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(axis使用和配置1.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

axis使用和配置1.docx

1、axis使用和配置1在某些场景中AXIS提供很强大的功能,包括添加消息头,提供NTLM等多种认证方式,进行ACK发送的功能,具体参考SAP 的AXIS FQA。本文档主要讲述PI的AXIS部署以及自定handler,涉及2个handler,一个用于外围系统异步发送系统的时候发生ACK给外围系统,另一个是PI采用Handler实现NTLM V2安全认证。 SP15 , SP10之后SAP推出了针对Apache HTTP Client library的补丁,参考note 2062567 - Integration of Apache HttpClient library in the PI Axi

2、s adapter可以实现NTLM V2。而对于这2个补丁之前的版本SAP不支持 NTLM V2协议。本例的方法是根据SAP的SP包中的相关类进行反编译后的源代码封装成自己的handler类。首先PI要支持AXIS,则需要部署部署情况可以通过网址 jar(开始使用版本,发现有bug: ) (NTLM V2 用到此包,下面的2个包也一样) 用工具sdaMakerTool进行压缩。如果是自己开发的handler类没有用到其他PI标准类的话也可以独立部署到这个包中,如果用到了其他类,其他的jar类也一并压缩到这个包中,并要进行加载,另外一种方式是把自定的handler类在SAP 的axis samp

3、le adapter中实现,参考AXIS的FQA.本文档中的两个类都是独立的类,用到的SAP标准的jar文件也压缩到其中。ACK handler类实现,网上有这个blog,照着blog实现。代码如下。package class ZResponseHandler extends BasicHandler protected static Log log = public void invoke(MessageContext msgContext) throws AxisFault /* Response handler to write custom Ariba response */ try

4、String Msg_id = (); (PI messageid is +Msg_id); if () Msg_id = 0001; String respTxt = createResponseText(Msg_id); /* * Getting response soap message envelop and add * response message to soap body */ etEnvelope().setTextContent(respTxt); (msg); catch (Exception e) throw (e); private String createResp

5、onseText(String msgid) String payloadID = 1234; String ts = getTimeStamp(); String respText = rn+ rn + + rn + rn + rn + +msgid+ rn + rn + rn + ; return respText; private String getTimeStamp() Date today = new Date(); SimpleDateFormat sdf = new SimpleDateFormat(yyyy-MM-ddTHH:mm:ssZ); etLog(); PlainCo

6、nnectionSocketFactory plainsf; boolean checkForDefaultPort; boolean authenticationPreemptive; CloseableHttpClient httpclient; CommonsHTTPClientProperties clientProperties; boolean httpChunkStream; public void init() (); authenticationPreemptive = (String)getOption().booleanValue(); clientProperties

7、= (); public Myntlm() etProperty(checkForDefaultPort); HttpClientContext context = (); httpclientbuilder = createHttpClient(msgContext, context, targetURL); RequestConfig reqConf = createRequestConfig(msgContext, targetURL, httpclientbuilder); boolean restful = ( (enableREST).booleanValue(); boolean

8、 posting = true; String webMethod = null; if () = webMethod = (); if (webMethod = null) webMethod = POST; else posting = (POST) | (PUT); if (posting) if (put) method = new HttpPut(); else method = new HttpPost(); else method = new HttpGet(); addContextInfo(method, reqConf, msgContext, targetURL); (r

9、eqConf); String httpVersion = msgContext .getStrProp(); if (httpVersion != null & (HTTP/) ; else ; ByteArrayOutputStream binReq = new ByteArrayOutputStream(); String contentType = text/xml; Message reqMsg = (); if (reqMsg != null) if (restful) SOAPPart part = (); String types = (Content-Type); if (t

10、ypes != null & 0) contentType = types0; if (!( Content-Type).getValue() (Content-Type); (Content-Type, contentType); (null); (, false); (new StringBuilder().append(rest message is: ) .append(new String() .toString(); else contentType = (msgContext .getSOAPConstants(); (binReq); (new StringBuilder().

11、append( Content type of request message determined to: ).append( contentType).toString(); HttpEntity reqEntity = null; if (posting) EntityBuilder reqBuilder = (); (); if () (); else if () (); (contentType); reqEntity = (); if (method .containsHeader) (removing old content encoding value.); method .r

12、emoveHeaders; (new StringBuilder().append(setting chunked to ) .append(httpChunkStream).toString(); (AbstractHttpEntity) reqEntity).setChunked(httpChunkStream); (HttpEntityEnclosingRequest) method).setEntity(reqEntity); HttpHost target = new HttpHost(), targetURL .getPort(), (); httpclient = (); (ne

13、w StringBuilder().append(target configured to: ) .append().append( and calling it .) .toString(); CloseableHttpResponse resp = (target, method, context); int respCode = ().getStatusCode(); (new StringBuilder().append( Called successfully with HTTP code: ).append(respCode) .toString(); contentType =

14、getHeader(resp, Content-Type); String contentLocation = getHeader(resp, Content-Location); String contentLength = getHeader(resp, Content-Length); if (respCode = 300) & (text/html.equalsIgnoreCase(contentType) | respCode = 600) String statusMessage = ().getReasonPhrase(); AxisFault fault = new AxisF

15、ault(HTTP, (new StringBuilder() .append().append(respCode).append().append( statusMessage).toString(), null, null); (return01, (new StringBuilder().append().append( () .toString(); , (respCode); throw fault; respBody = (); Header contEnc = (); if (contEnc != null) HeaderElement elems = (); HeaderEle

16、ment arr$ = elems; int len$ = arr$.length; for (int i$ = 0; i$ len$; i$+) HeaderElement el = arr$i$; if (gzip.equalsIgnoreCase() respBody = new GzipDecompressingEntity(respBody); (respBody); Header responseHeaders = (); String enc = (respBody); if (enc = null) enc = iso-8859-1; Message outMsg = null

17、; (new StringBuilder().append( Content type of response message determined to: ).append( contentType).toString(); if (restful) outMsg = new Message(respBody .getContent(), enc, UTF-8, false), false, contentType, contentLocation); ().setMimeHeader(Content-Type, contentType); try (, UTF-8); catch (SOA

18、PException e) (Error while setting message encoding, e); else if (contentLength != null & 0.equalsIgnoreCase(contentLength) outMsg = new Message(new SOAPEnvelope(); else outMsg = new Message(), false, contentType, contentLocation); (); MimeHeaders responseMimeHeaders = (); for (int i = 0; i ; i+) He

19、ader responseHeader = responseHeadersi; (), (); (response); (outMsg); if () Header headers = (); for (int i = 0; i ; i+) if (headersi.getName().equalsIgnoreCase(Set-Cookie) handleCookie(Cookie, headersi.getValue(), msgContext); continue; if (headersi.getName().equalsIgnoreCase(Set-Cookie2) handleCoo

20、kie(Cookie2, headersi.getValue(), msgContext); catch (Exception e) (Error , e); throw new AxisFault(Error while invoking HttpClientSender: , e); if (httpclient != null) try (); catch (IOException e) (Error while closing http client: , e); try (); catch (IOException e) (Error while closing http clien

21、t: , e); public void handleCookie(String cookieName, String acookie, MessageContext msgContext) String ck = (,); ArrayList cookies = new ArrayList(); for (int i = 0; i ; i+) int index = cki.indexOf(;); if (index != -1) cki = cki.substring(0, index); index = cki.indexOf(=); String key = index != -1 c

22、ki.substring(0, index) : cki; Object oldCookies = (cookieName); boolean alreadyExist = false; if (oldCookies != null) if (oldCookies instanceof String) String oldCookiesArray = (String) (String) oldCookies; for (int j = 0; j 1) (cookieName, (Object) (cookies .toArray(new String(); private String get

23、Header(HttpResponse resp, String header) Header h = (header); return h != null () : null; private void addContextInfo(HttpRequestBase method, RequestConfig reqConf, MessageContext msgContext, URL targetURL) throws Exception String action = () msgContext .getSOAPActionURI() : ; if (action = null) act

24、ion = ; Message msg = (); if (msg != null) String contentType = (msgContext .getSOAPConstants(); if () & () = & () = 0) contentType = (new StringBuilder().append(contentType).append( ; action=).append(action).append().toString(); (Content-Type, contentType); if () = | (attachment_encapsulation_format) = ) (SOAPAction, (new StringBuilder().append() .append(action).append().toString(); (User-Agent, (axisUserAgent); if () (Accept-Encoding, gzip); MimeHea

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1