package webservice.uddi;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.Locale;
import java.util.Properties;
import javax.xml.registry.BulkResponse;
import javax.xml.registry.BusinessQueryManager;
import javax.xml.registry.Connection;
import javax.xml.registry.ConnectionFactory;
import javax.xml.registry.FindQualifier;
import javax.xml.registry.JAXRException;
import javax.xml.registry.RegistryService;
import javax.xml.registry.infomodel.ExternalLink;
import javax.xml.registry.infomodel.InternationalString;
import javax.xml.registry.infomodel.Organization;
import javax.xml.registry.infomodel.RegistryObject;
import javax.xml.registry.infomodel.Service;
import javax.xml.registry.infomodel.ServiceBinding;
import javax.xml.registry.infomodel.SpecificationLink;
public class uddiFindWebService {
public void exec()
throws JAXRException {
// RegistryService 객체 생성
RegistryService rs =
getConnection().getRegistryService();
// 인쿼리 작업을 위해서 BusinessQueryManager 객체 생성
BusinessQueryManager bqm =
rs.getBusinessQueryManager();
// 검색된 결과를 소팅하기 위해 Collection 객체 생성
Collection findQualifiers = new ArrayList();
findQualifiers.add(FindQualifier.SORT_BY_NAME_DESC);
// 회사 이름으로 찾기 위해 Collenction 객체 생성
Collection namePatterns = new ArrayList();
namePatterns.add("%test%");
// 회사 이름으로 찾기
BulkResponse response =
bqm.findOrganizations(findQualifiers, namePatterns, null, null, null, null);
// 검색된 모든 회사(Organization)을 얻어냄
Collection orgCollection = response.getCollection();
Iterator orgIterator = orgCollection.iterator();
while (orgIterator.hasNext()) {
// 한개의 회사(Organization)을 뽑아 냄
Organization org = (Organization) orgIterator.next();
// businessService 엘리먼트 내용에 대한 정보 얻기
System.out.println("n---businessService 엘리먼트 내용에 대한 정보 얻기---");
// 웹 서비스 정보 얻기
Collection serviceCollection = org.getServices();
Iterator serviceIterator = serviceCollection.iterator();
printWSList(serviceIterator);
}
}
/**
* 웹 서비스 리스트 출력
* @param serviceIterator
* @throws javax.xml.registry.JAXRException
*/
void printWSList(Iterator serviceIterator)
throws JAXRException {
while (serviceIterator.hasNext()) {
Service service = (Service)serviceIterator.next();
InternationalString localeServiceName = service.getName();
InternationalString localeServiceDesc = service.getDescription();
String strServiceName = localeServiceName.getValue(Locale.ENGLISH);
String strServiceDesc = localeServiceDesc.getValue(Locale.ENGLISH);
System.out.println("웹 서비스 이름: " + strServiceName);
System.out.println("웹 서비스 설명: " + strServiceDesc);
System.out.println("n---bindingTemplate 엘리먼트 내용에 대한 정보 얻기---");
Collection serviceBindingCollection = service.getServiceBindings();
Iterator serviceBindingIterator = serviceBindingCollection.iterator();
printWSBindingList(serviceBindingIterator);
}
}
/**
* 웹 서비스 바인딩 리스트 출력
* @param serviceBindingIterator
* @throws javax.xml.registry.JAXRException
*/
void printWSBindingList(Iterator serviceBindingIterator)
throws JAXRException {
while (serviceBindingIterator.hasNext()) {
ServiceBinding serviceBinding = (ServiceBinding)serviceBindingIterator.next();
String strAccessPointURL = serviceBinding.getAccessURI();
InternationalString localeAccssPointDesc = serviceBinding.getDescription();
String strAccessPointDesc = localeAccssPointDesc.getValue(Locale.ENGLISH);
System.out.println("웹 서비스 종점 URL: " + strAccessPointURL);
System.out.println("웹 서비스 종점 설명: " + strAccessPointDesc);
Collection specificaionLinksCollection = serviceBinding.getSpecificationLinks();
Iterator specificaionLinksIterator = specificaionLinksCollection.iterator();
printTmodeList(specificaionLinksIterator);
}
}
/**
* tModeList 출력
* @param specificaionLinksIterator
* @throws javax.xml.registry.JAXRException
*/
void printTmodeList(Iterator specificaionLinksIterator)
throws JAXRException {
while (specificaionLinksIterator.hasNext()) {
SpecificationLink specificationLink = (SpecificationLink)specificaionLinksIterator.next();
System.out.println("n---참조하는 tModel 엘리먼트 내용에 대한 정보 얻기---");
RegistryObject registryObject = specificationLink.getSpecificationObject();
InternationalString localeTModelName = registryObject.getName();
String strTModelName = localeTModelName.getValue();
System.out.println("tModel 이름: " + strTModelName);
InternationalString localeRegistryObject = registryObject.getDescription();
String strTModelDesc = localeRegistryObject.getValue(Locale.ENGLISH);
System.out.println("tModel 설명: " + strTModelDesc);
System.out.println("n---overviewDoc 엘리먼트 내용에 대한 정보 얻기---");
Collection externalLinksCollection = registryObject.getExternalLinks();
Iterator externalLinksIterator = externalLinksCollection.iterator();
printWSDLList(externalLinksIterator);
}
}
/**
* WSDL 문서 정보 출력
* @param externalLinksIterator
* @throws javax.xml.registry.JAXRException
*/
void printWSDLList(Iterator externalLinksIterator)
throws JAXRException {
while (externalLinksIterator.hasNext()) {
ExternalLink externalLink = (ExternalLink)externalLinksIterator.next();
String strWSDLURL = externalLink.getExternalURI();
System.out.println("WSDL 문서 URL: " + strWSDLURL);
InternationalString localeWSDLDesc = externalLink.getDescription();
String strWSDLDesc = localeWSDLDesc.getValue(Locale.ENGLISH);
System.out.println("WSDL 문서 설명: " + strWSDLDesc);
}
}
/**
* Connection 객체를 생산하는 ConnectionFactory 객체 생성
* JAXR 프로바이더의 연결을 위한 Connection 객체 생성
* @return Connection
* @throws javax.xml.registry.JAXRException
*/
Connection getConnection()
throws JAXRException {
ConnectionFactory factory = ConnectionFactory.newInstance();
factory.setProperties(setProperty());
Connection connection = factory.createConnection();
return connection;
}
/**
* JAXR 프로바이더와 연결하기 위한 정보 셋팅
* @return 프로퍼티
*/
Properties setProperty() {
Properties props = new Properties();
props.setProperty("javax.xml.registry.queryManagerURL",
"http://uddi.microsoft.com/inquire");
return props;
}
public static void main(String[] args) {
uddiFindWebService uddiClient = new uddiFindWebService();
try {
uddiClient.exec();
} catch (JAXRException e) {
e.printStackTrace();
}
}
} |
---businessService 엘리먼트 내용에 대한 정보 얻기---
웹 서비스 이름: null
웹 서비스 설명: null
---bindingTemplate 엘리먼트 내용에 대한 정보 얻기---
웹 서비스 종점 URL: CMS
웹 서비스 종점 설명: null
---참조하는 tModel 엘리먼트 내용에 대한 정보 얻기---
tModel 이름: UDDI_tModel
tModel 설명: null
---overviewDoc 엘리먼트 내용에 대한 정보 얻기---
WSDL 문서 URL: http://203.247.150.218/CMS/webServiceProductInfo/wsProductInfo.asmx
WSDL 문서 설명: null
… |