直接バインディング起動APIの使用例
この項では、APIの使用方法について説明します。接続パラメータを設定し、直接バインディングによってSOAコンポジット・アプリケーションを起動する方法、および直接バインディング起動を起動するようにメッセージ・オブジェクトを変更する方法を示します。
// The JNDIDirectConnectionFactory can be used to establish SOA instance // connections for exchanging messages over the direct binding. DirectConnectionFactory dcFactory = JNDIDirectConnectionFactory.newInstance(); // Connections are created based on the configuration, which is a map of standard // naming properties, which will be used for the underlying connection lookup. Map<String, Object> properties = new HashMap<String, Object>(); properties.put(Context.INITIAL_CONTEXT_FACTORY, jndi.WLInitialContextFactory"); properties.put(Context.PROVIDER_URL, "t3://HOST:PORT"); properties.put(Context.SECURITY_PRINCIPAL, USERNAME); properties.put(Context.SECURITY_CREDENTIALS, PASSWORD); DirectConnection conn = dcFactory.createConnection("soadirect:/default/MyComposite!1.0/MyService", properties);
// Messages are created using the MessageFactory // Message objects are subsequently modified to be used for an invocation. Message<Element> request = XMLMessageFactory.getInstance().createMessage(); // Define a Map of WSDL part names to matching XML Element objects Map<String, Element> partData; Payload<Element> payload = PayloadFactory.createXMLPayload(partData); request.setPayload(payload); // One-way invocation conn.post("onewayoperation", request); // Request-reply invocation Message<Element> response = conn.request("requestreplyoperation", request);
Hashtable jndiProps = new Hashtable(); jndiProps.put(Context.PROVIDER_URL, "t3://" + HOST + ':' + PORT); jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory"); jndiProps.put(Context.SECURITY_PRINCIPAL,USERNAME); jndiProps.put(Context.SECURITY_CREDENTIALS, PASSWORD); Locator locator = LocatorFactory.createLocator(jndiProps); CompositeDN compositedn = new CompositeDN(domainName, compositename, version); String serviceName = "HelloEntry"; DirectConnection conn = locator.createDirectConnection(compositedn, serviceName);