查詢服務程序的實現過程
創建Inquiry對象
並設置查詢地址
聲明FindBusiness對象
並設置查詢服務名和相關屬性
獲得BusinessList對象
然後層層向下查詢
BusinessList
>BusinessInfo
>ServiceInfo
>BusinessService
>BindingTemplate
最後得到AccessPoint對象
調用getText()方法
就可獲得該服務的入口地
得到服務的WSDL之後
可利用WSIF調用這個服務的方法
見如下程序的方法
public void getServicesURL(){
try{
Inquiry inq=new Inquiry();
inq
setURL(
);
FindQualifiers fqs = new FindQualifiers();
FindBusiness fb = new FindBusiness();
fb
setFindQualifiers(fqs);
fb
setName(new Name(
MagazineServices
));//查找服務名MagazineServices的服務
BusinessList rBusinessList = inq
findBusiness(fb);
BusinessInfos rBusinessInfos = rBusinessList
getBusinessInfos();
Vector rBusinessInfoVector = rBusinessInfos
getBusinessInfoVector();
BusinessInfo rBusinessInfo;
for (int y =
; y < rBusinessInfoVector
size(); y++)
{
rBusinessInfo = (BusinessInfo)rBusinessInfoVector
elementAt(y);
System
out
println(
*********BUSINESS INFO********
);
System
out
println(
Attribute BusinessKey:
+rBusinessInfo
getBusinessKey());
Name rName = rBusinessInfo
getName();
System
out
println(
Name :
+rName
getValue());
Vector rDesVector = rBusinessInfo
getDescriptionVector();
Description rDes=null;
printDescriptionVector(rDesVector);
ServiceInfos rSerInfos = rBusinessInfo
getServiceInfos();
Vector rServiceInfoVector = rSerInfos
getServiceInfoVector();
ServiceInfo rServiceInfo;
for (int x =
; x<rServiceInfoVector
size();x++)
{
System
out
println(
*********Service Info********
);
rServiceInfo = (ServiceInfo)rServiceInfoVector
elementAt(x);
System
out
println(
Service Info Name:
+rServiceInfo
getName()
getValue());
System
out
println(
ServiceKey :
+rServiceInfo
getServiceKey());
System
out
println(
BusinessKey :
+rServiceInfo
getBusinessKey());
String magazineServer=rServiceInfo
getServiceKey();
ServiceDetail rServiceDetail = inq
getServiceDetail(gsd);
Vector rBusinessServiceVector = rServiceDetail
getBusinessServiceVector();
BusinessService rBS;
for (int a=
;a<rBusinessServiceVector
size();a++)
{
System
out
println(
*****************BUSINESS SERVICE***************
);
rBS = (BusinessService)rBusinessServiceVector
elementAt(a);
Vector rDesVector = rBS
getDescriptionVector();
BindingTemplates rBTs = rBS
getBindingTemplates();
if (rBTs !=null)
{
Vector rBTVector = rBTs
getBindingTemplateVector();
BindingTemplate returnBindingTemplate;
for (int i =
; i < returnBindingTemplateVector
size(); i++)
{
System
out
println(
***********BINDING TEMPLATE*************
);
returnBindingTemplate =(BindingTemplate)returnBindingTemplateVector
elementAt(i);
Vector rDesVector = returnBindingTemplate
getDescriptionVector(); AccessPoint rAP = returnBindingTemplate
getAccessPoint();
URL url=new URL(rAP
getText());//找到服務的URL地址
}
}
}
}
}
}catch(Exception e){
e
printStackTrace();
}
}
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/19291.html