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 Thushantha De Alwis <ra...@opensource.lk> on 2006/02/24 06:40:44 UTC
[Axis2] Writing Axis2 Client
Hi All
I have successfully deployed a WebService called "Echo"
So I want to invoke that web service. For that I tried to write a client.
When writing it I used the following code
sample got from 0.93 release.
try{
EndpointReference targetEPR =3D new EndpointReference(
"http://localhost:8080/axis2/services/StockQuoteService");
// Make the request message
OMFactory fac =3D OMAbstractFactory.getOMFactory();
OMNamespace omNs =3D fac.createOMNamespace(
"http://www.developerworks.com/example", "example");
OMElement payload =3D fac.createOMElement("subscribe", omNs);
payload.setText("IBM");
// Send the request
MessageSender msgSender =3D new MessageSender();
msgSender.setTo(targetEPR);
msgSender.setSenderTransport(Constants.TRANSPORT_HTTP);
msgSender.send("subscribe", payload);
}catch (AxisFault axisFault) {
axisFault.printStackTrace();
}
But Messagesender was depricated.
Is there any other way to write a client to invike the service. I went
through 0.94 release document also. If some
one have very simple code for cient to invike a service please send me.
Best Regards
Thushantha
RE: [Axis2] Writing Axis2 Client
Posted by do...@yahoo.de.
Hello Thushantha,
use ServiceClient instead of the deprecated
MessageSender the following way:
EndpointReference endpoint = new
EndpointReference("http://...");
Options ops = new Options();
op.setTo(endpoint);
op.setTransportInProtocol(org.apache.axis2.Constants.TRANSPORT_HTTP);
op.setUseSeparateListener(false);
ServiceClient sc = new ServiceClient();
sc.setOptions(ops);
--
Ted
--- Thushantha De Alwis <ra...@opensource.lk> schrieb:
> Hi All
>
> I have successfully deployed a WebService called
> "Echo"
>
> So I want to invoke that web service. For that I
> tried to write a client.
> When writing it I used the following code
> sample got from 0.93 release.
>
> try{
> EndpointReference targetEPR =3D new
> EndpointReference(
>
>
"http://localhost:8080/axis2/services/StockQuoteService");
>
> // Make the request message
> OMFactory fac =3D OMAbstractFactory.getOMFactory();
> OMNamespace omNs =3D fac.createOMNamespace(
> "http://www.developerworks.com/example",
> "example");
> OMElement payload =3D
> fac.createOMElement("subscribe", omNs);
> payload.setText("IBM");
>
> // Send the request
> MessageSender msgSender =3D new MessageSender();
> msgSender.setTo(targetEPR);
>
>
msgSender.setSenderTransport(Constants.TRANSPORT_HTTP);
> msgSender.send("subscribe", payload);
> }catch (AxisFault axisFault) {
> axisFault.printStackTrace();
> }
>
>
>
> But Messagesender was depricated.
>
> Is there any other way to write a client to invike
> the service. I went
> through 0.94 release document also. If some
> one have very simple code for cient to invike a
> service please send me.
>
> Best Regards
> Thushantha
>
>
___________________________________________________________
Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de