juddiv3 客户端发布代码

package publish;

import java.util.ArrayList;
import java.util.Vector;

import org.uddi4j.client.UDDIProxy;
import org.uddi4j.datatype.Name;
import org.uddi4j.datatype.binding.AccessPoint;
import org.uddi4j.datatype.binding.BindingTemplate;
import org.uddi4j.datatype.service.BusinessService;
import org.uddi4j.response.BusinessInfo;
import org.uddi4j.response.BusinessList;
import org.uddi4j.response.ServiceDetail;
import org.uddi4j.response.ServiceInfo;
import org.uddi4j.response.ServiceList;
import org.uddi4j.response.TModelInfo;
import org.uddi4j.response.TModelList;
import org.uddi4j.transport.TransportException;
import org.uddi4j.util.CategoryBag;
import org.uddi4j.util.FindQualifier;
import org.uddi4j.util.FindQualifiers;
import org.uddi4j.util.KeyedReference;
import org.uddi4j.util.TModelBag;
import org.uddi4j.util.TModelKey;

public class find_weather_information {
public static void main(String[] args) throws TransportException, Exception{
  find_weather_information find = new find_weather_information();
  ArrayList rs= new ArrayList();
  rs=find.find_URL();
  for(int i=0;i <rs.size();i++){
  System.out.println(rs.get(i));
  }
 
 


}
public ArrayList find_URL() throws Exception, TransportException
{
String inquiryURL = "http://localhost:8080/juddi/inquiry";
    String publishURL= "http://localhost:8080/juddi/publish";
    String userid="juddi";
    String password="juddi";
// 创建一个 UDDIProxy object.
UDDIProxy proxy = new UDDIProxy();
        // 设置环境
proxy.setInquiryURL(inquiryURL);
proxy.setPublishURL(publishURL);



//tModel的查询
        //根据TModel的categoryBag查询,目标是categoryBag的name为uddi-org:types,值为wsdlSpec的tModel
CategoryBag categoryBag = new CategoryBag();
categoryBag.add(new KeyedReference("uddi-org:types", "wsdlSpec"));
TModelList tModelList=proxy.find_tModel(null,categoryBag, null, null, 0);
//讲找到的tModelkey放入ArrayList中
String tModelKey = null;
ArrayList tModelKeyList=new ArrayList();
Vector tModelInfoVector =tModelList.getTModelInfos().getTModelInfoVector();
for(int i=0;i <tModelInfoVector.size();i++)
{
    tModelKey = ((TModelInfo)tModelInfoVector.get(i)).getTModelKey();
    tModelInfoVector.add(tModelKey);
}
//创建TModelBag,存放上面找到的符合要求的TModel,便于下面的查询使用
TModelBag tModelBag = new TModelBag();
for(int i=0;i <tModelKeyList.size();i++)
tModelBag.add((TModelKey) tModelKeyList.get(i));



//Entity的查询
//填名字
Vector entity_names = new Vector();
entity_names.add(new Name("%Airlines_Company%"));////记得加“%”
    //设置FindQualifiers为“区分大小写模式”
    FindQualifiers findQualifiers = new FindQualifiers();
Vector qualifier = new Vector();
qualifier.add(new FindQualifier("caseSensitiveMatch"));//区分大小写匹配模式
findQualifiers.setFindQualifierVector(qualifier);
//查找
BusinessList businessList = proxy.find_business(entity_names, null, null, null,tModelBag,findQualifiers,0);


//对每个Entity查询service
String  businessKey= null;
String  serviceKey= null;
ServiceDetail serviceDetail = null;
BindingTemplate bindingTemplate = null;
AccessPoint accessPoint = null;
ArrayList URLlist=new ArrayList();
Vector businessInfoVector  = businessList.getBusinessInfos().getBusinessInfoVector();
for( int i = 0; i < businessInfoVector.size(); i++ )
{
//Service查询
//获得BusinessKey
BusinessInfo businessInfo = (BusinessInfo)businessInfoVector.elementAt(i);
businessKey=businessInfo.getBusinessKey();
//填名字
Vector service_names = new Vector();
service_names.add(new Name("%inquiry_service%"));
//设置FindQualifiers为“区分大小写模式”,直接用上面的就好
//查询service
ServiceList serviceList = proxy.find_service(businessKey,service_names,
null,tModelBag,findQualifiers,0);

//对每个service获得URL
Vector serviceInfoVector  = serviceList.getServiceInfos().getServiceInfoVector();
for( int j = 0; j < serviceInfoVector.size(); j++ )

//获得serviceKey
ServiceInfo serviceInfo = (ServiceInfo)serviceInfoVector.elementAt(j);
serviceKey=serviceInfo.getServiceKey();
//使用serviceDetail对象,找到其中的BindingTemplate,再从BindingTemplate中找到AccessPoint
serviceDetail = proxy.get_serviceDetail(serviceKey);
Vector businessServiceVector = serviceDetail.getBusinessServiceVector();
BusinessService businessService =(BusinessService) businessServiceVector.get(0);
Vector bindingTemplateVector=businessService.getBindingTemplates().getBindingTemplateVector();
bindingTemplate = (BindingTemplate)bindingTemplateVector.elementAt(0);
accessPoint = bindingTemplate.getAccessPoint();
URLlist.add(accessPoint.getText());
}// 里面的for
}//外面的for


return URLlist;
}
}

你可能感兴趣的:(div)