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.xxx.com/security"
xmlns:vais="http://www.xxx.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 "";
}
}
My jboss-wsse-client.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-ws-security
xmlns="http://www.jboss.com/ws-security/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jboss.com/ws-security/config
http://www.jboss.com/ws-security/schema/jboss-ws-security_1_0.xsd">
</jboss-ws-security>
By the way, I'm getting HTTP 404 Error when I try to access
http://www.jboss.com/ws-security/config.
I can't call serviceSoap.getName() because I don't know how to pass
the UsernameToken object. Anyone to help me?
Thank you,
Leandro.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4111042#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...