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/13 06:27:37 UTC
RE: problem to invoke the webservice using REST Style
Hi kinichiro,
I have tried for this also but problem is same. can you check the link below,
http://ws.apache.org/axis2/0_95/api/org/apache/axis2/rpc/receivers/class-use/RPCInOnlyMessageReceiver.html
in this it is clearly mention that there is no use of RpcInOnlyMessageReceiver.finding the method in service may be the problem.
http://localhost:8080/axis2/rest/ServiceName/setData?num=10
can you send me the running sample code including service.xml,client and service if you have.
Thanks
Vimal Bansal.
-----Original Message-----
From: Kinichiro Inoguchi [mailto:ingc1968@yahoo.com]
Sent: Wednesday, July 12, 2006 7:32 PM
To: axis-user@ws.apache.org
Subject: RE: problem to invoke the webservice using RESTt Style
Hi Bansal,
You must use RPCInOnlyMessageReceiver instead of RPCMessageReceiver,
because your method is void.
Regards,
kinichiro
--- "Bansal, Vimal" <Vi...@lionbridge.com> wrote:
> Hi kinichiro,
> Thanks again, tried my all stuff now I have just created one method
> in my service Say setdata(in num) my code snippets is below just for
> testing purpose
>
> public void setData(int num) {
> System.out.println("$$$$Entry in setData");
> System.out.println("value of num ="+ num);
> System.out.println("$$$$Exit from setData");
> }
> and i am passing parameter via REST like this,
> http://localhost:8080/axis2/rest/ServiceName/setData?num=10
> but i have the same problem i am not getting access of setdata()
> method.
> i have also created the client for this when I am running it by dos
> prompt I am getting this message
> org.apache.axis2.AxisFault: Incoming message input stream is
> null:Incoming mesas
> gee input stream is null
> is there any changes needed to services.xml below is the code for
> service.xml
> <service >
>
> <description>
> This is a sample Test Service with one operations setdata
> </description>
> <parameter name="ServiceClass"
> locked="false">com.poc.service.TestService</parameter>
> <operation name="setData">
> <messageReceiver
> class="org.apache.axis2.rpc.receivers.RPCMessageReceiver/>
> </operation>
>
> </service >
> i think passing the parameter may be problem
> Thanks
> Vimal Bansal
>
> -----Original Message-----
> From: Kinichiro Inoguchi [mailto:ingc1968@yahoo.com]
> Sent: Tuesday, July 11, 2006 7:15 PM
> To: axis-user@ws.apache.org
> Subject: RE: problem to invoke the webservice using RESTt Style
>
>
> Hi Vimal,
>
> You can pass parameter via REST like this,
>
http://localhost:8080/axis2/rest/YourService/getProductDetails?productid=12345
>
> And if you still get internal error,
> could you try change return value String[] to String, please ?
>
> Regards,
> kinichiro
>
> --- "Bansal, Vimal" <Vi...@lionbridge.com> wrote:
>
> > Hi Kinichiro,
> > Thanks for your response. I tried the service with method returning
> > String type or String[] type. But the real problem is when i am
> > passing a paramter. For example: String[] getProductDetails(long
> > productid);
> >
> > The array is basically an array of all the values reteieved from a
> > database, like returnVal[0] will be the first element, returnVal[1]
> > will be the next and so on. The returning type is not an issue. Is
> > the paramter (productid as in my example) creating this problem?
> How
> > can we pass paramters?
> >
> > Regards,
> > Vimal.
> >
> > -----Original Message-----
> > From: Kinichiro Inoguchi [mailto:ingc1968@yahoo.com]
> > Sent: Tuesday, July 11, 2006 3:40 PM
> > To: axis-user@ws.apache.org
> > Subject: Re: problem to invoke the webservice using RESTt Style
> >
> >
> > 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
> >
> >
> >
> >
> >
> ---------------------------------------------------------------------
> > 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
>
>
>
>
> ---------------------------------------------------------------------
> 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
---------------------------------------------------------------------
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 REST Style
Posted by Kinichiro Inoguchi <in...@yahoo.com>.
Hi Bansal,
Test class is like this.
package test;
public class MyService1 {
public void ping(int element) {
System.out.println("value of input value = "+ element);
}
public int echo(int element) {
return element * element;
}
}
services.xml is like this.
<service name="ComplexTest">
<description>test service.</description>
<parameter name="ServiceClass"
locked="false">test.MyService1</parameter>
<operation name="ping">
<messageReceiver
class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/>
</operation>
<operation name="echo">
<messageReceiver
class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
</operation>
</service>
You can call this by REST.
http://localhost:8080/axis2/rest/MyService1/ping?element=15
I could see this log message in tomcat stdout.log
value of input value = 15
It worked fine.
Regards,
kinichiro
--- "Bansal, Vimal" <Vi...@lionbridge.com> wrote:
> Hi kinichiro,
> I have tried for this also but problem is same. can you check the
> link below,
>
>
http://ws.apache.org/axis2/0_95/api/org/apache/axis2/rpc/receivers/class-use/RPCInOnlyMessageReceiver.html
>
> in this it is clearly mention that there is no use of
> RpcInOnlyMessageReceiver.finding the method in service may be the
> problem.
> http://localhost:8080/axis2/rest/ServiceName/setData?num=10
> can you send me the running sample code including service.xml,client
> and service if you have.
> Thanks
> Vimal Bansal.
>
> -----Original Message-----
> From: Kinichiro Inoguchi [mailto:ingc1968@yahoo.com]
> Sent: Wednesday, July 12, 2006 7:32 PM
> To: axis-user@ws.apache.org
> Subject: RE: problem to invoke the webservice using RESTt Style
>
>
> Hi Bansal,
>
> You must use RPCInOnlyMessageReceiver instead of RPCMessageReceiver,
> because your method is void.
>
> Regards,
> kinichiro
>
> --- "Bansal, Vimal" <Vi...@lionbridge.com> wrote:
>
> > Hi kinichiro,
> > Thanks again, tried my all stuff now I have just created one method
> > in my service Say setdata(in num) my code snippets is below just
> for
> > testing purpose
> >
> > public void setData(int num) {
> > System.out.println("$$$$Entry in setData");
> > System.out.println("value of num ="+ num);
> > System.out.println("$$$$Exit from setData");
> > }
> > and i am passing parameter via REST like this,
> > http://localhost:8080/axis2/rest/ServiceName/setData?num=10
> > but i have the same problem i am not getting access of setdata()
> > method.
> > i have also created the client for this when I am running it by dos
> > prompt I am getting this message
> > org.apache.axis2.AxisFault: Incoming message input stream is
> > null:Incoming mesas
> > gee input stream is null
> > is there any changes needed to services.xml below is the code for
> > service.xml
> > <service >
> >
> > <description>
> > This is a sample Test Service with one operations setdata
> > </description>
> > <parameter name="ServiceClass"
> > locked="false">com.poc.service.TestService</parameter>
> > <operation name="setData">
> > <messageReceiver
> > class="org.apache.axis2.rpc.receivers.RPCMessageReceiver/>
> > </operation>
> >
> > </service >
> > i think passing the parameter may be problem
> > Thanks
> > Vimal Bansal
> >
> > -----Original Message-----
> > From: Kinichiro Inoguchi [mailto:ingc1968@yahoo.com]
> > Sent: Tuesday, July 11, 2006 7:15 PM
> > To: axis-user@ws.apache.org
> > Subject: RE: problem to invoke the webservice using RESTt Style
> >
> >
> > Hi Vimal,
> >
> > You can pass parameter via REST like this,
> >
>
http://localhost:8080/axis2/rest/YourService/getProductDetails?productid=12345
> >
> > And if you still get internal error,
> > could you try change return value String[] to String, please ?
> >
> > Regards,
> > kinichiro
> >
> > --- "Bansal, Vimal" <Vi...@lionbridge.com> wrote:
> >
> > > Hi Kinichiro,
> > > Thanks for your response. I tried the service with method
> returning
> > > String type or String[] type. But the real problem is when i am
> > > passing a paramter. For example: String[] getProductDetails(long
> > > productid);
> > >
> > > The array is basically an array of all the values reteieved from
> a
> > > database, like returnVal[0] will be the first element,
> returnVal[1]
> > > will be the next and so on. The returning type is not an issue.
> Is
> > > the paramter (productid as in my example) creating this problem?
> > How
> > > can we pass paramters?
> > >
> > > Regards,
> > > Vimal.
> > >
> > > -----Original Message-----
> > > From: Kinichiro Inoguchi [mailto:ingc1968@yahoo.com]
> > > Sent: Tuesday, July 11, 2006 3:40 PM
> > > To: axis-user@ws.apache.org
> > > Subject: Re: problem to invoke the webservice using RESTt Style
> > >
> > >
> > > 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
> > >
> > >
> > >
> > >
> > >
> >
> ---------------------------------------------------------------------
> > > 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
> >
> >
> >
> >
> >
> ---------------------------------------------------------------------
> > 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
>
>
>
>
> ---------------------------------------------------------------------
> 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