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!

Comments:

  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

Posted by Donghee Lee on August 19, 2009 at 08:16 PM PDT #

I tried the above but getting the below error: Apr 23, 2010 10:54:54 PM com.sun.corba.se.impl.encoding.CDRInputStream_1_0 read_value WARNING: "IOP00810211: (MARSHAL) Exception from readValue on ValueHandler in CDRInputStream" org.omg.CORBA.MARSHAL: vmcid: SUN minor code: 211 completed: Maybe at com.sun.corba.se.impl.logging.ORBUtilSystemException.valuehandlerReadException(Unknown Source) at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_value(Unknown Source) at com.sun.corba.se.impl.encoding.CDRInputStream.read_value(Unknown Source) at com.sun.corba.se.impl.io.IIOPInputStream.inputObjectField(Unknown Source) at com.sun.corba.se.impl.io.IIOPInputStream.inputClassFields(Unknown Source) at com.sun.corba.se.impl.io.IIOPInputStream.inputObject(Unknown Source) at com.sun.corba.se.impl.io.IIOPInputStream.simpleReadObject(Unknown Source) at com.sun.corba.se.impl.io.ValueHandlerImpl.readValueInternal(Unknown Source) at com.sun.corba.se.impl.io.ValueHandlerImpl.readValue(Unknown Source) at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_value(Unknown Source) at com.sun.corba.se.impl.encoding.CDRInputStream.read_value(Unknown Source) at com.sun.corba.se.impl.io.IIOPInputStream.inputObjectField(Unknown Source) at com.sun.corba.se.impl.io.IIOPInputStream.inputClassFields(Unknown Source) at com.sun.corba.se.impl.io.IIOPInputStream.inputObject(Unknown Source) at com.sun.corba.se.impl.io.IIOPInputStream.simpleReadObject(Unknown Source) at com.sun.corba.se.impl.io.ValueHandlerImpl.readValueInternal(Unknown Source) at com.sun.corba.se.impl.io.ValueHandlerImpl.readValue(Unknown Source) at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_value(Unknown Source) at com.sun.corba.se.impl.encoding.CDRInputStream.read_value(Unknown Source) at com.sun.corba.se.impl.io.IIOPInputStream.inputObjectField(Unknown Source) at com.sun.corba.se.impl.io.IIOPInputStream.inputClassFields(Unknown Source) at com.sun.corba.se.impl.io.IIOPInputStream.inputObject(Unknown Source) at com.sun.corba.se.impl.io.IIOPInputStream.simpleReadObject(Unknown Source) at com.sun.corba.se.impl.io.ValueHandlerImpl.readValueInternal(Unknown Source) at com.sun.corba.se.impl.io.ValueHandlerImpl.readValue(Unknown Source) at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_value(Unknown Source) at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_value(Unknown Source) at com.sun.corba.se.impl.encoding.CDRInputStream.read_value(Unknown Source) at com.sun.corba.se.spi.servicecontext.UEInfoServiceContext.(Unknown Source) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at com.sun.corba.se.spi.servicecontext.ServiceContextData.makeServiceContext(Unknown Source) at com.sun.corba.se.spi.servicecontext.ServiceContexts.unmarshal(Unknown Source) at com.sun.corba.se.spi.servicecontext.ServiceContexts.get(Unknown Source) at com.sun.corba.se.spi.servicecontext.ServiceContexts.get(Unknown Source) at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.processResponse(Unknown Source) at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.marshalingComplete(Unknown Source) at com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl.invoke(Unknown Source) at org.omg.CORBA.portable.ObjectImpl._invoke(Unknown Source) at oracle.soa.management.internal.ejb.impl._FacadeFinderBean_4vacyo_FacadeFinderBeanImpl_Stub.executeServiceMethod(Unknown Source) at oracle.soa.management.internal.ejb.EJBLocatorImpl.executeServiceMethod(EJBLocatorImpl.java:883) at oracle.soa.management.internal.facade.ServiceImpl.request(ServiceImpl.java:118) at src.StartProcess.(StartProcess.java:103) at src.StartProcess.main(StartProcess.java:182) Caused by: java.lang.IllegalArgumentException: No enum const class oracle.fabric.common.FabricInvocationException$RetryType.Error while parsing XML text. error while parsing the XML text SRIVENKATESH. The XML text was invalid because Namespace prefix 'ns1' used but not declared.. Verify that the XML text is valid. at java.lang.Enum.valueOf(Unknown Source) at com.sun.corba.se.impl.io.IIOPInputStream.inputObject(Unknown Source) at com.sun.corba.se.impl.io.IIOPInputStream.simpleReadObject(Unknown Source) at com.sun.corba.se.impl.io.ValueHandlerImpl.readValueInternal(Unknown Source) at com.sun.corba.se.impl.io.ValueHandlerImpl.readValue(Unknown Source) ... 45 more org.omg.CORBA.UNKNOWN: vmcid: 0x0 minor code: 0 completed: Maybe at com.sun.corba.se.spi.servicecontext.UEInfoServiceContext.(Unknown Source) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at com.sun.corba.se.spi.servicecontext.ServiceContextData.makeServiceContext(Unknown Source) at com.sun.corba.se.spi.servicecontext.ServiceContexts.unmarshal(Unknown Source) at com.sun.corba.se.spi.servicecontext.ServiceContexts.get(Unknown Source) at com.sun.corba.se.spi.servicecontext.ServiceContexts.get(Unknown Source) at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.processResponse(Unknown Source) at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.marshalingComplete(Unknown Source) at com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl.invoke(Unknown Source) at org.omg.CORBA.portable.ObjectImpl._invoke(Unknown Source) at oracle.soa.management.internal.ejb.impl._FacadeFinderBean_4vacyo_FacadeFinderBeanImpl_Stub.executeServiceMethod(Unknown Source) at oracle.soa.management.internal.ejb.EJBLocatorImpl.executeServiceMethod(EJBLocatorImpl.java:883) at oracle.soa.management.internal.facade.ServiceImpl.request(ServiceImpl.java:118) at src.StartProcess.(StartProcess.java:103) at src.StartProcess.main(StartProcess.java:182) oracle.fabric.common.FabricInvocationException: org.omg.CORBA.UNKNOWN: vmcid: 0x0 minor code: 0 completed: Maybe at oracle.soa.management.internal.facade.ServiceImpl.request(ServiceImpl.java:135) at src.StartProcess.(StartProcess.java:103) at src.StartProcess.main(StartProcess.java:182) Caused by: org.omg.CORBA.UNKNOWN: vmcid: 0x0 minor code: 0 completed: Maybe at com.sun.corba.se.spi.servicecontext.UEInfoServiceContext.(Unknown Source) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at com.sun.corba.se.spi.servicecontext.ServiceContextData.makeServiceContext(Unknown Source) at com.sun.corba.se.spi.servicecontext.ServiceContexts.unmarshal(Unknown Source) at com.sun.corba.se.spi.servicecontext.ServiceContexts.get(Unknown Source) at com.sun.corba.se.spi.servicecontext.ServiceContexts.get(Unknown Source) at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.processResponse(Unknown Source) at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.marshalingComplete(Unknown Source)IN CATCH 777 :oracle.fabric.common.FabricInvocationException: org.omg.CORBA.UNKNOWN: vmcid: 0x0 minor code: 0 completed: Maybe at com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl.invoke(Unknown Source) at org.omg.CORBA.portable.ObjectImpl._invoke(Unknown Source) at oracle.soa.management.internal.ejb.impl._FacadeFinderBean_4vacyo_FacadeFinderBeanImpl_Stub.executeServiceMethod(Unknown Source) at oracle.soa.management.internal.ejb.EJBLocatorImpl.executeServiceMethod(EJBLocatorImpl.java:883) at oracle.soa.management.internal.facade.ServiceImpl.request(ServiceImpl.java:118) ... 2 more java.lang.NullPointerException at src.StartProcess.(StartProcess.java:111)RES 44 : null at src.StartProcess.main(StartProcess.java:182) Here is the my code: package src; import java.util.Hashtable; import java.util.UUID; import java.util.List; import javax.naming.Context; import oracle.soa.management.facade.Locator; import oracle.soa.management.facade.LocatorFactory; import oracle.soa.management.facade.Composite; import oracle.soa.management.facade.Service; import oracle.soa.management.facade.CompositeInstance; import oracle.soa.management.facade.ComponentInstance; import oracle.fabric.common.NormalizedMessage; import oracle.fabric.common.NormalizedMessageImpl; import oracle.soa.management.util.CompositeInstanceFilter; import oracle.soa.management.util.ComponentInstanceFilter; import java.util.Map; import javax.xml.transform.*; import javax.xml.transform.dom.*; import javax.xml.transform.stream.*; import org.w3c.dom.Element; import java.io.*; public class StartProcess { public StartProcess() { super(); Hashtable jndiProps = new Hashtable(); jndiProps.put(Context.PROVIDER_URL, "t3://xxxxxx: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"); StringBuffer xml = new StringBuffer(); //xml.append(""); //xml.append(""); xml.append(""); xml.append("SRI"); xml.append("VENKATESH"); xml.append(""); //xml.append(""); //xml.append(""); String inputPayload = "\n" + " 88\n" + "\n" ; System.out.println("PAYLOAD : "+xml); Locator locator = null; try { // connect to the soa server System.out.println("Service Locator : "+locator); locator = LocatorFactory.createLocator(jndiProps); System.out.println("Service Locator : "+locator); String compositeDN = "default/Project2!1.0"; System.out.println("Service Locator : "+locator); // find composite Composite composite = locator.lookupComposite("default/Project2!1.0"); //System.out.println("Got Composite : "+ composite.toString()); // find exposed service of the composite List svcList = composite.getServices(); System.out.println("SERVICE : "+svcList); Service service = composite.getService("bpelprocess1_client_ep"); System.out.println("Got serviceName : "+ service.toString()); // make the input request and add this to a operation of the service NormalizedMessage input = new NormalizedMessageImpl(); System.out.println("NormalizedMessage 111 : "+input); String uuid = "uuid:" + UUID.randomUUID(); System.out.println("UUID 222 : "+uuid); input.addProperty(NormalizedMessage.PROPERTY_CONVERSATION_ID,uuid); System.out.println("NormalizedMessage 333 : "+input); // payload is the partname of the process operation input.getPayload().put("payload",xml); System.out.println("NormalizedMessage 444 : "+input.toString()); // process is the operation of the employee service NormalizedMessage res = null; try { System.out.println("IN TRY 555 :"+input); System.out.println("SERVICE NAME : "+service.getName()); System.out.println("SERVICE COMPOSITE DN : "+service.getCompositeDN()); System.out.println("SERVICE WSDL URL : "+service.getWSDLURL()); System.out.println("SERVICE Bindings : "+service.getClass()); res = service.request("process", input); System.out.println("IN TRY 666 :"+res); } catch(Exception e) { System.out.println("IN CATCH 777 :"+e); e.printStackTrace(); } System.out.println("RES 44 : "+res); Map payload = res.getPayload(); Element element = (Element)payload.get("payload"); TransformerFactory tFactory = TransformerFactory.newInstance(); Transformer transformer = tFactory.newTransformer(); transformer.setOutputProperty("indent", "yes"); StringWriter sw = new StringWriter(); StreamResult result = new StreamResult(sw); DOMSource source = new DOMSource(element); transformer.transform(source, result); System.out.println("Result\n"+sw.toString()); System.out.println("instances"); CompositeInstanceFilter filter = new CompositeInstanceFilter(); filter.setMinCreationDate(new java.util.Date((System.currentTimeMillis() - 2000000))); // get composite instances by filter .. List obInstances = composite.getInstances(filter); // for each of the returned composite instances.. for (CompositeInstance instance : obInstances) { System.out.println(" DN: " + instance.getCompositeDN() + " Instance: " + instance.getId() + " creation-date: " + instance.getCreationDate() + " state (" + instance.getState() + "): " + getStateAsString(instance.getState()) ); // setup a component filter ComponentInstanceFilter cInstanceFilter = new ComponentInstanceFilter(); // get child component instances .. List childComponentInstances = instance.getChildComponentInstances(cInstanceFilter); // for each child component instance (e.g. a bpel process) for (ComponentInstance cInstance : childComponentInstances) { System.out.println(" -> componentinstance: " + cInstance.getComponentName() + " type: " + cInstance.getServiceEngine().getEngineType() + " state: " +getStateAsString(cInstance.getState()) ); System.out.println("State: "+cInstance.getNormalizedStateAsString() ); } } } catch (Exception e) { e.printStackTrace(); } } private String getStateAsString(int state) { // note that this is dependent on wheter the composite state is captured or not if (state == CompositeInstance.STATE_COMPLETED_SUCCESSFULLY) return ("success"); else if (state == CompositeInstance.STATE_FAULTED) return ("faulted"); else if (state == CompositeInstance.STATE_RECOVERY_REQUIRED) return ("recovery required"); else if (state == CompositeInstance.STATE_RUNNING) return ("running"); else if (state == CompositeInstance.STATE_STALE) return ("stale"); else return ("unknown"); } public static void main(String[] args) { StartProcess startUnitProcess = new StartProcess(); } }

Posted by Ravi on April 23, 2010 at 12:00 AM PDT #

Ravi What you put in your payload doesn't seem alright to me. it's not valid XML, and that's why it throws an error as "The XML text was invalid because Namespace prefix 'ns1' used but not declared.. Verify that the XML text is valid." Jay

Posted by changjae.lee on April 25, 2010 at 11:42 AM PDT #

ohh... its working noww.. Thanks a lot Jay. Thanks again. :)

Posted by Ravi on April 26, 2010 at 12:29 PM PDT #

Hi, I installed soa suite: ofm_soa_generic_11.1.1.2, but it does not have the requied 4 jars that have been mentioned here. Can you please let me know where can I get these jars from. Regards, Sanjay

Posted by Sanjay on July 12, 2010 at 03:45 PM PDT #

Hi Jay,

Can we invoke a SOA Composite service by creating Java proxy clients ?

Thanks,
Venu

Posted by Venu on May 27, 2013 at 05:58 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
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