axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hemap...@apache.org
Subject svn commit: r170873 - in /webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi: Call.java InOnlyMEPClient.java InOutMEPClient.java MEPClient.java
Date Thu, 19 May 2005 05:28:13 GMT
Author: hemapani
Date: Wed May 18 22:28:13 2005
New Revision: 170873

URL: http://svn.apache.org/viewcvs?rev=170873&view=rev
Log:
fine tuning the Client API

Modified:
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/Call.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/InOnlyMEPClient.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/InOutMEPClient.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/MEPClient.java

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/Call.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/Call.java?rev=170873&r1=170872&r2=170873&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/Call.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/Call.java Wed May
18 22:28:13 2005
@@ -28,21 +28,16 @@
 import org.apache.axis.description.GlobalDescription;
 import org.apache.axis.description.OperationDescription;
 import org.apache.axis.description.ServiceDescription;
-import org.apache.axis.description.TransportInDescription;
-import org.apache.axis.description.TransportOutDescription;
 import org.apache.axis.engine.AxisFault;
 import org.apache.axis.engine.AxisSystemImpl;
-import org.apache.axis.om.OMAbstractFactory;
 import org.apache.axis.om.OMElement;
 import org.apache.axis.soap.SOAPEnvelope;
-import org.apache.axis.soap.SOAPFactory;
 
 /**
  * This class is the pretty convineance class for the user without see the comlplexites of
Axis2.
  */
 public class Call extends InOutMEPClient {
     private HashMap properties;
-    private boolean isEnvelope = false;
 
     public Call() throws AxisFault {
         super(assumeServiceContext());
@@ -69,15 +64,11 @@
             axisConfig = new OperationDescription(new QName(axisop));
             serviceContext.getServiceConfig().addOperation(axisConfig);
         }
-        MessageContext msgctx = prepareTheSystem(axisConfig, toSend);
+        MessageContext msgctx = prepareTheSystem(toSend);
 
         MessageContext responseContext = super.invokeBlocking(axisConfig, msgctx);
         SOAPEnvelope resEnvelope = responseContext.getEnvelope();
-        if (isEnvelope) {
-            return resEnvelope;
-        } else {
-            return resEnvelope.getBody().getFirstElement();
-        }
+        return resEnvelope.getBody().getFirstElement();
     }
     /**
      * Invoke the nonblocking/Asynchronous call
@@ -96,46 +87,12 @@
             axisConfig = new OperationDescription(new QName(axisop));
             serviceContext.getServiceConfig().addOperation(axisConfig);
         }
-        MessageContext msgctx = prepareTheSystem(axisConfig, toSend);
+        MessageContext msgctx = prepareTheSystem(toSend);
 
         super.invokeNonBlocking(axisConfig, msgctx, callback);
     }
 
-    /**
-     * Prepare the MessageContext, this is Utility method
-     * @param axisOp
-     * @param toSend
-     * @return
-     * @throws AxisFault
-     */
-
-    private MessageContext prepareTheSystem(OperationDescription axisOp, OMElement toSend)
-        throws AxisFault {
-        ConfigurationContext syscontext = serviceContext.getEngineContext();
-        //Make sure the ServiceDescription object has the OperationDescription
-        serviceContext.getServiceConfig().addOperation(axisOp);
-
-        TransportInDescription transportIn =
-            syscontext.getEngineConfig().getTransportIn(new QName(listenertransport));
-        TransportOutDescription transportOut =
-            syscontext.getEngineConfig().getTransportOut(new QName(senderTransport));
-
-        MessageContext msgctx = new MessageContext(null, transportIn, transportOut, syscontext);
-
-        SOAPEnvelope envelope = null;
-
-        if (toSend instanceof SOAPEnvelope) {
-            envelope = (SOAPEnvelope) toSend;
-            isEnvelope = true;
-        } else {
-            SOAPFactory omfac = OMAbstractFactory.getSOAP11Factory();
-            envelope = omfac.getDefaultEnvelope();
-            envelope.getBody().addChild(toSend);
-            isEnvelope = false;
-        }
-        msgctx.setEnvelope(envelope);
-        return msgctx;
-    }
+  
 
     /**
      * Assume the values for the ConfigurationContext and ServiceContext to make the NON
WSDL cases simple.
@@ -146,27 +103,6 @@
         EngineContextFactory efac = new EngineContextFactory();
         ConfigurationContext sysContext = efac.buildClientEngineContext(null);
         new ConfigurationContext(new AxisSystemImpl(new GlobalDescription()));
-
-//        //Add the addressing modules
-//        ModuleDescription addressingModule = new ModuleDescription();
-//        addressingModule.setName(new QName("addressing"));
-//        Flow inflow = new FlowImpl();
-//        HandlerDescription handlerDesc = new HandlerDescription();
-//        handlerDesc.setRules(new PhaseRule(PhaseMetadata.PHASE_PRE_DISPATCH));
-//        handlerDesc.setHandler(new AddressingInHandler());
-//        inflow.addHandler(handlerDesc);
-//        addressingModule.setInFlow(inflow);
-//
-//        Flow outflow = new FlowImpl();
-//        handlerDesc = new HandlerDescription();
-//        handlerDesc.setRules(new PhaseRule(PhaseMetadata.PHASE_PRE_DISPATCH));
-//        handlerDesc.setHandler(new AddressingOutHandler());
-//        outflow.addHandler(handlerDesc);
-//        addressingModule.setInFlow(outflow);
-//        addressingModule.setModule(new AddressingModule());
-//        sysContext.getEngineConfig().addMdoule(addressingModule);
-//        sysContext.getEngineConfig().getGlobal().addModule(addressingModule.getName());
-
 
         //create new service
         QName assumedServiceName = new QName("AnonnoymousService");

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/InOnlyMEPClient.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/InOnlyMEPClient.java?rev=170873&r1=170872&r2=170873&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/InOnlyMEPClient.java
(original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/InOnlyMEPClient.java
Wed May 18 22:28:13 2005
@@ -17,26 +17,70 @@
  */
 package org.apache.axis.clientapi;
 
