分享
 
 
 

服务查询的API(Weblogic)编写的client实例

王朝other·作者佚名  2006-03-10
窄屏简体版  字體: |||超大  

import weblogic.uddi.client.service.Inquiry;

import weblogic.uddi.client.service.Publish;

import weblogic.uddi.client.structures.exception.UDDIException;

import weblogic.uddi.client.structures.exception.XML_SoapException;

import weblogic.uddi.client.structures.datatypes.AccessPoint;

import weblogic.uddi.client.structures.datatypes.Address;

import weblogic.uddi.client.structures.datatypes.AddressLine;

import weblogic.uddi.client.structures.datatypes.AuthInfo;

import weblogic.uddi.client.structures.datatypes.BindingKey;

import weblogic.uddi.client.structures.datatypes.BindingTemplate;

import weblogic.uddi.client.structures.datatypes.BindingTemplates;

import weblogic.uddi.client.structures.datatypes.BusinessEntity;

import weblogic.uddi.client.structures.datatypes.BusinessKey;

import weblogic.uddi.client.structures.datatypes.BusinessService;

import weblogic.uddi.client.structures.datatypes.BusinessServices;

import weblogic.uddi.client.structures.datatypes.CategoryBag;

import weblogic.uddi.client.structures.datatypes.Contact;

import weblogic.uddi.client.structures.datatypes.Contacts;

import weblogic.uddi.client.structures.datatypes.Description;

import weblogic.uddi.client.structures.datatypes.DiscoveryURL;

import weblogic.uddi.client.structures.datatypes.DiscoveryURLs;

import weblogic.uddi.client.structures.datatypes.Email;

import weblogic.uddi.client.structures.datatypes.FindQualifier;

import weblogic.uddi.client.structures.datatypes.FindQualifiers;

import weblogic.uddi.client.structures.datatypes.HostingRedirector;

import weblogic.uddi.client.structures.datatypes.IdentifierBag;

import weblogic.uddi.client.structures.datatypes.InstanceDetails;

import weblogic.uddi.client.structures.datatypes.InstanceParms;

import weblogic.uddi.client.structures.datatypes.KeyValue;

import weblogic.uddi.client.structures.datatypes.KeyedReference;

import weblogic.uddi.client.structures.datatypes.Name;

import weblogic.uddi.client.structures.datatypes.OverviewDoc;

import weblogic.uddi.client.structures.datatypes.OverviewURL;

import weblogic.uddi.client.structures.datatypes.Phone;

import weblogic.uddi.client.structures.datatypes.ServiceKey;

import weblogic.uddi.client.structures.datatypes.TModel;

import weblogic.uddi.client.structures.datatypes.TModelBag;

import weblogic.uddi.client.structures.datatypes.TModelInstanceDetails;

import weblogic.uddi.client.structures.datatypes.TModelInstanceInfo;

import weblogic.uddi.client.structures.datatypes.TModelKey;

import weblogic.uddi.client.structures.datatypes.UploadRegister;

import weblogic.uddi.client.structures.datatypes.BusinessInfo;

import weblogic.uddi.client.structures.datatypes.BusinessInfos;

import weblogic.uddi.client.structures.datatypes.ErrInfo;

import weblogic.uddi.client.structures.datatypes.Result;

import weblogic.uddi.client.structures.datatypes.ServiceInfo;

import weblogic.uddi.client.structures.datatypes.ServiceInfos;

import weblogic.uddi.client.structures.datatypes.TModelInfo;

import weblogic.uddi.client.structures.datatypes.TModelInfos;

import weblogic.uddi.client.structures.request.DeleteBinding;

import weblogic.uddi.client.structures.request.DeleteBusiness;

import weblogic.uddi.client.structures.request.DeleteService;

import weblogic.uddi.client.structures.request.DeleteTModel;

import weblogic.uddi.client.structures.request.DiscardAuthToken;

import weblogic.uddi.client.structures.request.FindBinding;

import weblogic.uddi.client.structures.request.FindBusiness;

import weblogic.uddi.client.structures.request.FindService;

import weblogic.uddi.client.structures.request.FindTModel;

import weblogic.uddi.client.structures.request.GetAuthToken;

import weblogic.uddi.client.structures.request.GetBindingDetail;

import weblogic.uddi.client.structures.request.GetBusinessDetail;

import weblogic.uddi.client.structures.request.GetBusinessDetailExt;

import weblogic.uddi.client.structures.request.GetRegisteredInfo;

import weblogic.uddi.client.structures.request.GetServiceDetail;

import weblogic.uddi.client.structures.request.GetTModelDetail;

import weblogic.uddi.client.structures.request.SaveBinding;

import weblogic.uddi.client.structures.request.SaveBusiness;

import weblogic.uddi.client.structures.request.SaveService;

