1 57 package org.apache.wsif.providers.jca.toolplugin; 58 59 import java.util.Arrays ; 60 import java.util.Iterator ; 61 import java.util.Map ; 62 63 import javax.wsdl.Definition; 64 import javax.wsdl.Operation; 65 import javax.wsdl.PortType; 66 import javax.wsdl.Service; 67 import javax.xml.namespace.QName ; 68 69 import org.apache.wsif.WSIFException; 70 import org.apache.wsif.WSIFMessage; 71 import org.apache.wsif.WSIFOperation; 72 import org.apache.wsif.WSIFPort; 73 import org.apache.wsif.WSIFService; 74 import org.apache.wsif.WSIFServiceFactory; 75 76 82 public abstract class Import { 83 84 private static final long serialVersionUID = 1L; 85 86 private Definition serviceDefintion = null; 87 88 private Service importService = null; 89 90 private PortType importPortType = null; 91 92 93 94 public static final String IMPORT_SERVICE_BASE_NAMESPACE = "http://importservice.jca.providers.wsif.apache.org/"; 95 public static final String IMPORT_SERVICE_BASE_PORTTYPE_NAME = "Import"; 96 97 public static final String GET_PORTTYPES_OPERATION = "getPortTypes"; 98 public static final String GET_DEFINITION_OPERATION = "getDefinition"; 99 public static final String GET_RAW_EIS_METADATA_OPERATION = "getRawEISMetaData"; 100 101 public static final String PORT_TYPE_SELECTION_PART = "portTypeSelection"; 102 public static final String RESULT_PART = "result"; 103 public static final String QUERY_STRING_PART = "queryString"; 104 105 108 public Import() { 109 super(); 110 } 111 112 120 public Import(Definition aServiceDefinition, String aServiceName) throws WSIFException { 121 super(); 122 try { 123 serviceDefintion = aServiceDefinition; 124 importPortType = serviceDefintion.getPortType(new QName (IMPORT_SERVICE_BASE_NAMESPACE, IMPORT_SERVICE_BASE_PORTTYPE_NAME)); 125 importService = serviceDefintion.getService(new QName (serviceDefintion.getTargetNamespace(), aServiceName)); 126 } catch (Exception e) { 127 if (e instanceof WSIFException) 128 throw (WSIFException) e; 129 else 130 throw new WSIFException(e.getMessage(), e); 131 } 132 } 133 134 135 141 public PortTypeArray getPortTypes(String queryString) throws WSIFException { 142 try { 143 WSIFService portFactory = WSIFServiceFactory.newInstance().getService(serviceDefintion, importService, importPortType); 144 145 WSIFPort port = portFactory.getPort(); 146 147 WSIFOperation operation = port.createOperation(GET_PORTTYPES_OPERATION); 148 WSIFMessage inputMessage = operation.createInputMessage(); 149 WSIFMessage outputMessage = operation.createOutputMessage(); 150 inputMessage.setObjectPart(QUERY_STRING_PART, queryString); 151 152 operation.executeRequestResponseOperation(inputMessage, outputMessage, null); 153 154 PortTypeArray portTypeArray = (PortTypeArray) outputMessage.getObjectPart(RESULT_PART); 155 156 port.close(); 157 return portTypeArray; 158 } catch (Exception e) { 159 if (e instanceof WSIFException) 160 throw (WSIFException) e; 161 else 162 throw new WSIFException(e.getMessage(), e); 163 } 164 } 165 166 172 public ImportDefinition getDefinition(PortTypeSelection portTypeSelection) throws WSIFException { 173 try { 174 WSIFService portFactory = WSIFServiceFactory.newInstance().getService(serviceDefintion, importService, importPortType); 175 WSIFPort port = portFactory.getPort(); 176 177 WSIFOperation operation = port.createOperation(GET_DEFINITION_OPERATION); 178 WSIFMessage inputMessage = operation.createInputMessage(); 179 WSIFMessage outputMessage = operation.createOutputMessage(); 180 181 inputMessage.setObjectPart(PORT_TYPE_SELECTION_PART, portTypeSelection); 182 183 operation.executeRequestResponseOperation(inputMessage, outputMessage, null); 184 185 ImportDefinition importDefinition = (ImportDefinition) outputMessage.getObjectPart(RESULT_PART); 186 port.close(); 187 188 return importDefinition; 189 } catch (Exception e) { 190 if (e instanceof WSIFException) 191 throw (WSIFException) e; 192 else 193 throw new WSIFException(e.getMessage(), e); 194 } 195 196 } 197 198 204 public byte[] getRawEISMetaData(String queryString) throws WSIFException { 205 try { 206 WSIFService portFactory = WSIFServiceFactory.newInstance().getService(serviceDefintion, importService, importPortType); 207 208 WSIFPort port = portFactory.getPort(); 209 210 WSIFOperation operation = port.createOperation(GET_RAW_EIS_METADATA_OPERATION); 212 WSIFMessage inputMessage = operation.createInputMessage(); 213 WSIFMessage outputMessage = operation.createOutputMessage(); 214 inputMessage.setObjectPart(QUERY_STRING_PART, queryString); 215 216 operation.executeRequestResponseOperation(inputMessage, outputMessage, null); 217 218 byte[] byteArray = (byte[]) outputMessage.getObjectPart(RESULT_PART); 219 220 port.close(); 221 return byteArray; 222 } catch (Exception e) { 223 if (e instanceof WSIFException) 224 throw (WSIFException) e; 225 else 226 throw new WSIFException(e.getMessage(), e); 227 228 } 229 } 230 231 235 public PortType getImportPortType() { 236 return importPortType; 237 } 238 239 243 public Service getImportService() { 244 return importService; 245 } 246 247 251 public Definition getServiceDefintion() { 252 return serviceDefintion; 253 } 254 255 259 public void setImportPortType(PortType importPortType) { 260 this.importPortType = importPortType; 261 } 262 263 267 public void setImportService(Service importService) { 268 this.importService = importService; 269 } 270 271 275 public void setServiceDefintion(Definition serviceDefintion) { 276 this.serviceDefintion = serviceDefintion; 277 } 278 279 } | Popular Tags |