+import javax.xml.namespace.QName;
+
 import org.apache.axis.addressing.EndpointReference;
 import org.apache.axis.addressing.MessageInformationHeadersCollection;
 import org.apache.axis.addressing.miheaders.RelatesTo;
+import org.apache.axis.context.ConfigurationContext;
 import org.apache.axis.context.MessageContext;
 import org.apache.axis.context.ServiceContext;
 import org.apache.axis.description.OperationDescription;
+import org.apache.axis.description.TransportInDescription;
+import org.apache.axis.engine.AxisConfiguration;
+import org.apache.axis.engine.AxisEngine;
+import org.apache.axis.engine.AxisFault;
+import org.apache.axis.soap.SOAPEnvelope;
+import org.apache.axis.transport.TransportReceiver;
+import org.apache.axis.transport.http.HTTPTransportReceiver;
+import org.apache.wsdl.WSDLConstants;
 
-
-public class InOnlyMEPClient extends MEPClient{
-    private MessageInformationHeadersCollection messageInformationHeaders;
-    /**
-     * @param service
-     */
+public class InOnlyMEPClient extends MEPClient {
+    protected MessageInformationHeadersCollection messageInformationHeaders;
+    protected String senderTransport;
+    
+    
     public InOnlyMEPClient(ServiceContext service) {
-        super(service);
-        // TODO Auto-generated constructor stub
+        super(service,WSDLConstants.MEP_URI_IN_ONLY);
     }
-    
-    public void send(OperationDescription axisop, final MessageContext msgctx){
-  
+
+    public void send(OperationDescription axisop, final MessageContext msgctx) throws AxisFault
{
+        verifyInvocation(axisop);
+        msgctx.setMessageInformationHeaders(messageInformationHeaders);
+        msgctx.setServiceContext(serviceContext);
+        ConfigurationContext syscontext = serviceContext.getEngineContext();
+        TransportInDescription transportIn =
+            syscontext.getEngineConfig().getTransportIn(new QName(senderTransport));
+        msgctx.setTransportIn(transportIn);
+
+        ConfigurationContext sysContext = serviceContext.getEngineContext();
+        AxisConfiguration registry = sysContext.getEngineConfig();
+
+        AxisEngine engine = new AxisEngine(sysContext);
+        msgctx.setOperationContext(axisop.findOperationContext(msgctx,serviceContext,false));
+
+        engine.send(msgctx);
+
+        MessageContext response =
+            new MessageContext(
+                msgctx.getSessionContext(),
+                msgctx.getTransportIn(),
+                msgctx.getTransportOut(),
+                msgctx.getSystemContext());
+        response.setProperty(
+            MessageContext.TRANSPORT_READER,
+            msgctx.getProperty(MessageContext.TRANSPORT_READER));
+        response.setServerSide(false);
+        response.setOperationContext(msgctx.getOperationContext());
+        response.setServiceContext(msgctx.getServiceContext());
+
+        //TODO Fix this we support only the HTTP Sync cases, so we hardcode this
+        TransportReceiver receiver = new HTTPTransportReceiver();
+        receiver.invoke(response, sysContext);
+        SOAPEnvelope resenvelope = response.getEnvelope();
+        if (response!= null && resenvelope.getBody().hasFault()) {
+            throw new AxisFault(resenvelope.getBody().getFault().getException());
+        }
     }
 
     /**

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/InOutMEPClient.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/InOutMEPClient.java?rev=170873&r1=170872&r2=170873&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/InOutMEPClient.java
(original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/InOutMEPClient.java
Wed May 18 22:28:13 2005
@@ -65,7 +65,7 @@
     protected EndpointReference to;
 
     public InOutMEPClient(ServiceContext serviceContext) {
-        super(serviceContext);
+        super(serviceContext,WSDLConstants.MEP_URI_OUT_IN);
         //service context has the engine context set in to it ! 
         callbackReceiver = new CallbackReceiver();
         listenerManager = new ListenerManager(serviceContext.getEngineContext());

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/MEPClient.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/MEPClient.java?rev=170873&r1=170872&r2=170873&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/MEPClient.java
(original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/MEPClient.java
Wed May 18 22:28:13 2005
@@ -17,23 +17,47 @@
  */
 package org.apache.axis.clientapi;
 
+import org.apache.axis.context.MessageContext;
 import org.apache.axis.context.ServiceContext;
 import org.apache.axis.description.OperationDescription;
 import org.apache.axis.engine.AxisFault;
+import org.apache.axis.om.OMAbstractFactory;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.soap.SOAPEnvelope;
+import org.apache.axis.soap.SOAPFactory;
 
 /**
  * This is the Super Class for all the MEPClients, All the MEPClient will extend this.
  */
 public abstract class MEPClient {
     protected ServiceContext serviceContext;
-    public MEPClient(ServiceContext service){
+    protected final String mep;
+    
+    public MEPClient(ServiceContext service,String mep){
         this.serviceContext = service;
+        this.mep = mep;
     }
     
     protected void verifyInvocation(OperationDescription axisop) throws AxisFault{
         if(axisop == null){
             throw new AxisFault("OperationDescription can not be null");
          }   
+         
+         if(mep.equals(axisop.getMessageExchangePattern() )){
+             throw new AxisFault("This mepClient supports only "+ mep + " And the Axis Operations
suppiled supports "+ axisop.getMessageExchangePattern());
+         }
     }
+    
+    protected MessageContext prepareTheSystem(OMElement toSend) throws AxisFault {
+         MessageContext msgctx =
+             new MessageContext(null, null, null, serviceContext.getEngineContext());
+
+         SOAPEnvelope envelope = null;
+         SOAPFactory omfac = OMAbstractFactory.getSOAP11Factory();
+         envelope = omfac.getDefaultEnvelope();
+         envelope.getBody().addChild(toSend);
+         msgctx.setEnvelope(envelope);
+         return msgctx;
+     }
 
 }



Mime
View raw message