import weblogic.uddi.client.structures.request.SaveTModel;

import weblogic.uddi.client.structures.request.ValidateCategorization;

import weblogic.uddi.client.structures.response.AuthToken;

import weblogic.uddi.client.structures.response.BindingDetail;

import weblogic.uddi.client.structures.response.BusinessDetail;

import weblogic.uddi.client.structures.response.BusinessDetailExt;

import weblogic.uddi.client.structures.response.BusinessList;

import weblogic.uddi.client.structures.response.DispositionReport;

import weblogic.uddi.client.structures.response.RegisteredInfo;

import weblogic.uddi.client.structures.response.ServiceDetail;

import weblogic.uddi.client.structures.response.ServiceList;

import weblogic.uddi.client.structures.response.TModelDetail;

import weblogic.uddi.client.structures.response.TModelList;

import java.util.Vector;

public class TestClientWebInq{

private static Inquiry inq;//创建查询对象

private static Publish pub;//创建发布对象

public TestClientWebInq()

{

inq = new Inquiry();

pub = new Publish();

}

public static void main(String arg[]){

System.out.println("\nTesting clientW.......\n");

TestClientWebInq t = new TestClientWebInq();

System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");

java.security.Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());

inq.setURL("http://localhost:7001/uddi/uddilistener");//设置查询地址:weblogic提供的UDDI注册中心

pub.setURL("http://localhost:7001/uddi/uddilistener");//设置发布地址

t.testFindBusinessByName();//从FindBussiness对象开始查询服务

t.testGetBusinessDetail();//通过给定的BusinessKey获得企业和商业实体的相关信息

}

/*给定的Name获得相关的企业实体信息和服务的相关信息

思路:

根据企业实体Name,使用FindBussiness对象定位到指定的企业的商业实体列表

BussinessList对象,通过BussinessInfos对象从它获得企业实体信息。再在一个

BussinessInfo对象中获得servicInfos,然后在一个ServiceInfo对象中获得服务名,服务

key,商业实体key.

运行结果:

*********BUSINESS INFO********

Attribute BusinessKey: 302d8510-da85-481a-a9c6-cc0762774db1

Name : JavaLab

*********Service Info********

Service Info Name: HelloWorldG

ServiceKey : 7271dc73-d738-4ef2-8e57-e7fcc4f5b0a2

BusinessKey : 302d8510-da85-481a-a9c6-cc0762774db1

*********Service Info********

*********BUSINESS INFO********

*/

public void testFindBusinessByName()

{

System.out.println("TEST FindBusiness By Name");

try{

Name name= new Name("JavaLab");//注册的公司单位/部门名称

FindBusiness fb = new FindBusiness();//声明FindBussiness对象,并设置相关的查询信息属性

fb.setName(name);

BusinessList rBusinessList = inq.findBusiness(fb);//从企业实体中提取,用Bussinsesslist获得商业服务列表

printBusinessList(rBusinessList);//打印服务列表

}catch(UDDIException ue){//UDDI异常

System.out.println("UDDIEXception");

System.out.println(ue.getFaultActor());

System.out.println(ue.getFaultCode());

DispositionReport dr = ue.getDispositionReport();

Vector res = dr.getResultVector();

Result r = (Result)res.elementAt(0);

ErrInfo ei = r.getErrInfo();

System.out.println("ErrInfo : "+ ei.getValue());

}

catch (XML_SoapException exp){//soap解析异常

System.out.println("XML_SoapException");

System.out.println(exp.getMessage());

exp.printStackTrace();

}

catch(Exception e){

System.out.println("Exception");

e.printStackTrace();

}

}

private void printBusinessList(BusinessList rBusinessList)

{

BusinessInfos rBusinessInfos = rBusinessList.getBusinessInfos();//获得商业服务信息

Vector rBusinessInfoVector = rBusinessInfos.getBusinessInfoVector();//获得商业服务信息向量列表

System.out.println("BusinessList size: "+rBusinessInfoVector.size());

BusinessInfo rBusinessInfo;

for (int y =0; 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();

ServiceInfos rSerInfos = rBusinessInfo.getServiceInfos();//获得商业服务信息

Vector rServiceInfoVector = rSerInfos.getServiceInfoVector();//获得商业服务信息的属性列表

ServiceInfo rServiceInfo;

for (int x =0; 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());

System.out.println("*********Service Info********");

}

System.out.println("*********BUSINESS INFO********");

}

}

