Monday Aug 17, 2009

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!

About

Solution & Technology Architect, Asia Pacific

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today