모듈이 있는 구성요소는 WebSphere Process Server 클러스터의 모든 노드에서 구성요소를 사용할 수 있습니다.
ServiceManager serviceManager = new ServiceManager();
InputStream myReferences = new FileInputStream("MyReferences.references"); ServiceManager serviceManager = new ServiceManager(myReferences);
StockQuote stockQuote = (StockQuote)serviceManager.locateService("stockQuote");
Service stockQuote = (Service)serviceManager.locateService("stockQuote");
public class MyValueImpl implements MyValue { public float myValue throws MyValueException { ServiceManager serviceManager = new ServiceManager(); // variables Customer customer = null; float quote = 0; float value = 0; // invoke CustomerInfo cInfo = (CustomerInfo)serviceManager.locateService("customerInfo"); customer = cInfo.getCustomerInfo(customerID); if (customer.getErrorMsg().equals("")) { // invoke StockQuoteAsync sQuote = (StockQuoteAsync)serviceManager.locateService("stockQuote"); Ticket ticket = sQuote.getQuoteAsync(customer.getSymbol()); // … do something else … quote = sQuote.getQuoteResponse(ticket, Service.WAIT); // assign value = quote * customer.getNumShares(); } else { // throw throw new MyValueException(customer.getErrorMsg()); } // reply return value; } }
모듈이 WSDL(Web Service Descriptor Language) 포트 유형 인터페이스가 포함된 구성요소를 호출할 때 모듈은 invoke() 메소드를 사용하여 동적으로 구성요소를 호출해야 합니다.
Service service = (Service)serviceManager.locateService("multiParamInf"); Reference reference = service.getReference(); OperationType methodMultiType = reference.getOperationType("methodWithMultiParameter"); Type t = methodMultiType.getInputType(); BOFactory boFactory = (BOFactory)serviceManager.locateService ("com/ibm/websphere/bo/BOFactory"); DataObject paramObject = boFactory.createbyType(t); paramObject.set(0,"input1") paramObject.set(1,"input2") paramObject.set(2,"input3") service.invoke("methodMultiParamater",paramObject);
다음 예는 WSDL 포트 유형 인터페이스를 대상으로 가지는 호출 메소드를 사용합니다.
Service serviceOne = (Service)serviceManager.locateService("multiParamInfWSDL"); DataObject dob = factory.create("http://MultiCallWSServerOne/bos", "SameBO"); dob.setString("attribute1", stringArg); DataObject wrapBo = factory.createByElement ("http://MultiCallWSServerOne/wsdl/ServerOneInf", "methodOne"); wrapBo.set("input1", dob); //wrapBo encapsulates all the parameters of methodOne wrapBo.set("input2", "XXXX"); wrapBo.set("input3", "yyyy"); DataObject resBo= (DataObject)serviceOne.invoke("methodOne", wrapBo);
ⓒ Copyright IBM Corporation 2005, 2006.
이 Information Center는 Eclipse 기술을 기반으로 합니다. (http://www.eclipse.org)