1. 程式人生 > >使用Eclipse-j2ee中運用wtp外掛實現webservice呼叫

使用Eclipse-j2ee中運用wtp外掛實現webservice呼叫

import java.rmi.RemoteException;

import javax.xml.rpc.ServiceException;


public class TestCallSoap {
        public  static void main(String[] args){
              HISWS.HISWSServiceLocator ws = new HISWS.HISWSServiceLocator();
              String str = "";
               try {
                     str = ws.getHISWSPort().getHospitals( "test", "test" );
              } catch (RemoteException e) {
                      // TODO Auto-generated catch block
                     e.printStackTrace();
              } catch (ServiceException e) {
                      // TODO Auto-generated catch block
                     e.printStackTrace();
              }
              System. out.println(str);
       }
}
       執行之後,結果如下           <?xml version='1.0'?><result><state>1</state><state_desc>查詢成功</state_desc><count>222</c
       到此呼叫成功!