1 package org.enhydra.shark.wfxml.test; 2 3 import java.net.MalformedURLException ; 4 import java.net.URL ; 5 import java.util.*; 6 7 import javax.xml.namespace.QName ; 8 9 import org.apache.axis.client.Call; 10 import org.apache.axis.encoding.DefaultTypeMappingImpl; 11 import org.apache.axis.encoding.ser.SimpleSerializerFactory; 12 import org.apache.axis.message.MessageElement; 13 import org.apache.axis.types.URI; 14 import org.enhydra.shark.asap.AsapBindingUtilitiesImpl; 15 import org.enhydra.shark.asap.AsapInstanceBindingStub; 16 import org.enhydra.shark.asap.types.*; 17 import org.enhydra.shark.asap.types.holders.*; 18 import org.enhydra.shark.wfxml.SharkWebServiceLocator; 19 import org.enhydra.shark.wfxml.WfXmlFactoryBindingStub; 20 import org.enhydra.shark.wfxml.util.AltBeanDeserializerFactory; 21 22 27 public class WfXmlKissClient extends junit.framework.TestCase { 28 static private URI ik; 29 30 static private Map factories = new HashMap(); 31 32 static private Map schemaLocactions = new HashMap(); 33 34 private static final String SERVICE = "Enhydra Shark Retailer"; 35 36 private static final String OBS = ""; 37 38 static { 39 factories.put("Fujitsu Retailer", 40 "http://interop.i-flow.com/ibpm/jsp/ProcDef.jsp?planName=Retailer"); 41 schemaLocactions.put("Fujitsu Retailer",""); 42 43 factories.put("Fujitsu Manufacturer", 44 "http://interop.i-flow.com/ibpm/jsp/ProcDef.jsp?planName=Manufacturer"); 45 schemaLocactions.put("Fujitsu Manufacturer","http://interop.i-flow.com/ibpm/jsp/contextData.jsp?pdid=152"); 46 47 factories.put("TIBCO Retailer", 48 "http://193.131.190.26:8080/ASAP/services/Factory?retail"); 49 schemaLocactions.put("TIBCO Retailer",""); 50 51 factories.put("TIBCO Manufacturer", 52 "http://bpm-interop.tibco.com:8080/ASAP/services/Factory?manufac"); 53 schemaLocactions.put("TIBCO Manufacturer","http://bpm-interop.tibco.com:8080/ASAP/schemas/context/manufac.xsd"); 54 55 factories.put("EasyASAP Retailer", "http://68.96.20.206:7777/asap_evm"); 56 schemaLocactions.put("EasyASAP Retailer",""); 57 58 factories.put("EasyASAP Manufacturer", 59 "http://68.96.20.206:7787/asap_evm"); 60 schemaLocactions.put("EasyASAP Manufacturer",""); 61 62 factories.put("Enhydra Shark Retailer", 63 "http://vajat.prozone.co.yu:8080/axis/services/wfxmlFactoryBinding?procDef=retailer&packageId=shark_retailer"); 64 schemaLocactions.put("Enhydra Shark Retailer",""); 65 66 factories.put("Enhydra Shark Manufacturer", 67 "http://vajat.prozone.co.yu:8080/axis/services/wfxmlFactoryBinding?procDef=manufacturer&packageId=shark_manufacturer"); 68 schemaLocactions.put("Enhydra Shark Manufacturer",""); 69 } 76 77 public WfXmlKissClient(java.lang.String name) { 78 super(name); 79 QName xmlType = new javax.xml.namespace.QName ("http://www.w3.org/2001/XMLSchema", 80 "anyType"); 81 DefaultTypeMappingImpl.getSingleton() 82 .register(String .class, 83 xmlType, 84 new SimpleSerializerFactory(String .class, 85 new javax.xml.namespace.QName ("http://www.w3.org/2001/XMLSchema", 86 "string")), 87 new AltBeanDeserializerFactory(String .class, 88 new javax.xml.namespace.QName ("http://www.w3.org/2001/XMLSchema", 89 "string"))); 90 } 91 92 public void qtest0wfxmlFactoryBindingGetProperties() throws Exception { 93 System.err.println(Call.SOAPACTION_USE_PROPERTY); 94 String uriString = (String ) factories.get(SERVICE); 95 WfXmlFactoryBindingStub binding = getFactoryBinding(uriString); 96 97 Request rqHead = new Request(null, 99 new URI(uriString), 100 YesNoIfError.No, 101 null); 102 String rqBody = ""; ResponseHolder rsHead = new ResponseHolder(); 104 GetPropertiesRsHolder rsBody = new GetPropertiesRsHolder(); 105 106 try { 108 binding.getProperties(rqHead, rqBody, rsHead, rsBody); 109 } catch (Throwable t) { 110 System.err.println("Throwable " 111 + t.getClass().getName() + "(" + t.getMessage() 112 + ")"); 113 } 114 Object [] oo = binding.getResponseHeaders(); 115 for (int n = 0; n < oo.length; ++n) { 116 System.err.println("" 117 + n + "#" 118 + binding.getResponseHeaders()[n].toString()); 119 } 120 System.err.println("res" + rsBody.value); 122 FactoryPropertiesGroup fpg = rsBody.value.getFactoryPropertiesGroup(); 123 System.err.println("Key=" + fpg.getKey()); 124 System.err.println("Name=" + fpg.getName()); 125 System.err.println("Subj=" + fpg.getSubject()); 126 System.err.println("desc=" + fpg.getDescription()); 127 try { 128 System.err.println("cds=" 129 + fpg.getContextDataSchema().get_any()[0].toString()); 130 System.err.println("rds=" 131 + fpg.getResultDataSchema().get_any()[0].toString()); 132 } catch (Throwable t) {} 133 } 134 135 public void test1wfxmlFactoryBindingCreateInstance() throws Exception { 136 String uriString = (String ) factories.get(SERVICE); 137 WfXmlFactoryBindingStub binding = getFactoryBinding(uriString); 138 139 Map m = new HashMap(); 140 m.put("product_code", new Long (111)); 141 m.put("product_quantity", new Long (221)); 142 m.put("order_number", new Long (4)); 143 m.put("order_date", new Date(System.currentTimeMillis())); 144 m.put("retailer_name", "vlada 323"); 145 Request rqHead = new Request(new URI(new SharkWebServiceLocator().getasapObserverBindingAddress()), 146 new URI(uriString), 147 YesNoIfError.Yes, 148 null); 149 CreateInstanceRq rqBody = new CreateInstanceRq(true, 150 new URI(new SharkWebServiceLocator().getasapObserverBindingAddress()), 151 "rqName", 152 "srqName", 153 "Enhydra Shark engine ", 154 AsapBindingUtilitiesImpl.getContextData(m, 155 (String ) schemaLocactions.get(SERVICE))); 156 ResponseHolder rsHead = new ResponseHolder(); 157 CreateInstanceRsHolder rsBody = new CreateInstanceRsHolder(); 158 rqHead.getSenderKey().setHost("vajat.prozone.co.yu"); 159 rqBody.getObserverKey().setHost("vajat.prozone.co.yu"); 161 binding.createInstance(rqHead, rqBody, rsHead, rsBody); 163 System.err.println("##" + rsBody.value.getInstanceKey()); 164 ik = rsBody.value.getInstanceKey(); 165 } 166 167 public void qqtestAsapInstanceBindingGetProperties() throws Exception { 168 Thread.sleep(70000); 169 AsapInstanceBindingStub binding; 170 try { 171 binding = (AsapInstanceBindingStub) new SharkWebServiceLocator().getasapInstanceBinding(new URL (ik.toString())); 172 } catch (javax.xml.rpc.ServiceException jre) { 173 if (jre.getLinkedCause() != null) jre.getLinkedCause() 174 .printStackTrace(); 175 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " 176 + jre); 177 } 178 assertNotNull("binding is null", binding); 179 180 binding.setTimeout(60000); 182 183 Request rqh = new Request(); 184 String rqb = ""; 185 ResponseHolder rsh = new ResponseHolder(); 186 GetPropertiesRsHolder rsb = new GetPropertiesRsHolder(); 187 rqh.setReceiverKey(ik); 188 189 System.err.println("##tt"); 190 binding.getProperties(rqh, rqb, rsh, rsb); 192 InstancePropertiesGroup ipg = rsb.value.getInstancePropertiesGroup(); 193 System.err.println("#ipg:" + ipg.getKey()); 194 System.err.println("#ipg:" + ipg.getFactoryKey()); 195 URI[] _obs_ = ipg.getObservers().getObserverKey(); 196 for (int n = 0; n < _obs_.length; ++n) { 197 System.err.println("#ipg" + n + ":" + _obs_[n]); 198 } 199 Event[] _ev_ = ipg.getHistory().getEvent(); 200 for (int n = 0; n < _ev_.length; ++n) { 201 System.err.println("#ipg" + n + "event:" + _ev_[n].getEventType()); 202 System.err.println("#ipg" + n + "event:" + _ev_[n].getTime()); 203 } 204 MessageElement[] ctx = ipg.getContextData().get_any(); 205 for (int n = 0; n < ctx.length; ++n) { 206 System.err.println("#ipg" + n + "ctx:" + ctx[n].toString()); 207 } 208 } 209 210 private WfXmlFactoryBindingStub getFactoryBinding(String uriString) throws MalformedURLException { 211 WfXmlFactoryBindingStub binding; 212 213 try { 214 binding = (WfXmlFactoryBindingStub) new SharkWebServiceLocator().getwfxmlFactoryBinding(new URL (uriString)); 215 } catch (javax.xml.rpc.ServiceException jre) { 216 if (jre.getLinkedCause() != null) jre.getLinkedCause() 217 .printStackTrace(); 218 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " 219 + jre); 220 } 221 assertNotNull("binding is null", binding); 222 223 binding.setTimeout(60000); 225 return binding; 226 } 227 } | Popular Tags |