Can you please send me the stacktrace too ?
And are u calling a service hosted in a non-Axis2
server ? Seems so, as
your target epr seems its not in an Axis2 server.
But since it seems you
have done the code well, its a rare chance that the
epr u set it wrong.
BTW, did you look at the code in
It has the same
code as what you are trying to do.
Chinthaka
trebor iksrazal wrote:
Hi Eran, thanks for the reply. I think I'm already
doing everything you mentioned - my client code is
basically the same as the EchoNonBlockingClient
example, which I believe has useSeparateListener
equal
true and passes a callback into invokeNonBlocking.
Of course, I'm sure I'm missing something simple.
Could you please give a look at the code below?
public class RCServiceClient {
private static EndpointReference targetEPR =
new
EndpointReference("http://127.0.0.1:8080/swa/services/RCService");
public static void main(String[] args) {
try {
OMElement payload =
ClientUtil.getEchoOMElement();
Call call = new Call();
call.setTo(targetEPR);
// The boolean flag informs the axis2
engine to use two separate transport connection
// to retrieve the response.
call.engageModule(new
QName(Constants.MODULE_ADDRESSING));
call.setTransportInfo(Constants.TRANSPORT_HTTP,
Constants.TRANSPORT_HTTP,
true);
//Callback to handle the response
Callback callback = new Callback() {
public void onComplete(AsyncResult
result) {
try {
System.out.println("inside
onComplete...");
StringWriter writer = new
StringWriter();
result.getResponseEnvelope().serializeWithCache(XMLOutputFactory.newInstance()
.createXMLStreamWriter(writer));
writer.flush();
System.out.println(writer.toString());
} catch (XMLStreamException e)
{
reportError(e);
}
}
public void reportError(Exception
e) {
e.printStackTrace();
}
};
//Non-Blocking Invocation
call.invokeNonBlocking("rcExecute",
payload, callback);
//Wait till the callback receives the
response.
System.out.println("RC Service
executed,
sleeping until completion...");
while (!callback.isComplete()) {
Thread.sleep(1000);
}
//Need to close the Client Side
Listener.
call.close();
System.out.println("RC Service
completed");
} catch (AxisFault axisFault) {
axisFault.printStackTrace();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
public class ClientUtil {
public static OMElement getEchoOMElement() {
OMFactory fac =
OMAbstractFactory.getOMFactory();
OMNamespace omNs = fac.createOMNamespace(
"http://example1.org/example1",
"example1");
OMElement method =
fac.createOMElement("rcExecute", omNs);
OMElement value =
fac.createOMElement("Text",
omNs);
value.addChild(fac.createText(value, "Axis2
Echo String "));
method.addChild(value);
return method;
}
}
Thanks a lot,
trebor iksrazal
--- Eran Chinthaka <[EMAIL PROTECTED]> wrote:
Hi Trebor,
trebor iksrazal wrote:
Hi all,
I've succesfully wrote a web service based off of
the
EchoNonBlockingClient example in the user guide.
I'm
using spring on the server side, if anyone needs
help.
Excellent, thanks for offering to help. I saw
there
are some people
struggling to do the samething. If you have time,
just explain what you
did and how you did as a small tutorial and mail
it
here. If its good,
we can put it in our Axis2 site.
However, the task I execute on the web service
side
can take between 6 and 20 minutes. Its why I
choosed
axis2, so I can execute it asynchronously. Yet it
gives me:
java.net.SocketTimeoutException: Read timed out
The reason for this is that the socket which you
used to invoke server
has timed out. What you can do is to use a
separate
listener and a pass
a Callback, as Srinath has stated.