Page 1 of 1

How to use webservice in cyclos 3.7.1

Posted: Mon Dec 10, 2012 8:10 am
by afzal
Hi!

I am new to cyclos system. I have spent some time getting familiar with Cyclos system on local server.

I have now installed a cyclos onto my laptop and it is running without any problem. But when I am trying to connect to cyclos web service I am getting Server error: unauthorized-access.

Thanks in advance for your help to solve this. It would be great if someone tells me the steps needed to configure and connect to web service.

The code I have written as client are as follows:

CyclosWebServicesClientFactory factory = new CyclosWebServicesClientFactory();
factory.setServerRootUrl("http://192.168.1.114:8080/cyclos");
PaymentWebService paymentWebService = factory.getPaymentWebService();
//AdWebService adWebService = factory.getAdWebService();
//AdCategoryVO []categories=adWebService.listCategories();
//System.out.println(categories);
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
PaymentParameters params = new PaymentParameters();

// Prompt the parameters
System.out.print("Amount: ");
params.setAmount(new BigDecimal(in.readLine()));
System.out.print("Login name: "); //This user should have the channel set as enabled
params.setFromMember(in.readLine());
System.out.print("PIN: ");
//params.setCredentials(in.readLine());


// Perform the payment
PaymentResult result = paymentWebService.doPayment(params);
System.out.println(result);

I am getting the following error:
Dec 10, 2012 5:16:35 PM org.apache.cxf.service.factory.ReflectionServiceFactoryBean buildServiceFromClass
INFO: Creating Service {http://payments.webservices.cyclos.stro ... iceService from class nl.strohalm.cyclos.webservices.payments.PaymentWebService
Amount: 500
Login name: mamun
PIN: 2131
Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Server error: unauthorized-access
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:156)
at $Proxy38.doPayment(Unknown Source)
at nl.strohalm.cyclos.webservices.client.CyclosWebClient.main(CyclosWebClient.java:44)
Caused by: org.apache.cxf.binding.soap.SoapFault: Server error: unauthorized-access
at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.unmarshalFault(Soap11FaultInInterceptor.java:75)
at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:46)
at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:35)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)
at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:113)
at org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:69)
at org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:34)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)
at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:798)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1667)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1520)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1428)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:658)
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:532)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:464)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:367)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:320)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:89)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:134)
... 2 more

Please let me know if anything is missing while configuring web service clients or the documentation in wiki need to be changed for 3.7.1.

Thanks.

Re: How to use webservice in cyclos 3.7.1

Posted: Mon Dec 10, 2012 8:23 am
by alexandre
Hi,

In order to perform a payment through webservices you need to configure a new channel, create a webservice client to use this new channel, and enable a transfer type to work with this new channel, and finally grant permissions to a member group to use this channel and make sure the channel are enable on members external access config.


Regards

Re: How to use webservice in cyclos 3.7.1

Posted: Mon Dec 10, 2012 9:31 am
by afzal
Dear Alexandre,

Thanks for your reply. I have followed all the steps but could not manage to get it work for me.

I have configured a new channel, created a webservice client to use this new channel, grant permissions to a member group to use this channel and the channel is enabled on members external access config.

But I did not understand or could not find how/where to enable a transfer type to work with this new channel.

Thanks again for your help.

Re: How to use webservice in cyclos 3.7.1

Posted: Mon Dec 10, 2012 9:41 am
by alexandre
Hi,

You need to go to menu accounts -> manage accounts then select the member account. you can edit an existing transfer type like trade transfer and on channels check the new created channel.

Regards.

Re: How to use webservice in cyclos 3.7.1

Posted: Mon Dec 10, 2012 10:09 am
by afzal
Dear Alexandre,

The attachment may give better picture on this.

Thanks.

Re: How to use webservice in cyclos 3.7.1

Posted: Mon Dec 10, 2012 10:33 am
by alexandre
Hi,

The error is unauthorized-access this can be 2 things: permissions or internet address.
The permissions seems to be ok. Maybe you can change the IP address in the webservices client to localhost and see if works.