/*通过给定的BusinessKey获得企业实体和商业服务的信息,以及服务的提供与定位到wsdl

思路:

根据给定的Bussinesskey,用inqury对象得到BussinessDetail,然后用他们得到一个

BussinessEntity的vector,然后通过BussinessEnity得到BusinessServices,剩下的流程:

BusinessServices-->BusinessService->BindingTemplates->BindingTemplate-->AccessPoint

运行结果:

DISCOVERY URL text: http://localhost:7001/uddi/uddilistener?businessKey=302d8510

-da85-481a-a9c6-cc0762774db1

DISCOVERY URL useType: businessEntity

Business Entity Name: JavaLab

*****************BUSINESS SERVICE***************

Description : TestUDDI

***********BINDING TEMPLATE*************

Access Point ==> Text : http://localhost:7001/axis/services/HelloWorldG?wsdl

Access Point ==> URLType : http

GH1

GH2

GH3

GH4

OVERVIEWURL : http://localhost:7001/axis/services/HelloWorldG?wsdl

GH5

GH6

TModelInstanceInfo TModelKey attribute : uuid:58ced676-8c97-40b1-8ee3-7cdb8c25db

09

bindingTemplate attr Binding Key : f518192f-3c48-400f-bbbb-093522ba2ae6

bindingTemplate attr serviceKey : 7271dc73-d738-4ef2-8e57-e7fcc4f5b0a2

***********BINDING TEMPLATE*************

BusinessService serviceKey: 7271dc73-d738-4ef2-8e57-e7fcc4f5b0a2

BusinessService businessKey: 302d8510-da85-481a-a9c6-cc0762774db1

*****************BUSINESS SERVICE***************

BUSINESS ENTITY BusinessKey: 302d8510-da85-481a-a9c6-cc0762774db1

BUSINESS ENTITY authorizedName: gaolong1

*/

public void testGetBusinessDetail()

{

try{

Vector businessKeyVector = new Vector();

BusinessKey businessKey = new BusinessKey("2c646249-2277-433d-8f87-9c95e41d4a7f");//商业标示

businessKeyVector.add(businessKey);

GetBusinessDetail gbd = new GetBusinessDetail();//获得商业描述的对象

gbd.setBusinessKeyVector(businessKeyVector);

BusinessDetail rBusinessDetail = inq.getBusinessDetail(gbd);//从查询对象中获得商业实体的描述

Vector rBusinessEntityVector = rBusinessDetail.getBusinessEntityVector();//得到商业实体列表

BusinessEntity rBE;

for (int a = 0; a<rBusinessEntityVector.size();a++)

{

rBE = (BusinessEntity)rBusinessEntityVector.elementAt(a);//取其中的商业实体

DiscoveryURLs rDisURLs = rBE.getDiscoveryURLs(); //指向基于可代替文件的服务发现机制的URL

Vector rDisURLVector = rDisURLs.getDiscoveryURLVector();

DiscoveryURL rDisURL;

for (int b=0;b<rDisURLVector.size();b++)

{

rDisURL=(DiscoveryURL)rDisURLVector.elementAt(b);

System.out.println("DISCOVERY URL text: "+rDisURL.getValue());//请求路径

System.out.println("DISCOVERY URL useType: "+rDisURL.getUseType());//请求参数

}

System.out.println("Business Entity Name: "+rBE.getName().getValue());//企业实体名称

Vector rDesVector = rBE.getDescriptionVector();

printDescriptionVector(rDesVector); //获取描述信息

BusinessServices rBSs = rBE.getBusinessServices();//获得商业服务

if (rBSs!=null)

{

Vector rBusinessServiceVector = rBSs.getBusinessServiceVector();

if (rBusinessServiceVector!=null)

{

printBusinessServiceVector(rBusinessServiceVector);//输出描述信息

}

}

System.out.println("BUSINESS ENTITY BusinessKey: "+rBE.getBusinessKey());

System.out.println("BUSINESS ENTITY authorizedName: "+rBE.getAuthorizedName());//获得发布消息的用户名

}

}catch(UDDIException ue){

System.out.println("UDDIEXception");

System.out.println(ue.getFaultActor());

System.out.println(ue.getFaultCode());

DispositionReport dr = ue.getDispositionReport();

Vector res = dr.getResultVector();

Result r = (Result)res.elementAt(0);

ErrInfo ei = r.getErrInfo();

System.out.println("ErrInfo : "+ ei.getValue());

}

catch (XML_SoapException exp)

{

System.out.println("XML_SoapException");

System.out.println(exp.getMessage());

exp.printStackTrace();

}

catch(Exception e){

System.out.println("Exception");

e.printStackTrace();

}

}

private void printBusinessServiceVector(Vector rBusinessServiceVector)

