You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by la...@apache.org on 2011/09/06 23:08:53 UTC
svn commit: r1165849 - in /incubator/airavata/trunk/modules/gfac-axis2:
pom.xml
src/main/java/org/apache/airavata/services/gfac/axis2/reciever/GFacMessageReciever.java
src/main/java/org/apache/airavata/services/gfac/axis2/utils/GFacServiceOperations.java
Author: lahiru
Date: Tue Sep 6 21:08:52 2011
New Revision: 1165849
URL: http://svn.apache.org/viewvc?rev=1165849&view=rev
Log:
adding gfac-axis2 getWSDL changes to give a full wsdl and an abstract wsdl.
Modified:
incubator/airavata/trunk/modules/gfac-axis2/pom.xml
incubator/airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/reciever/GFacMessageReciever.java
incubator/airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/utils/GFacServiceOperations.java
Modified: incubator/airavata/trunk/modules/gfac-axis2/pom.xml
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-axis2/pom.xml?rev=1165849&r1=1165848&r2=1165849&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-axis2/pom.xml (original)
+++ incubator/airavata/trunk/modules/gfac-axis2/pom.xml Tue Sep 6 21:08:52 2011
@@ -51,6 +51,12 @@
<artifactId>jcr</artifactId>
<version>2.0</version>
</dependency>
+ <dependency>
+ <groupId>wsdl4j</groupId>
+ <artifactId>wsdl4j</artifactId>
+ <version>1.6.2</version>
+ </dependency>
+
</dependencies>
<build>
<plugins>
Modified: incubator/airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/reciever/GFacMessageReciever.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/reciever/GFacMessageReciever.java?rev=1165849&r1=1165848&r2=1165849&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/reciever/GFacMessageReciever.java (original)
+++ incubator/airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/reciever/GFacMessageReciever.java Tue Sep 6 21:08:52 2011
@@ -21,12 +21,20 @@ package org.apache.airavata.services.gfa
*
*/
+import java.io.ByteArrayInputStream;
import java.io.StringReader;
+import java.text.BreakIterator;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import javax.jcr.Credentials;
import javax.jcr.Repository;
+import javax.wsdl.Definition;
+import javax.wsdl.PortType;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.wsdl.xml.WSDLWriter;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;
@@ -59,6 +67,7 @@ import org.apache.axis2.util.MessageCont
import org.apache.axis2.util.Utils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.xml.sax.InputSource;
public class GFacMessageReciever implements MessageReceiver {
@@ -70,6 +79,13 @@ public class GFacMessageReciever impleme
GFacServiceOperations operation = GFacServiceOperations.valueFrom(axisRequestMsgCtx.getOperationContext()
.getOperationName());
switch (operation) {
+ case GETABSTRACTWSDL:
+ try {
+ processgetAbstractWSDLOperation(axisRequestMsgCtx);
+ } catch (Exception e) {
+ throw new AxisFault("Error retrieving the WSDL");
+ }
+ log.info("getWSDL operation invoked !!");
case INVOKE:
try {
processInvokeOperation(axisRequestMsgCtx);
@@ -77,7 +93,6 @@ public class GFacMessageReciever impleme
} catch (Exception e) {
throw new AxisFault("Error Invoking the service");
}
- break;
case GETWSDL:
try {
processgetWSDLOperation(axisRequestMsgCtx);
@@ -203,6 +218,41 @@ public class GFacMessageReciever impleme
new StringReader(jcr.getWSDL(serviceName)));
StAXOMBuilder builder = new StAXOMBuilder(reader);
OMElement wsdlElement = builder.getDocumentElement();
+ WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(wsdlElement.toString().getBytes());
+ InputSource source = new InputSource(byteArrayInputStream);
+ Definition wsdlDefinition = wsdlReader.readWSDL(null, source);
+ //TODO based on the abstact wsdl content fill up the required information using wsdl4j api
+ SOAPFactory sf = OMAbstractFactory.getSOAP11Factory();
+ SOAPEnvelope responseEnv = sf.createSOAPEnvelope();
+ sf.createSOAPBody(responseEnv);
+ responseEnv.getBody().addChild(wsdlElement);
+ response = MessageContextBuilder.createOutMessageContext(messageContext);
+ response.setEnvelope(responseEnv);
+ response.getOperationContext().addMessageContext(response);
+ AxisEngine.send(response);
+ } catch (Exception fault) {
+ log.error("Error creating response");
+ throw fault;
+ }
+ }
+
+ public void processgetAbstractWSDLOperation(MessageContext messageContext) throws Exception {
+ MessageContext response = null;
+ String serviceName = getOriginalServiceName(messageContext);
+ ConfigurationContext context = messageContext.getConfigurationContext();
+ // todo this logic has to change based on the logic we are storing data
+ // into repository
+ try {
+ Credentials credentials = (Credentials) context.getProperty("credentials");
+ Repository repo = (Repository) context.getProperty("repository");
+
+ JCRRegistry jcr = new JCRRegistry(repo, credentials);
+
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(
+ new StringReader(jcr.getWSDL(serviceName)));
+ StAXOMBuilder builder = new StAXOMBuilder(reader);
+ OMElement wsdlElement = builder.getDocumentElement();
SOAPFactory sf = OMAbstractFactory.getSOAP11Factory();
SOAPEnvelope responseEnv = sf.createSOAPEnvelope();
sf.createSOAPBody(responseEnv);
Modified: incubator/airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/utils/GFacServiceOperations.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/utils/GFacServiceOperations.java?rev=1165849&r1=1165848&r2=1165849&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/utils/GFacServiceOperations.java (original)
+++ incubator/airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/utils/GFacServiceOperations.java Tue Sep 6 21:08:52 2011
@@ -22,7 +22,7 @@ package org.apache.airavata.services.gfa
public enum GFacServiceOperations {
- GETWSDL("getWSDL"), INVOKE("invoke");
+ GETWSDL("getWSDL"), INVOKE("invoke"), GETABSTRACTWSDL("getAbstractWSDL");
private final String name;