熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> JSP教程 >> 正文

程序分享:從UDDI注冊中心查詢服務

2013-11-15 11:36:47  來源: JSP教程 

  查詢服務程序的實現過程創建Inquiry對象並設置查詢地址聲明FindBusiness對象並設置查詢服務名和相關屬性獲得BusinessList對象然後層層向下查詢BusinessList>BusinessInfo>ServiceInfo>BusinessService>BindingTemplate最後得到AccessPoint對象調用getText()方法就可獲得該服務的入口地得到服務的WSDL之後可利用WSIF調用這個服務的方法見如下程序的方法
  
  public void getServicesURL(){
  try{
  Inquiry inq=new Inquiry();
  inqsetURL();
  FindQualifiers fqs = new FindQualifiers();
  FindBusiness fb = new FindBusiness();
  fbsetFindQualifiers(fqs);
  fbsetName(new Name(MagazineServices));//查找服務名MagazineServices的服務
  BusinessList rBusinessList = inqfindBusiness(fb);
  BusinessInfos rBusinessInfos = rBusinessListgetBusinessInfos();
  Vector rBusinessInfoVector = rBusinessInfosgetBusinessInfoVector();
  BusinessInfo rBusinessInfo;
  for (int y =; y < rBusinessInfoVectorsize(); y++)
  {
  rBusinessInfo = (BusinessInfo)rBusinessInfoVectorelementAt(y);
  Systemoutprintln(*********BUSINESS INFO********);
  Systemoutprintln(Attribute BusinessKey: +rBusinessInfogetBusinessKey());
  Name rName = rBusinessInfogetName();
  Systemoutprintln(Name : +rNamegetValue());
  Vector rDesVector = rBusinessInfogetDescriptionVector();
  Description rDes=null;
  printDescriptionVector(rDesVector);
  ServiceInfos rSerInfos = rBusinessInfogetServiceInfos();
  Vector rServiceInfoVector = rSerInfosgetServiceInfoVector();
  ServiceInfo rServiceInfo;
  for (int x =; x<rServiceInfoVectorsize();x++)
  {
  Systemoutprintln(*********Service Info********);
  rServiceInfo = (ServiceInfo)rServiceInfoVectorelementAt(x);
  Systemoutprintln(Service Info Name: +rServiceInfogetName()getValue());
  Systemoutprintln(ServiceKey : +rServiceInfogetServiceKey());
  Systemoutprintln(BusinessKey : +rServiceInfogetBusinessKey());
  String magazineServer=rServiceInfogetServiceKey();
  ServiceDetail rServiceDetail = inqgetServiceDetail(gsd);
  Vector rBusinessServiceVector = rServiceDetailgetBusinessServiceVector();
  BusinessService rBS;
  for (int a=;a<rBusinessServiceVectorsize();a++)
  {
  Systemoutprintln(*****************BUSINESS SERVICE***************);
  rBS = (BusinessService)rBusinessServiceVectorelementAt(a);
  Vector rDesVector = rBSgetDescriptionVector();
  BindingTemplates rBTs = rBSgetBindingTemplates();
  if (rBTs !=null)
  {
  Vector rBTVector = rBTsgetBindingTemplateVector();
  BindingTemplate returnBindingTemplate;
  for (int i = ; i < returnBindingTemplateVectorsize(); i++)
  {
  Systemoutprintln(***********BINDING TEMPLATE*************);
  returnBindingTemplate =(BindingTemplate)returnBindingTemplateVectorelementAt(i);
  Vector rDesVector = returnBindingTemplategetDescriptionVector();                  AccessPoint rAP = returnBindingTemplategetAccessPoint();
  URL url=new URL(rAPgetText());//找到服務的URL地址
  }
  }
  }
  }
  }
  }catch(Exception e){
  eprintStackTrace();
  }
  }

From:http://tw.wingwit.com/Article/program/Java/JSP/201311/19291.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.