Problem with WS Security
cichykloszard Jan 23, 2010 9:44 AMHi everyone,
I`m trying to implement WS server and client with WS Security for several last days.
My server looks like:
package test;
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService()
public class Calculator {
@WebMethod
public int add(int value1, int value2) {
return value1 + value2;
}
}
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.4">
<servlet>
<display-name>Calculator</display-name>
<servlet-name>Calculator</servlet-name>
<servlet-class>
test.Calculator
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Calculator</servlet-name>
<url-pattern>/calculator</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
jboss-wsse-server.xml:
<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">
<key-store-file>WEB-INF/server.keystore</key-store-file>
<key-store-password>pass123</key-store-password>
<key-store-type>jks</key-store-type>
<trust-store-file>WEB-INF/server.truststore</trust-store-file>
<trust-store-password>pass123</trust-store-password>
<trust-store-type>jks</trust-store-type>
<key-passwords>
<key-password alias="server" password="pass123" />
</key-passwords>
<config>
<encrypt type="x509v3" alias="client" />
<requires>
<encryption />
</requires>
</config>
</jboss-ws-security>
I`ve put server.keystore and server.truststore into web-inf direcotry.
My Client:
package test;
import org.jboss.ws.annotation.EndpointConfig;
@EndpointConfig(configName="Standard WSSecurity Endpoint")
public class Client {
public static void main(String[] args) {
CalculatorService svc = new CalculatorService();
Calculator calc = svc.getCalculatorPort();
System.out.println("2 + 2 = " + calc.add(2, 2));
}
}
I`ve put client.keystore, client.truststore, jboss-wsse-client.xml and standard-jaxws-client-config.xml to meta-inf directory.
When I deploy server, I can see wsdl file. But when I run the client i get :
Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: org.jboss.ws.core.CommonSOAPFaultException: This service requires <wsse:Security>, which is missing.
at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(Unknown Source)
at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(Unknown Source)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(Unknown Source)
at $Proxy25.add(Unknown Source)
at test.Client.main(Client.java:9)
Can anyone help me?
Marcin Ostachowski