1. install the following software
jre 1.5 or 1.6, tomcat 5525, eclipse, axis2
and in eclipse preferences set tomcat to web server, set jre env and set axis2's runtime
2. create a java project and add axis2 runtime library to its build library
test ws client sample code:
public class TestSms
{
private static EndpointReference targetEPR = new EndpointReference(
"http://cdl:8080/axis2/services/Version");
public static OMElement getGetLeftElement(){
OMFactory fac=OMAbstractFactory.getOMFactory();
OMNamespace omNs=fac.createOMNamespace("此處填寫WS的命名空間","hw");
OMElement method=fac.createOMElement("WS 方法名",omNs);
OMElement value = fac.createOMElement("參數一", omNs);
value.addChild(fac.createOMText(value, "值一"));
method.addChild(value);
value = fac.createOMElement("參數二", omNs);
value.addChild(fac.createOMText(value, "值2"));
method.addChild(value);
return method;
}
public static void main(String[] args){
try{
Options options=new Options();
options.setTo(targetEPR);
options.setAction("命名空間/WS 方法名");
ServiceClient sender=new ServiceClient();
sender.setOptions(options);
OMElement sayHello=TestSms.getGetLeftElement();
//WSDLConstants.
OMElement result=sender.sendReceive(sayHello);
OMElement elem = result.getFirstElement();
System.out.println(elem.getText());
//System.out.println(result);
}
catch(Exception axisFault){
axisFault.printStackTrace();
}
}
}
ref:
http://zhangjunhd.blog.51cto.com/113473/23690
http://randomcoder.com/articles/jsessionid-considered-harmful
最近總是打不開網頁中的JAVA程序, 本來機器上有JAVA開發環境, 重裝系統一般不安裝JAVA,反正設置java_home和path中添加javac/java就可以了. 結果IE總是打不開,也不找到原因. 今天沒辦法了, 要參加一項考試,只好在網上搜索了一下, 原來出問題總是有原因的.
參考官方幫助:
http://www.java.com/zh_CN/download/help/win_offline.xml下載jre運行環境.安裝.
- 雙擊該圖標打開“Java 控制面板”
- 在“Java 控制面板”中選擇“瀏覽器”選項卡
- 確保選中“Internet Explorer”、“Netscape”或“Mozilla”旁邊的復選框
- 如果尚未選中,請選中對應的復選框,為您的 Web 瀏覽器啟用 JRE
- 單擊“應用”按鈕
Internet Explorer 4.x 及更高版本
- 單擊“工具”-->“Internet 選項”
- 選擇“高級”選項卡,并向下滾動到“Java (Sun)”
- 選中“使用 Java 2 版本”旁邊的復選框
- 接下來選擇“安全”選項卡,然后選擇“自定義級別”按鈕
- 向下滾動到“Java 小程序腳本”
- 確保選中“啟用”單選按鈕。
- 單擊“確定”保存您的首選設置。
最后不要忘了在這里測試一下是否安裝成功: http://www.java.com/zh_CN/download/help/testvm.xml