Hi Chinkata,
I just managed to get my first REST POST sample working, after having
downloaded the nightly build. I also fiddled around with my code so
it is not clear what was wrong. The sourcecode is provided below.
Thank you very much,
Juliane.
------------------------------------------------------------------------
--
import org.apache.axiom.om.*;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.Constants;
public class EchoClientRest
{
public static void main(String[] args)
{
try {
EndpointReference targetEPR = new
EndpointReference("http://localhost:8080/axis2/rest/MyService");
OMElement payload = getEchoOMElement();
Options options = new Options();
options.setTo(targetEPR);
options.setProperty(Constants.Configuration.ENABLE_REST,Constants.VALUE_
TRUE);
ServiceClient sender = new ServiceClient();
sender.setOptions(options);
OMElement result = sender.sendReceive(payload);
System.out.println(result);
} catch (AxisFault axisFault) {
axisFault.printStackTrace();
}
}
public static OMElement getEchoOMElement()
{
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNs = fac.createOMNamespace(
"http://example1.org/example1", "example1");
OMElement method = fac.createOMElement("echo", omNs);
OMElement value = fac.createOMElement("Text", omNs);
value.addChild(fac.createOMText(value, "Axis2 Echo String "));
method.addChild(value);
return method;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]