在线视频精品一,成人a视频在线,av中文在线http://www.aygfsteel.com/jinn/category/33084.html Jinn's Programming Roadzh-cnFri, 18 Jul 2008 14:47:04 GMTFri, 18 Jul 2008 14:47:04 GMT60- 用Stax組裝及解析XMLhttp://www.aygfsteel.com/jinn/archive/2008/07/18/215812.htmljinnjinnFri, 18 Jul 2008 07:13:00 GMThttp://www.aygfsteel.com/jinn/archive/2008/07/18/215812.htmlhttp://www.aygfsteel.com/jinn/comments/215812.htmlhttp://www.aygfsteel.com/jinn/archive/2008/07/18/215812.html#Feedback0http://www.aygfsteel.com/jinn/comments/commentRss/215812.htmlhttp://www.aygfsteel.com/jinn/services/trackbacks/215812.html閱讀全文

]]> - Axis中用戶名、密碼傳遞http://www.aygfsteel.com/jinn/archive/2008/07/18/215750.htmljinnjinnFri, 18 Jul 2008 05:18:00 GMThttp://www.aygfsteel.com/jinn/archive/2008/07/18/215750.htmlhttp://www.aygfsteel.com/jinn/comments/215750.htmlhttp://www.aygfsteel.com/jinn/archive/2008/07/18/215750.html#Feedback0http://www.aygfsteel.com/jinn/comments/commentRss/215750.htmlhttp://www.aygfsteel.com/jinn/services/trackbacks/215750.htmlWebservice交互經常需要驗證用戶,用戶名和密碼的傳遞采用SOAPHeader傳遞不失為一種好辦法。在Axis1中設置很簡單:
客戶端:
((org.apache.axis.client.Call) call).addHeader(new SOAPHeaderElement("Authorization","username",username));
((org.apache.axis.client.Call) call).addHeader(new SOAPHeaderElement("Authorization","password",password));
經包裝后傳遞的內容如下
<soapenv:Header>
<ns1:username
soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next"
soapenv:mustUnderstand="0" xsi:type="soapenc:string"
xmlns:ns1="Authorization"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
admin
</ns1:username>
<ns2:password
soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next"
soapenv:mustUnderstand="0" xsi:type="soapenc:string"
xmlns:ns2="Authorization"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
1
</ns2:password>
</soapenv:Header>
服務端通過Handler取得用戶名和密碼進行驗證:
username = (String) messageContext.getRequestMessage().getSOAPEnvelope()
.getHeaderByName("Authorization","username").getValue();
password = (String) messageContext.getRequestMessage().getSOAPEnvelope()
.getHeaderByName("Authorization","password").getValue();
如果覺得這樣不安全,可雙方約定一種加密解密規則,將用戶名和密碼加密后進行傳輸。
我曾試過使用如下方法,
客戶端:
((org.apache.axis.client.Call) call).setUsername(username);
((org.apache.axis.client.Call) call).setPassword(password);
包裝后傳遞內容(多了最后一句:Authorization: Basic emphZG1pbjox。Axis將用戶名和密碼經Base64加密后傳遞):
POST /web/services/GenericServer HTTP/1.0
Content-Type: text/xml; charset=utf-8
Accept: application/soap+xml, application/dime, multipart/related, text/*
User-Agent: Axis/1.4
Host: localhost:8083
Cache-Control: no-cache
Pragma: no-cache
SOAPAction: ""
Content-Length: 807
Authorization: Basic emphZG1pbjox
服務端的Handle:
username =messageContext.getUsername();
password = messageContext.getPassword();
這樣是沒問題,看起來更簡單。可惜調用部署在weblogic上的ws時,會被weblogic攔截,必須在weblogic安全域中配置相應的用戶才能通過驗證,這不是我們所需要的,通常我們有自己的用戶管理機制,調用WS的用戶也作為系統中的一個用戶納入我們的管理,而不是跟weblogic安全域用戶綁在一起。

]]>
主站蜘蛛池模板:
福鼎市|
交口县|
凤城市|
将乐县|
澜沧|
筠连县|
沿河|
武平县|
阿克|
兴安盟|
屏山县|
汉阴县|
五峰|
商水县|
周口市|
姚安县|
昭苏县|
青河县|
静安区|
南皮县|
香港|
白银市|
墨玉县|
绵竹市|
阳信县|
旌德县|
江口县|
祁门县|
略阳县|
万宁市|
霸州市|
全椒县|
新宁县|
观塘区|
高平市|
青冈县|
无为县|
龙海市|
象州县|
蒙自县|
麻阳|