« gencon bug in IBM JDK earlier than SR5 | Main | Mediator JavaCallout Sample »

Invoking Composite from JAVA/JSP

According to Bug 8561287, we have to add "binding.adf" manually into composite.xml in order to invoke the composite with JAVA/JSP. I've spent quite a long time to figure this out as it's not clearly documented in our doc.

there are 4 libs that should be in the classpath.

1. fabric-common.jar located at
$SOA_HOME\Oracle_SOA1\modules\oracle.fabriccommon_11.1.1
2. soa-infra-mgmt.jar located at
$SOA_HOME\Oracle_SOA1\modules\oracle.soa.mgmt_11.1.1
3. wsclient_extended.jar located at
$SOA_HOME\Oracle_SOA1\webservices
4. weblogic.jar or wlfullclient.jar

next step is changing the composite.xml to add binding.adf like below(bold) :

  <service name="receivePO" ui:wsdlLocation="receivePO.wsdl">

    <interface.wsdl interface="http://oracle.com/sca/soapservice/POProcessing/PoProcessing/receivePO#wsdl.interface(execute_ptt)"/>

    <binding.ws port="http://oracle.com/sca/soapservice/POProcessing/PoProcessing/receivePO#wsdl.endpoint(receivePO/execute_pt)"/>

  </service>

  <service name="receivePO_BPEL" ui:wsdlLocation="receivePO.wsdl">

    <interface.wsdl interface="http://oracle.com/sca/soapservice/POProcessing/PoProcessing/receivePO#wsdl.interface(execute_ptt)"/>

    <binding.adf serviceName="bpel_client" registryName=""/>

  </service>


and actual java code :

Locator locator = null;
try {
Hashtable jndiProps = new Hashtable();
jndiProps.put(Context.PROVIDER_URL,
"t3://localhost:8001/soa-infra");
jndiProps.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
jndiProps.put(Context.SECURITY_PRINCIPAL, "weblogic");
jndiProps.put(Context.SECURITY_CREDENTIALS, "welcome1");
// jndiProps.put("dedicated.connection", "true");

locator = LocatorFactory.createLocator(jndiProps);
Composite composite = locator
.lookupComposite("default/PoProcessing!1.0");
List svcList = composite.getServices();
for (Service obj : svcList) {
System.out.println(" > Name=" + obj.getName() + ", WSDL="
+ obj.getWSDLURL());

}

StringBuffer xml = new StringBuffer();

xml.append("<ns1:PurchaseOrder xmlns:ns1=\"http://xmlns.oracle.com/ns/order\">");

xml.append("<ns1:CustID>1111</ns1:CustID>");

xml.append("<ns1:ID>2222</ns1:ID>");

xml.append("<ns1:productName>iPod shuffle</ns1:productName>");

xml.append("<ns1:itemType>Electronics</ns1:itemType>");

xml.append("<ns1:price>98765</ns1:price>");

xml.append("<ns1:quantity>30</ns1:quantity>");

xml.append("<ns1:status>Initial</ns1:status>");

xml.append("<ns1:ccType>Mastercard</ns1:ccType>");

xml.append("<ns1:ccNumber>1234-1234-1234-1234</ns1:ccNumber>");

xml.append("</ns1:PurchaseOrder>");


NormalizedMessage input = new NormalizedMessageImpl();
String operationName = "execute";

Document doc = SOAUtil.getDocumentBuilder(true).parse(new StringInputStream(xml.toString()));
//input.getPayload().put("payload", doc.getDocumentElement());
input.getPayload().put("request", doc.getDocumentElement());

Service svc = composite.getService("receivePO_BPEL");
svc.post(operationName, input);
System.out.println("End");
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (locator != null)
locator.close();
} catch (Exception e) {
}
}

this is it! good luck!

TrackBack

TrackBack URL for this entry:
http://blogs.oracle.com/mt/mt-tb.cgi/13452

Comments (1)

Donghee Lee:
  1. fabric-common.jar
    $SOA_HOME/modules/oracle.fabriccommon_11.1.1
  2. soa-infra-mgmt.jar
    $SOA_HOME/soa/modules/oracle.soa.mgmt_11.1.1
  3. wsclient_extended.jar
    $SOA_HOME\webservices
  4. weblogic.jar
    $WL_HOME/server/lib/weblogic.jar

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

About This Entry

This page contains a single entry from the blog posted on August 18, 2009 3:54 AM.

The previous post in this blog was gencon bug in IBM JDK earlier than SR5.

The next post in this blog is Mediator JavaCallout Sample.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type and Oracle