[jboss-user] Re: UsernameToken authentication using JBossWS
Leandro Sales
leandroal at gmail.com
Thu Dec 6 17:11:29 EST 2007
Please, someone to help me on the implementation of user auth via
UsernameToken Method
2007/12/6, Leandro Sales <leandroal at gmail.com>:
> Hi folks,
>
> I need to consume a certain webservice that use a UsernameToken
> authentication method. Using SOAPui it generate the following SOAP
> envelop:
>
> <soapenv:Envelope
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:sec="http://www.vaisala.com/security"
> xmlns:vais="http://www.vaisala.com/">
> <soapenv:Header>
> <sec:UsernameToken>
> <sec:username>?</sec:username>
> <sec:password>?</sec:password>
> </sec:UsernameToken>
> </soapenv:Header>
> <soapenv:Body>
> <vais:GetStations/>
> </soapenv:Body>
> </soapenv:Envelope>
>
> I use the wsconsumer.sh and jboss generated all the java classes
> necessary to have the objects, and I have the following code:
>
> (... some imports ...)
>
> @Stateless
> @WebService(endpointInterface="bean.WeatherInfoIF")
> @WebServiceClient(name = "Vaisala", targetNamespace = "http://www.xxx.com/",
> wsdlLocation = "http://xxx/WebS/xxx.asmx?WSDL")
> public class MyInfoBean implements InfoIF {
>
> public MyInfoBean() {
>
> }
>
> public String makeRequest(int arg0) {
> Service service = null;
>
> try {
> URL wsdlLocation = new URL("http://xxx/WebS/xxx.asmx?WSDL");
> QName serviceName = new QName("http://www.xxx.com/", "TheService");
> service = Service.create(wsdlLocation, serviceName);
> }
> catch(Exception e)
> {
> e.printStackTrace();
> }
>
> ServiceSOAP serviceSoap = service.getPort(ServiceSOAP.class);
>
> URL url = null;
> try {
> url = new File("/home/leandro/jboss-wsse-client.xml").toURL();
> ((StubExt)serviceSoap).setSecurityConfig(url.toExternalForm());
> } catch (MalformedURLException e) {
> e.printStackTrace();
> }
>
> ((StubExt)serviceSoap).setConfigName("Standard WSSecurity Client");
>
> UsernameToken usernameToken = new UsernameToken();
> usernameToken.setUsername("user");
> usernameToken.setPassword("pass");
>
> // I NEED TO PASS THE UsernameToken information to be inserted
> into the SOAP-Header of the SOAP envelop, how to do this?
>
> String stations = serviceSoap.getName();
>
>
> return "";
> }
>
> }
>
> I can't call serviceSoap.getName() because I don't know how to pass
> the UsernameToken object. Anyone to help me?
>
> Thank you,
> Leandro.
>
--
Leandro Melo de Sales.
Pervasive and Embedded Computing Laboratory
BRisa and E-Phone Projects Manager
Network Admin @ http://embedded.ufcg.edu.br/indexen.html
+55 83 3310-1404 (extension 208)
O especialista é alguém que conhece sempre mais sobre cada vez menos e
termina por saber tudo sobre nada!
More information about the jboss-user
mailing list