cancel
Showing results for 
Search instead for 
Did you mean: 

Call authenticate service in EJB

Former Member
0 Kudos

Hi Experts

I'd developed a ejb project, and in this project i imported a service from esworkplace. I need to authenticate when i call this service, but i don't know how can i do this. I think is necessary http authentication.

I created a service group, but didn't work.

I use NW 7.1 EHP1.

Someone can help me to resolve this?

Marcos

Edited by: Marcos Brandao on Jun 23, 2009 6:21 PM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos
Former Member
0 Kudos

Hi welcomenag

Thanks for your reply and suggestion, but that isn't what i want. I use version 7.1, and i think i don't need call a JCO Connection. i am calling a web service in esworkplace in my ejb project and i just need authenticate it. I've read some about service groups to connect in web service with authentication. I don't how to configure this right. I know that service group is assign in my project, and there is a Provider system assign to the service group. But isn't work.

Any other suggestion will be great.

Regards

Marcos

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Marcos,

When calling a Web Service from proxy client within EJB you can use the following to pass in the username and password:

context.put(BindingProvider.USERNAME_PROPERTY,"userName");
context.put(BindingProvider.PASSWORD_PROPERTY,"pass");

For more detailed explation look at this help.sap.com page:

http://help.sap.com/saphelp_nwce10/helpdata/en/45/113a1221337249e10000000a155369/frameset.htm

Regards,

Alka.

Former Member
0 Kudos

Hi Alka

Thanks for your reply

I've done this, but the error is happen.

This is my code:

((BindingProvider) port).getRequestContext().put(BindingProvider.USERNAME_PROPERTY,"S000XXXXXXX");
((BindingProvider) port).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY,"XXXXXXXXXXXXX");

and the message error returned:

javax.ejb.EJBException: (Failed in component: xxxx.com.br/crvp~ear~services) 
Exception raised from invocation of public br.com.xxxxxxxxx.xi.apo.global.ResourceSimpleByPlantResponseSync br.com.xxxxxxxxx.xi.apo.global.QueryCriticalResourceInImplBean.findCriticalResourceByPlant(br.com.xxxxxxxxx.xi.apo.global.ResourceSimpleByPlantQuerySync)
throws br.com.xxxxxxxxx.xi.apo.global.StandardMessageFault_Exception method on bean instance br.com.xxxxxxxxx.xi.apo.global.QueryCriticalResourceInImplBean@1eda952
for bean xxxx.com.br/crvp~ear~services*annotation|xxxx.com.br~crvp~ejb~services.jar*annotation|QueryCriticalResourceInImplBean

in application xxxx.com.br/crvp~ear~services.; nested exception is: javax.xml.ws.WebServiceException:
Invalid Response code (401). Server <http://erp.esworkplace.sap.com/sap/bc/srt/xip/sap/ecc_workcentre001qr/version2?sap-client=800> returned message <Unauthorized>.

javax.xml.ws.WebServiceException: Invalid Response code (401). 
Server <http://erp.esworkplace.sap.com/sap/bc/srt/xip/sap/ecc_workcentre001qr/version2?sap-client=800> returned message <Unauthorized>.

Maybe i forget some steps, i just don't put the ENDPOINT_ADDRESS_PROPERTY property in BindingProvider, but others examples don't have, and if i put, the errors continues.

Any ideia?

Regards

Marcos