You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by "Bansal, Vimal" <Vi...@lionbridge.com> on 2006/07/11 06:13:17 UTC
problem to invoke the webservice using RESTt Style
Hi All,
I am a new user of Web Services. I am using Axis2 for implementing services. I want to use REST style of Web services. My service class, say MyServices have to service methods:
String getAllValues() and String[] getValue(long id).
The first service method, that has no parameters, is working fine when invoked by a client. I am accessing this service through the link: http://localhost:8080/Axis2/rest/servicename/getAllValues
I am getting the following result:
<ns:getAllValuesdsResponse xmlns:ns="http://service.poc.com/xsd">
<return>[33, 34, 35, 36, 37, 38]</return>
</ns:getAllValuessResponse>
My problem is that when I am trying to access the second service(that has one parameter), through the link http://localhost:8080/Axis2/rest/servicename/getValue am getting an axis page showing "Internal server error". How can I access this web service? Is there some way to pass the parameter through url?
My client class is having following code snippets:
private static EndpointReference targetEPR = new EndpointReference("http://localhost:8080/rest/userservice2/getValue");
...
public static void main(String[] args) {
try {
ServiceClient sender = null;
Options options = new Options();
options.setTo(targetEPR);
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
options.setProperty(Constants.Configuration.ENABLE_REST, Constants.VALUE_TRUE);
options.setProperty(Constants.Configuration.HTTP_METHOD,Constants.Configuration.HTTP_METHOD_GET);
sender = new ServiceClient();
sender.setOptions(options);
OMElement result= sender.sendReceive(getPayload());
}
catch(Exception e){ }
}
...
private static OMElement getPayload() throws Exception{
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNs = fac.createOMNamespace("http://service.poc.com/xsd","example1");
OMElement method = fac.createOMElement("getValue", omNs);
OMElement value = fac.createOMElement("Text", omNs);
value.addChild(fac.createOMText(value,"38"));
method.addChild(value);
return method;
}
Thanks and regards,
Vimal.
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org
Re: problem to invoke the webservice using RESTt Style
Posted by Deepal Jayasinghe <de...@opensource.lk>.
Hi Bansal;
pls see my comments below;
Bansal, Vimal wrote:
>Hi All,
>
>I am a new user of Web Services. I am using Axis2 for implementing services. I want to use REST style of Web services. My service class, say MyServices have to service methods:
> String getAllValues() and String[] getValue(long id).
>The first service method, that has no parameters, is working fine when invoked by a client. I am accessing this service through the link: http://localhost:8080/Axis2/rest/servicename/getAllValues
>I am getting the following result:
><ns:getAllValuesdsResponse xmlns:ns="http://service.poc.com/xsd">
> <return>[33, 34, 35, 36, 37, 38]</return>
></ns:getAllValuessResponse>
>My problem is that when I am trying to access the second service(that has one parameter), through the link http://localhost:8080/Axis2/rest/servicename/getValue am getting an axis page showing "Internal server error". How can I access this web service? Is there some way to pass the parameter through url?
>My client class is having following code snippets:
>
>private static EndpointReference targetEPR = new EndpointReference("http://localhost:8080/rest/userservice2/getValue");
>
>
pls type the following link in the browser and see ;
http://localhost:8080/rest/userservice2/getValue?id=10
N:B:- id value should be a valid value w.r.t your service.
>...
>public static void main(String[] args) {
> try {
> ServiceClient sender = null;
> Options options = new Options();
> options.setTo(targetEPR);
> options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
> options.setProperty(Constants.Configuration.ENABLE_REST, Constants.VALUE_TRUE);
> options.setProperty(Constants.Configuration.HTTP_METHOD,Constants.Configuration.HTTP_METHOD_GET);
> sender = new ServiceClient();
> sender.setOptions(options);
> OMElement result= sender.sendReceive(getPayload());
> }
> catch(Exception e){ }
>}
>...
>private static OMElement getPayload() throws Exception{
> OMFactory fac = OMAbstractFactory.getOMFactory();
> OMNamespace omNs = fac.createOMNamespace("http://service.poc.com/xsd","example1");
> OMElement method = fac.createOMElement("getValue", omNs);
> OMElement value = fac.createOMElement("Text", omNs);
> value.addChild(fac.createOMText(value,"38"));
> method.addChild(value);
> return method;
>}
>
>Thanks and regards,
>Vimal.
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>For additional commands, e-mail: axis-user-help@ws.apache.org
>
>
>
>
>
--
Thanks,
Deepal
................................................................
~Future is Open~
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org
Re: problem to invoke the webservice using RESTt Style
Posted by Kinichiro Inoguchi <in...@yahoo.com>.
Hi,
If you change your method from String[] getValue(long id)
to String getValue(long id), does it work ?
I faced same kind of issue, and created JIRA.
http://issues.apache.org/jira/browse/AXIS2-880
Regards,
kinichiro
--- "Bansal, Vimal" <Vi...@lionbridge.com> wrote:
>
> Hi All,
>
> I am a new user of Web Services. I am using Axis2 for implementing
> services. I want to use REST style of Web services. My service class,
> say MyServices have to service methods:
> String getAllValues() and String[] getValue(long id).
> The first service method, that has no parameters, is working fine
> when invoked by a client. I am accessing this service through the
> link: http://localhost:8080/Axis2/rest/servicename/getAllValues
> I am getting the following result:
> <ns:getAllValuesdsResponse xmlns:ns="http://service.poc.com/xsd">
> <return>[33, 34, 35, 36, 37, 38]</return>
> </ns:getAllValuessResponse>
> My problem is that when I am trying to access the second service(that
> has one parameter), through the link
> http://localhost:8080/Axis2/rest/servicename/getValue am getting an
> axis page showing "Internal server error". How can I access this web
> service? Is there some way to pass the parameter through url?
> My client class is having following code snippets:
>
> private static EndpointReference targetEPR = new
>
EndpointReference("http://localhost:8080/rest/userservice2/getValue");
> ...
> public static void main(String[] args) {
> try {
> ServiceClient sender = null;
> Options options = new Options();
> options.setTo(targetEPR);
> options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
> options.setProperty(Constants.Configuration.ENABLE_REST,
> Constants.VALUE_TRUE);
>
>
options.setProperty(Constants.Configuration.HTTP_METHOD,Constants.Configuration.HTTP_METHOD_GET);
> sender = new ServiceClient();
> sender.setOptions(options);
> OMElement result= sender.sendReceive(getPayload());
> }
> catch(Exception e){ }
> }
> ...
> private static OMElement getPayload() throws Exception{
> OMFactory fac = OMAbstractFactory.getOMFactory();
> OMNamespace omNs =
> fac.createOMNamespace("http://service.poc.com/xsd","example1");
> OMElement method = fac.createOMElement("getValue", omNs);
> OMElement value = fac.createOMElement("Text", omNs);
> value.addChild(fac.createOMText(value,"38"));
> method.addChild(value);
> return method;
> }
>
> Thanks and regards,
> Vimal.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org