Regards

Re: How to use webservice in cyclos 3.7.1

Posted: Mon Dec 10, 2012 2:10 pm
by afzal
Dear Alexandre,

Thanks for your reply again.

I have tried with local host first. Then also tried with the hostname of the laptop and at last tried with IP address but nothing worked out. It seems like I am missing something while configuring this web service. If you could give me the details step for setting up this, it will help me a lot.

Thanks.

Re: How to use webservice in cyclos 3.7.1

Posted: Mon Dec 10, 2012 2:24 pm
by alexandre
Hi,

Do you are trying with a member restricted webservice.
Did you enable the channel on the member preferences? this must be enabled for the member that are paying too.
Member menu -> personal-> external access

Regards

Re: How to use webservice in cyclos 3.7.1

Posted: Mon Dec 10, 2012 2:34 pm
by afzal
Dear Alexandre,

Thanks for your reply again.

Yes I am trying with a member restricted webservice.

Yes I have enabled Member menu -> personal-> external access.

Thanks.

Re: How to use webservice in cyclos 3.7.1

Posted: Mon Dec 10, 2012 2:54 pm
by alexandre
Hi,

What env. you are using windows or linux? If windows what version?

Re: How to use webservice in cyclos 3.7.1

Posted: Mon Dec 10, 2012 3:08 pm
by afzal
Dear Alexandre,

Thanks for your reply again.

I am using Windows 7 64bit.

The following software are used for the development environment:
1. Eclipse:
Eclipse Java EE IDE for Web Developers.

Version: Indigo Service Release 2
Build id: 20120216-1857

2. JDK:
jdk1.6.0_37

3. Tomcat:
apache-tomcat-6.0.36
4. MySQL:
5.5.8

Please find the attached transaction type setup screenshot for more information.

Re: How to use webservice in cyclos 3.7.1

Posted: Mon Dec 10, 2012 3:19 pm
by alexandre
Hi,

Verify if there is an entry like it on your hosts file:
192.168.1.114 localhost

If not add this to the file.

Here you can find how to see/edit this file:
http://helpdeskgeek.com/windows-7/windows-7-hosts-file/

Maybe your java/tomcat are not resolving correctly your ip address, resulting in unauthorized-access.

Regards

Re: How to use webservice in cyclos 3.7.1

Posted: Mon Dec 10, 2012 9:34 pm
by afzal
Dear Alexandre,

The system is resolving IP correctly, I have observed while debugging AuthInterceptor.resolveeClient , it has passed 192.168.1.114 as remote address. But ServiceClientService.findByAddressAndCredentials does not recognize username and password, therefore it returns null and as a result throwing new EntityNotFoundException(ServiceClient.class) Is there any way to pass this password and user name? I have passing only fromMember here . I think I am making mistakes here. Please let me know the parameter you are passing to connect to the web service.

PaymentParameters params = new PaymentParameters();

// Prompt the parameters
System.out.print("Amount: ");
params.setAmount(new BigDecimal(in.readLine()));
System.out.print("Login name: "); //This user should have the channel set as enabled
params.setFromMember(in.readLine());
System.out.print("PIN: ");


Thanks

Re: How to use webservice in cyclos 3.7.1

Posted: Tue Dec 11, 2012 8:12 am
by afzal
Hi!

Could someone let me know what should be the web service url value in new channel creation screen?

I am using http://localhost:8080/cyclos/services/payment

Is it correct based on the root URL http://localhost:8080/cyclos/ in my local machine or I need to change this.

Or if someone write down the detail steps to configure the web service, it will help me a lot.

Thanks.

Re: How to use webservice in cyclos 3.7.1

Posted: Tue Dec 11, 2012 9:13 am
by afzal
Hi!

I have solved the problem.

The main problem was setting Web Service client. I was setting http user and http password which is not necessary in this case.

Anyway thanks Alexandre for helping me out for this issue.

Thanks