You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by de...@apache.org on 2006/07/04 06:45:39 UTC
svn commit: r418914 - in
/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2:
client/ServiceClient.java description/ClientUtils.java
Author: deepal
Date: Mon Jul 3 21:45:38 2006
New Revision: 418914
URL: http://svn.apache.org/viewvc?rev=418914&view=rev
Log:
- fixing fireAndForget invocation (using two channel)
Modified:
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/ServiceClient.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/ClientUtils.java
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/ServiceClient.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/ServiceClient.java?rev=418914&r1=418913&r2=418914&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/ServiceClient.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/ServiceClient.java Mon Jul 3 21:45:38 2006
@@ -18,11 +18,7 @@
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
-import org.apache.axiom.soap.SOAP12Constants;
-import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axiom.soap.SOAPFactory;
-import org.apache.axiom.soap.SOAPHeader;
-import org.apache.axiom.soap.SOAPHeaderBlock;
+import org.apache.axiom.soap.*;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.async.AsyncResult;
@@ -354,11 +350,65 @@
* received in response (per the Robust In-Only MEP).
*/
public void sendRobust(QName operation, OMElement elem) throws AxisFault {
- MessageContext mc = new MessageContext();
- fillSoapEnvelope(mc, elem);
- OperationClient mepClient = createClient(operation);
- mepClient.addMessageContext(mc);
- mepClient.execute(true);
+ if (options.isUseSeparateListener()) {
+
+ // This mean doing a Fault may come through a differnt channel .
+ // If the
+ // transport is two way transport (e.g. http) Only one channel is
+ // used (e.g. in http cases
+ // 202 OK is sent to say no respsone avalible). Axis2 get blocked
+ // return when the response is avalible.
+ SyncCallBack callback = new SyncCallBack();
+
+ // this method call two channel non blocking method to do the work
+ // and wait on the callbck
+ sendReceiveNonBlocking(operation, elem, callback);
+
+ long timeout = options.getTimeOutInMilliSeconds();
+ long waitTime = timeout;
+ long startTime = System.currentTimeMillis();
+
+ synchronized (callback) {
+ while (! callback.isComplete() && waitTime >= 0) {
+ try {
+ callback.wait(timeout);
+ } catch (InterruptedException e) {
+ // We were interrupted for some reason, keep waiting
+ // or throw new AxisFault( "Callback was interrupted by someone?" );
+ }
+ // The wait finished, compute remaining time
+ // - wait can end prematurly, see Object.wait( int timeout )
+ waitTime = timeout - (System.currentTimeMillis() - startTime);
+ }
+
+ }
+ SOAPEnvelope envelope = callback.envelope;
+ // process the resule of the invocation
+ if (envelope != null) {
+ // building soap enevlop
+ envelope.build();
+ // closing transport
+ if (envelope.getBody().hasFault()) {
+ SOAPFault soapFault = envelope.getBody().getFault();
+ throw new AxisFault(soapFault.getCode(), soapFault.getReason(),
+ soapFault.getNode(), soapFault.getRole(), soapFault.getDetail());
+ }
+ } else {
+ if (callback.error instanceof AxisFault) {
+ throw (AxisFault) callback.error;
+ } else if (callback.error != null) {
+ throw new AxisFault(callback.error);
+ } else if (! callback.isComplete()) {
+ //no exception has occured
+ }
+ }
+ } else {
+ MessageContext mc = new MessageContext();
+ fillSoapEnvelope(mc, elem);
+ OperationClient mepClient = createClient(operation);
+ mepClient.addMessageContext(mc);
+ mepClient.execute(true);
+ }
}
/**
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/ClientUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/ClientUtils.java?rev=418914&r1=418913&r2=418914&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/ClientUtils.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/ClientUtils.java Mon Jul 3 21:45:38 2006
@@ -27,6 +27,8 @@
import org.apache.axis2.i18n.Messages;
import javax.xml.namespace.QName;
+import java.net.URI;
+import java.net.URISyntaxException;
/**
* Utility methods for various clients to use.
@@ -70,6 +72,21 @@
Options options,
MessageContext msgCtxt) throws AxisFault {
String listenerTransportProtocol = options.getTransportInProtocol();
+ if (listenerTransportProtocol == null) {
+ EndpointReference replyTo = msgCtxt.getReplyTo();
+ if (replyTo != null) {
+ try {
+ URI uri = new URI(replyTo.getAddress());
+ String scheme = uri.getScheme();
+ listenerTransportProtocol = scheme;
+ } catch (URISyntaxException e) {
+ //need to ignore
+ }
+ } else {
+ //assume listner transport as sender transport
+ listenerTransportProtocol = msgCtxt.getTransportOut().getName().getLocalPart();
+ }
+ }
TransportInDescription transportIn = null;
if (options.isUseSeparateListener()) {
if ((listenerTransportProtocol != null) && !"".equals(listenerTransportProtocol)) {
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org
Re: svn commit: r418914 - in /webservices/axis2/trunk/java/modules/core/src/org/apache/axis2:
client/ServiceClient.java description/ClientUtils.java
Posted by Deepal Jayasinghe <de...@opensource.lk>.
deepal@apache.org wrote:
>Author: deepal
>Date: Mon Jul 3 21:45:38 2006
>New Revision: 418914
>
>URL: http://svn.apache.org/viewvc?rev=418914&view=rev
>Log:
>- fixing fireAndForget invocation (using two channel)
>
>
fixing sendRobust NOT fireAndForget
>Modified:
> webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/ServiceClient.java
> webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/ClientUtils.java
>
>Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/ServiceClient.java
>URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/ServiceClient.java?rev=418914&r1=418913&r2=418914&view=diff
>==============================================================================
>--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/ServiceClient.java (original)
>+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/ServiceClient.java Mon Jul 3 21:45:38 2006
>@@ -18,11 +18,7 @@
>
> import org.apache.axiom.om.OMAbstractFactory;
> import org.apache.axiom.om.OMElement;
>-import org.apache.axiom.soap.SOAP12Constants;
>-import org.apache.axiom.soap.SOAPEnvelope;
>-import org.apache.axiom.soap.SOAPFactory;
>-import org.apache.axiom.soap.SOAPHeader;
>-import org.apache.axiom.soap.SOAPHeaderBlock;
>+import org.apache.axiom.soap.*;
> import org.apache.axis2.AxisFault;
> import org.apache.axis2.addressing.EndpointReference;
> import org.apache.axis2.client.async.AsyncResult;
>@@ -354,11 +350,65 @@
> * received in response (per the Robust In-Only MEP).
> */
> public void sendRobust(QName operation, OMElement elem) throws AxisFault {
>- MessageContext mc = new MessageContext();
>- fillSoapEnvelope(mc, elem);
>- OperationClient mepClient = createClient(operation);
>- mepClient.addMessageContext(mc);
>- mepClient.execute(true);
>+ if (options.isUseSeparateListener()) {
>+
>+ // This mean doing a Fault may come through a differnt channel .
>+ // If the
>+ // transport is two way transport (e.g. http) Only one channel is
>+ // used (e.g. in http cases
>+ // 202 OK is sent to say no respsone avalible). Axis2 get blocked
>+ // return when the response is avalible.
>+ SyncCallBack callback = new SyncCallBack();
>+
>+ // this method call two channel non blocking method to do the work
>+ // and wait on the callbck
>+ sendReceiveNonBlocking(operation, elem, callback);
>+
>+ long timeout = options.getTimeOutInMilliSeconds();
>+ long waitTime = timeout;
>+ long startTime = System.currentTimeMillis();
>+
>+ synchronized (callback) {
>+ while (! callback.isComplete() && waitTime >= 0) {
>+ try {
>+ callback.wait(timeout);
>+ } catch (InterruptedException e) {
>+ // We were interrupted for some reason, keep waiting
>+ // or throw new AxisFault( "Callback was interrupted by someone?" );
>+ }
>+ // The wait finished, compute remaining time
>+ // - wait can end prematurly, see Object.wait( int timeout )
>+ waitTime = timeout - (System.currentTimeMillis() - startTime);
>+ }
>+
>+ }
>+ SOAPEnvelope envelope = callback.envelope;
>+ // process the resule of the invocation
>+ if (envelope != null) {
>+ // building soap enevlop
>+ envelope.build();
>+ // closing transport
>+ if (envelope.getBody().hasFault()) {
>+ SOAPFault soapFault = envelope.getBody().getFault();
>+ throw new AxisFault(soapFault.getCode(), soapFault.getReason(),
>+ soapFault.getNode(), soapFault.getRole(), soapFault.getDetail());
>+ }
>+ } else {
>+ if (callback.error instanceof AxisFault) {
>+ throw (AxisFault) callback.error;
>+ } else if (callback.error != null) {
>+ throw new AxisFault(callback.error);
>+ } else if (! callback.isComplete()) {
>+ //no exception has occured
>+ }
>+ }
>+ } else {
>+ MessageContext mc = new MessageContext();
>+ fillSoapEnvelope(mc, elem);
>+ OperationClient mepClient = createClient(operation);
>+ mepClient.addMessageContext(mc);
>+ mepClient.execute(true);
>+ }
> }
>
> /**
>
>Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/ClientUtils.java
>URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/ClientUtils.java?rev=418914&r1=418913&r2=418914&view=diff
>==============================================================================
>--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/ClientUtils.java (original)
>+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/ClientUtils.java Mon Jul 3 21:45:38 2006
>@@ -27,6 +27,8 @@
> import org.apache.axis2.i18n.Messages;
>
> import javax.xml.namespace.QName;
>+import java.net.URI;
>+import java.net.URISyntaxException;
>
> /**
> * Utility methods for various clients to use.
>@@ -70,6 +72,21 @@
> Options options,
> MessageContext msgCtxt) throws AxisFault {
> String listenerTransportProtocol = options.getTransportInProtocol();
>+ if (listenerTransportProtocol == null) {
>+ EndpointReference replyTo = msgCtxt.getReplyTo();
>+ if (replyTo != null) {
>+ try {
>+ URI uri = new URI(replyTo.getAddress());
>+ String scheme = uri.getScheme();
>+ listenerTransportProtocol = scheme;
>+ } catch (URISyntaxException e) {
>+ //need to ignore
>+ }
>+ } else {
>+ //assume listner transport as sender transport
>+ listenerTransportProtocol = msgCtxt.getTransportOut().getName().getLocalPart();
>+ }
>+ }
> TransportInDescription transportIn = null;
> if (options.isUseSeparateListener()) {
> if ((listenerTransportProtocol != null) && !"".equals(listenerTransportProtocol)) {
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
>For additional commands, e-mail: axis-cvs-help@ws.apache.org
>
>
>
>
>
--
Thanks,
Deepal
................................................................
~Future is Open~
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org
Re: svn commit: r418914 - in /webservices/axis2/trunk/java/modules/core/src/org/apache/axis2:
client/ServiceClient.java description/ClientUtils.java
Posted by Deepal Jayasinghe <de...@opensource.lk>.
deepal@apache.org wrote:
>Author: deepal
>Date: Mon Jul 3 21:45:38 2006
>New Revision: 418914
>
>URL: http://svn.apache.org/viewvc?rev=418914&view=rev
>Log:
>- fixing fireAndForget invocation (using two channel)
>
>
fixing sendRobust NOT fireAndForget
>Modified:
> webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/ServiceClient.java
> webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/ClientUtils.java
>
>Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/ServiceClient.java
>URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/ServiceClient.java?rev=418914&r1=418913&r2=418914&view=diff
>==============================================================================
>--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/ServiceClient.java (original)
>+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/ServiceClient.java Mon Jul 3 21:45:38 2006
>@@ -18,11 +18,7 @@
>
> import org.apache.axiom.om.OMAbstractFactory;
> import org.apache.axiom.om.OMElement;
>-import org.apache.axiom.soap.SOAP12Constants;
>-import org.apache.axiom.soap.SOAPEnvelope;
>-import org.apache.axiom.soap.SOAPFactory;
>-import org.apache.axiom.soap.SOAPHeader;
>-import org.apache.axiom.soap.SOAPHeaderBlock;
>+import org.apache.axiom.soap.*;
> import org.apache.axis2.AxisFault;
> import org.apache.axis2.addressing.EndpointReference;
> import org.apache.axis2.client.async.AsyncResult;
>@@ -354,11 +350,65 @@
> * received in response (per the Robust In-Only MEP).
> */
> public void sendRobust(QName operation, OMElement elem) throws AxisFault {
>- MessageContext mc = new MessageContext();
>- fillSoapEnvelope(mc, elem);
>- OperationClient mepClient = createClient(operation);
>- mepClient.addMessageContext(mc);
>- mepClient.execute(true);
>+ if (options.isUseSeparateListener()) {
>+
>+ // This mean doing a Fault may come through a differnt channel .
>+ // If the
>+ // transport is two way transport (e.g. http) Only one channel is
>+ // used (e.g. in http cases
>+ // 202 OK is sent to say no respsone avalible). Axis2 get blocked
>+ // return when the response is avalible.
>+ SyncCallBack callback = new SyncCallBack();
>+
>+ // this method call two channel non blocking method to do the work
>+ // and wait on the callbck
>+ sendReceiveNonBlocking(operation, elem, callback);
>+
>+ long timeout = options.getTimeOutInMilliSeconds();
>+ long waitTime = timeout;
>+ long startTime = System.currentTimeMillis();
>+
>+ synchronized (callback) {
>+ while (! callback.isComplete() && waitTime >= 0) {
>+ try {
>+ callback.wait(timeout);
>+ } catch (InterruptedException e) {
>+ // We were interrupted for some reason, keep waiting
>+ // or throw new AxisFault( "Callback was interrupted by someone?" );
>+ }
>+ // The wait finished, compute remaining time
>+ // - wait can end prematurly, see Object.wait( int timeout )
>+ waitTime = timeout - (System.currentTimeMillis() - startTime);
>+ }
>+
>+ }
>+ SOAPEnvelope envelope = callback.envelope;
>+ // process the resule of the invocation
>+ if (envelope != null) {
>+ // building soap enevlop
>+ envelope.build();
>+ // closing transport
>+ if (envelope.getBody().hasFault()) {
>+ SOAPFault soapFault = envelope.getBody().getFault();
>+ throw new AxisFault(soapFault.getCode(), soapFault.getReason(),
>+ soapFault.getNode(), soapFault.getRole(), soapFault.getDetail());
>+ }
>+ } else {
>+ if (callback.error instanceof AxisFault) {
>+ throw (AxisFault) callback.error;
>+ } else if (callback.error != null) {
>+ throw new AxisFault(callback.error);
>+ } else if (! callback.isComplete()) {
>+ //no exception has occured
>+ }
>+ }
>+ } else {
>+ MessageContext mc = new MessageContext();
>+ fillSoapEnvelope(mc, elem);
>+ OperationClient mepClient = createClient(operation);
>+ mepClient.addMessageContext(mc);
>+ mepClient.execute(true);
>+ }
> }
>
> /**
>
>Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/ClientUtils.java
>URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/ClientUtils.java?rev=418914&r1=418913&r2=418914&view=diff
>==============================================================================
>--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/ClientUtils.java (original)
>+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/ClientUtils.java Mon Jul 3 21:45:38 2006
>@@ -27,6 +27,8 @@
> import org.apache.axis2.i18n.Messages;
>
> import javax.xml.namespace.QName;
>+import java.net.URI;
>+import java.net.URISyntaxException;
>
> /**
> * Utility methods for various clients to use.
>@@ -70,6 +72,21 @@
> Options options,
> MessageContext msgCtxt) throws AxisFault {
> String listenerTransportProtocol = options.getTransportInProtocol();
>+ if (listenerTransportProtocol == null) {
>+ EndpointReference replyTo = msgCtxt.getReplyTo();
>+ if (replyTo != null) {
>+ try {
>+ URI uri = new URI(replyTo.getAddress());
>+ String scheme = uri.getScheme();
>+ listenerTransportProtocol = scheme;
>+ } catch (URISyntaxException e) {
>+ //need to ignore
>+ }
>+ } else {
>+ //assume listner transport as sender transport
>+ listenerTransportProtocol = msgCtxt.getTransportOut().getName().getLocalPart();
>+ }
>+ }
> TransportInDescription transportIn = null;
> if (options.isUseSeparateListener()) {
> if ((listenerTransportProtocol != null) && !"".equals(listenerTransportProtocol)) {
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
>For additional commands, e-mail: axis-cvs-help@ws.apache.org
>
>
>
>
>
--
Thanks,
Deepal
................................................................
~Future is Open~
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org