{

BusinessService rBS;

for (int a=0;a<rBusinessServiceVector.size();a++)

{

System.out.println("*****************BUSINESS SERVICE***************");

rBS = (BusinessService)rBusinessServiceVector.elementAt(a);//得到商业服务对象

Vector rDesVector = rBS.getDescriptionVector();

printDescriptionVector(rDesVector);//给出描述信息

BindingTemplates rBTs = rBS.getBindingTemplates();//提供详细技术信息,包含服务存取点的信息。由serviceKey属性来识别bussinessService.

if (rBTs !=null)//如果该模板不是服务的人口点,他会给出远程宿主的服务的信息,称为绿页,它维护tModels结构列表

{

Vector rBTVector = rBTs.getBindingTemplateVector();

printBindingTemplate(rBTVector);

}

CategoryBag rCategoryBag = rBS.getCategoryBag();//Category结构中使用tModelKey,用于定义组织标识和多种分类

if (rCategoryBag!=null)

{

Vector rCatKRVector = rCategoryBag.getKeyedReferenceVector();

KeyedReference rCatKR;

for (int b=0;b<rCatKRVector.size();b++)

{

rCatKR = (KeyedReference)rCatKRVector.elementAt(b);

System.out.println("CatBag KeyedReference tModelKey: "+rCatKR.getTModelKey());

System.out.println("CatBag KeyedReference KeyName: "+rCatKR.getKeyName());

System.out.println("CatBag KeyedReference keyValue: "+rCatKR.getKeyValue());

}

}

System.out.println("BusinessService serviceKey: "+rBS.getServiceKey());

System.out.println("BusinessService businessKey: "+rBS.getBusinessKey());

System.out.println("*****************BUSINESS SERVICE***************");

}

}

private void printBindingTemplate(Vector returnBindingTemplateVector)

{

BindingTemplate returnBindingTemplate;

for (int i = 0; i < returnBindingTemplateVector.size(); i++)

{

System.out.println("***********BINDING TEMPLATE*************");

returnBindingTemplate = (BindingTemplate)returnBindingTemplateVector.elementAt(i);

Vector rDesVector = returnBindingTemplate.getDescriptionVector();

printDescriptionVector(rDesVector);//得到描述信息

AccessPoint rAP = returnBindingTemplate.getAccessPoint();//获得适合调用webservices的入口点地址

if (rAP != null)

{

System.out.println("Access Point ==> Text : "+rAP.getValue());//入口wsdl路径

System.out.println("Access Point ==> URLType : " + rAP.getURLType());//该路经的通信协议

}

HostingRedirector rHR = returnBindingTemplate.getHostingRedirector();//没有指定accessPoint时,指定对不同bindingTemplate的引用

if (rHR != null)

{

System.out.println("Hosting Redirector ==> BindingKey : " + rHR.getBindingKey());

}

TModelInstanceDetails rTMIDs = returnBindingTemplate.getTModelInstanceDetails();//tModelInstaceInfo元素列表,提供标示符,识别兼容的服务

if (rTMIDs!=null)

{

Vector rTMIIVector = rTMIDs.getTModelInstanceInfoVector();

TModelInstanceInfo rTMII;

for (int y = 0 ; y < rTMIIVector.size(); y++)

{

rTMII = (TModelInstanceInfo)rTMIIVector.elementAt(y);

Vector rTMIIrDesVector = rTMII.getDescriptionVector();

printDescriptionVector(rTMIIrDesVector);

InstanceDetails rIDs = rTMII.getInstanceDetails();

if (rIDs != null)

{

System.out.println("GH1");

Vector newDes = rIDs.getDescriptionVector();//获得描述信息

printDescriptionVector(newDes);

System.out.println("GH2");

OverviewDoc rOD = rIDs.getOverviewDoc();//指定对远程指令和该结构相关信息的引用

System.out.println("GH3");

if (rOD != null)

{

printDescriptionVector(rOD.getDescriptionVector());

System.out.println("GH4");

if (rOD.getOverviewURL() != null)

{

System.out.println("OVERVIEWURL : " + rOD.getOverviewURL().getValue());//获得远程信息的URL

}

System.out.println("GH5");

}

InstanceParms rIP = rIDs.getInstanceParms();

System.out.println("GH6");

if (rIP != null)

{

System.out.println("IntsanceParams : "+ rIP.getValue());

}

}

System.out.println("TModelInstanceInfo TModelKey attribute : "+rTMII.getTModelKey());//获得指定tModel结构的唯一键

}

}

System.out.println("bindingTemplate attr Binding Key : "+returnBindingTemplate.getBindingKey());//获得该结构的UUID

System.out.println("bindingTemplate attr serviceKey : "+returnBindingTemplate.getServiceKey());//获得BusinessService/

System.out.println("***********BINDING TEMPLATE*************");

}

}

static public void printDescriptionVector(Vector des)

{

if (des

==null)

return;

//Find the class in the Vector

Description ct;

for (int i =0 ; i<des.size();i++)

{

ct = (Description)des.elementAt(i);

System.out.println("Description : " + ct.getValue());//获得描述信息

}

}

}

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有