Steve,
what do you mean by hang?, does the service wait forever?, what
happens on the server side, any log?
Maybe it won't fix your problem, but here are a couple of advices:
- the soap action usually starts with "urn:" and it's followed by the
operation name
- in the finally block you change the state of your sender object,
which may be null
Michele
On 14 Dec 2007, at 09:13, Clark, Stephen wrote:
All,
I am new to Axis and have been trying to update the NonBlockingDual
client to use Transport Asynchrony for a specific web service. The
example works OK if i do not use a separate listener but as soon as
I set options.setUseSeparateListener(true); and run the example it
simply hangs. I am using the default axis2.xml file supplied with
the userguide samples. I have included the source code at the end
of this e-mail.
Is there anything I am doing that is obviously wrong?
Thanks
Steve
package userguide.clients;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axis2.AxisFault;
import org.apache.axis2.Constants;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.client.async.AsyncResult;
import org.apache.axis2.client.async.Callback;
import javax.xml.namespace.QName;
/**
* Sample for asynchronous dual channel non-blocking service
invocation.
* Message Exchage Pattern IN-OUT
* Ulitmate asynchronous service invocation sample.
*/
public class EchoNonBlockingDualClient {
private static EndpointReference targetEPR = new
EndpointReference("http://www.webservicex.net/uklocation.asmx");
public static void main(String[] args) {
ServiceClient sender = null;
try {
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace ns = fac.createOMNamespace("http://
www.webserviceX.NET", "");
OMElement method = fac.createOMElement
("GetUKLocationByTown", ns);
OMElement value = fac.createOMElement("Town", ns);
value.setText("Coventry");
method.addChild(value);
Options options = new Options();
options.setTo(targetEPR);
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
options.setAction("http://www.webserviceX.NET/
GetUKLocationByTown");
options.setTimeOutInMilliSeconds(60000);
options.setUseSeparateListener(true);
//Callback to handle the response
Callback callback = new Callback() {
public void onComplete(AsyncResult result) {
System.out.println(result.getResponseEnvelope());
}
public void onError(Exception e) {
e.printStackTrace();
}
};
//Non-Blocking Invocation
sender = new ServiceClient();
sender.setOptions(options);
sender.engageModule(Constants.MODULE_ADDRESSING);
sender.sendReceiveNonBlocking(method, callback);
//Wait till the callback receives the response.
while (!callback.isComplete()) {
Thread.sleep(1000);
}
//Need to close the Client Side Listener.
} catch (AxisFault axisFault) {
axisFault.printStackTrace();
} catch (Exception ex) {
ex.printStackTrace();
} finally {
try {
sender.cleanup();
} catch (AxisFault axisFault) {
//have to ignore this
}
}
}
}
This email and any files transmitted with it are confidential,
proprietary and intended solely for the individual or entity to
whom they are addressed. If you have received this email in error
please delete it immediately.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]