[jboss-user] [JBossWS] - Unable to create a WSClient that uses jboss-wsse-client.xml

noclueu2 do-not-reply at jboss.com
Mon Apr 2 18:57:24 EDT 2007


Hello All,
  I am trying to do a simple WS that requires a user/password and has encryption. I have the user/password working and the server (i think) is doing encryption but I cannot get my client to use the jboss-wsse-client.xml file. Here is all my code, step by step.

SERVER:
jboss-wsse-server.xml

  | <?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">
  |   <key-store-file>META-INF/wsse.keystore</key-store-file>
  |   <key-store-password>jbossws</key-store-password>
  |   <trust-store-file>META-INF/wsse.truststore</trust-store-file>
  |   <trust-store-password>jbossws</trust-store-password>
  |   <config>
  |     <sign type="x509v3" alias="wsse"/>
  |     <requires>
  |       <signature/>
  |     </requires>
  |   </config>
  | </jboss-ws-security>
  | 

ServerHandler.xml

  | <?xml version="1.0" encoding="UTF-8"?>
  | 
  | <handler-config>
  | 	<handler-chain>
  | 		<handler-chain-name>SecureHandlerChain</handler-chain-name>
  | 		<handler>
  | 			<handler-name>WSSecurityHandlerInbound</handler-name>
  | 			<handler-class>org.jboss.ws.extensions.security.jaxws.WSSecurityHandlerServer</handler-class>
  | 		</handler>
  | 	</handler-chain>
  | </handler-config>
  | 

Server Source:
TestMagicRemoteInterface.java

  | import javax.ejb.Local;
  | import javax.ejb.Remote;
  | 
  | @Local
  | @Remote
  | public interface TestMagicRemoteInterface {
  | 	String pullFromHat(String input);
  | }
  | 

TestMagicBean.java

  | import javax.annotation.PostConstruct;
  | import javax.annotation.security.RolesAllowed;
  | import javax.ejb.Local;
  | import javax.ejb.Remote;
  | import javax.ejb.Stateless;
  | import javax.jws.WebMethod;
  | import javax.jws.WebResult;
  | import javax.jws.WebService;
  | import javax.jws.HandlerChain;
  | import javax.jws.soap.SOAPBinding;
  | 
  | import org.jboss.annotation.ejb.RemoteBinding;
  | import org.jboss.annotation.security.SecurityDomain;
  | import org.jboss.ws.annotation.WebContext;
  | 
  | @WebService(name = "EndpointInterface",
  | 		targetNamespace = "http://com.test.www/test/jsr181ejb",
  | 		serviceName = "MagicService")
  | @SOAPBinding(style = SOAPBinding.Style.RPC)
  | @Local(TestMagicRemoteInterface.class)
  | @Remote(TestMagicRemoteInterface.class)
  | @RolesAllowed("internal")
  | @Stateless
  | @RemoteBinding(jndiBinding = "/ejb3/TestMagician")
  | @WebContext(authMethod="BASIC", transportGuarantee="NONE", secureWSDLAccess=false)
  | @SecurityDomain(value="JBossWS")
  | @HandlerChain(file="resource://config/ServerHandler.xml", name="SecureHandlerChain")
  | public class TestMagicBean implements TestMagicRemoteInterface {
  | 
  | 	@WebMethod(operationName="PullFromHat")
  | 	@WebResult(name = "hat")
  | 	public String pullFromHat(String input) {
  | 		return "White Rabbit--"+input;
  | 	}
  | }
  | 

build.xml


  | <?xml version="1.0" encoding="UTF-8"?>
  | <project default="dist" basedir="." name="JBossWS-Tests">
  | 	<property file="${basedir}/build.properties"/>
  | 
  | 	<property name="dist.dir" value="${basedir}/dist"/>
  | 	<property name="bin.dir" value="${basedir}/bin"/>
  | 	<property name="src.dir" value="${basedir}/src"/>
  | 	<property name="conf.dir" value="${basedir}/conf"/>
  | 	<property name="keystore.dir" value="${basedir}/keystore"/>
  | 
  | 	<property name="jboss.client" value="${jboss40.home}/client"/>
  | 	<property name="jboss.deploy" value="${jboss40.home}/server/${jboss.server.instance}"/>
  | 
  | 	<available classname="java.lang.Enum" property="HAVE_JDK_1.5"/>
  | 
  | 	<target name="check-jvm">
  | 		<fail message="jdk-1.5 is required" unless="HAVE_JDK_1.5"/>
  | 	</target>
  | 
  | 	<target name="prepare-classpath" depends="check-jvm">
  | 		<path id="core.classpath">
  | 			<pathelement location="${jboss40.home}/lib/jboss-common.jar"/>
  | 			<pathelement location="${jboss40.home}/lib/jboss-jmx.jar"/>
  | 			<pathelement location="${jboss40.home}/lib/jboss-system.jar"/>
  | 			<pathelement location="${jboss40.home}/lib/jboss-xml-binding.jar"/>
  | 		</path>
  | 		<path id="jbossws.classpath">
  | 			<fileset dir="${jboss.deploy}/deploy/jbossws.sar">
  | 				<include name="*.jar"/>
  | 			</fileset>
  | 			<pathelement location="${jboss.client}/jbossws-client.jar"/>
  | 			<pathelement location="${jboss.client}/jboss-jaxrpc.jar"/>
  | 			<pathelement location="${jboss.client}/jboss-saaj.jar"/>
  | 		</path>
  | 		<path id="ejb3.classpath">
  | 			<fileset dir="${jboss.deploy}/deploy/ejb3.deployer">
  | 				<include name="*.jar"/>
  | 			</fileset>
  | 			<pathelement location="${jboss.client}/jboss-ejb3-client.jar"/>
  | 			<pathelement location="${jboss.deploy}/lib/jboss-j2ee.jar"/>
  | 		</path>
  | 		<path id="wstools.classpath">
  | 			<pathelement location="${jboss.client}/jboss-xml-binding.jar"/>
  | 			<pathelement location="${jboss.client}/activation.jar"/>
  | 			<pathelement location="${jboss.client}/javassist.jar"/>
  | 			<pathelement location="${jboss.client}/jbossall-client.jar"/>
  | 			<pathelement location="${jboss.client}/jbossretro-rt.jar"/>
  | 			<pathelement location="${jboss.client}/jboss-backport-concurrent.jar"/>
  | 			<pathelement location="${jboss.client}/jbossws-client.jar"/>
  | 			<pathelement location="${jboss.client}/log4j.jar"/>
  | 			<pathelement location="${jboss.client}/mail.jar"/>
  | 		</path>
  | 		<path id="build.classpath">
  | 			<path refid="core.classpath"/>
  | 			<path refid="jbossws.classpath"/>
  | 			<path refid="ejb3.classpath"/>
  | 		</path>
  | 	</target>
  | 
  | 	<target name="wstools" depends="prepare-classpath">
  | 		<taskdef name="wstools" classname="org.jboss.ws.tools.ant.wstools"
  | 	 		classpathref="wstools.classpath"/>
  | 
  | 	</target>
  | 
  | 
  | 	<target name="compile" depends="prepare-classpath">
  | 		<delete dir="${bin.dir}"/>
  | 		<mkdir  dir="${bin.dir}"/>
  | 		<javac destdir="${bin.dir}">
  | 			<src path="${src.dir}"/>
  | 			<classpath refid="build.classpath"/>
  | 		</javac>
  | 	</target>
  | 
  | 	<target name="package" depends="compile">
  | 		<delete dir="${dist.dir}"/>
  | 		<mkdir  dir="${dist.dir}"/>
  | 		<jar destfile="${dist.dir}/${project.name}.jar">
  | 			<zipfileset dir="${bin.dir}">
  | 				<include name="**"/>
  | 			</zipfileset>
  | 			<zipfileset dir="${conf.dir}" prefix="config">
  | 				<include name="ServerHandler.xml"/>
  | 			</zipfileset>
  | 			<zipfileset dir="${conf.dir}" prefix="META-INF">
  | 				<include name="jboss-wsse-server.xml"/>
  | 			</zipfileset>
  | 			<zipfileset dir="${keystore.dir}" prefix="META-INF">
  | 				<include name="wsse.*"/>
  | 			</zipfileset>
  | 		</jar>
  | 	</target>
  | 
  | 
  | 	<target name="dist" depends="package">
  | 		<echo message="Preparing Dist"/>
  | 	</target>
  | </project>
  | 

Everything above builds and deploys and expects the client to use wsse:Security



Client Code:
jboss-wsse-client.jar


  | <?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">
  |   <key-store-file>c:/work/workspace/TestWebServicesClient/keystore/wsse.keystore</key-store-file>
  |   <key-store-password>jbossws</key-store-password>
  |   <trust-store-file>c:/work/workspace/TestWebServicesClient/keystore/wsse.truststore</trust-store-file>
  |   <trust-store-password>jbossws</trust-store-password>
  |   <config>
  |     <sign type="x509v3" alias="wsse"/>
  |     <requires>
  |        <encryption/>
  |     </requires>
  |   </config>
  | </jboss-ws-security>
  | 

wstools-config.xml

  | <?xml version="1.0" encoding="UTF-8"?>
  | 
  | <configuration xmlns="http://www.jboss.org/jbossws-tools"
  |    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  |    xsi:schemaLocation="http://www.jboss.org/jbossws-tools http://www.jboss.org/jbossws-tools/schema/jbossws-tool_1_0.xsd">
  | 	<wsdl-java file="http://localhost:8080/MagicService/TestMagicBean?wsdl">
  | 
  | 	</wsdl-java>
  | </configuration>
  | 

ClientTest.java

  | import java.net.URL;
  | import java.util.Map;
  | 
  | import javax.xml.namespace.QName;
  | import javax.xml.ws.BindingProvider;
  | 
  | import com.client.MagicService;
  | import com.client.EndpointInterface;
  | 
  | public class ClientTest {
  | 
  | 	public static void main(String[] args) {
  | 		System.setProperty("org.jboss.wsse.keyStore", "c:/work/workspace/TestWebServicesClient/keystore/wsse.keystore");
  | 		System.setProperty("org.jboss.wsse.keyStorePassword", "jbossws");
  | 		System.setProperty("org.jboss.wsse.keyStoreType", "x509v3");
  | 		System.setProperty("org.jboss.wsse.trustStore", "c:/work/workspace/TestWebServicesClient/keystore/wsse.truststore");
  | 		System.setProperty("org.jboss.wsse.trustStorePassword", "jbossws");
  | 		System.setProperty("org.jboss.wsse.trustStoreType", "x509v3");
  | 
  | 		
  | 		try {
  | 			System.out.println("Hello World, I'm about to do magic");
  | 			MagicService service = new MagicService();
  | 			EndpointInterface port = service.getEndpointInterfacePort();
  | 			BindingProvider bindingProvider = (BindingProvider) port;
  | 			Map<String, Object> reqContext = bindingProvider.getRequestContext();
  | 			reqContext.put(BindingProvider.USERNAME_PROPERTY, "myuser");
  | 			reqContext.put(BindingProvider.PASSWORD_PROPERTY, "mypassword");
  | 
  | 			System.out.println(port.pullFromHat("Java Client Test"));
  | 
  | 		} catch (Exception e) {
  | 			e.printStackTrace();
  | 		}
  | 
  | 	}
  | 
  | }
  | 


build.xml

  | <?xml version="1.0" encoding="UTF-8"?>
  | <project default="dist" basedir="." name="JBossWS-Tests">
  | 	<property file="${basedir}/build.properties"/>
  | 
  | 	<property name="dist.dir" value="${basedir}/dist"/>
  | 	<property name="bin.dir" value="${basedir}/bin"/>
  | 	<property name="src.dir" value="${basedir}/src"/>
  | 	<property name="conf.dir" value="${basedir}/conf"/>
  | 	<property name="keystore.dir" value="${basedir}/keystore"/>
  | 	<property name="thirdparty.dir" value="${basedir}/thirdparty"/>
  | 
  | 	<property name="jboss.client" value="${jboss40.home}/client"/>
  | 	<property name="jboss.deploy" value="${jboss40.home}/server/${jboss.server.instance}"/>
  | 
  | 	<available classname="java.lang.Enum" property="HAVE_JDK_1.5"/>
  | 
  | 	<target name="check-jvm">
  | 		<fail message="jdk-1.5 is required" unless="HAVE_JDK_1.5"/>
  | 	</target>
  | 
  | 	<target name="prepare-classpath" depends="check-jvm">
  | 		<path id="core.classpath">
  | 			<pathelement location="${jboss40.home}/lib/jboss-common.jar"/>
  | 			<pathelement location="${jboss40.home}/lib/jboss-jmx.jar"/>
  | 			<pathelement location="${jboss40.home}/lib/jboss-system.jar"/>
  | 			<pathelement location="${jboss40.home}/lib/jboss-xml-binding.jar"/>
  | 		</path>
  | 		<path id="jbossws.classpath">
  | 			<fileset dir="${jboss.deploy}/deploy/jbossws.sar">
  | 				<include name="*.jar"/>
  | 			</fileset>
  | 			<pathelement location="${jboss.client}/jbossws-client.jar"/>
  | 			<pathelement location="${jboss.client}/jboss-jaxrpc.jar"/>
  | 			<pathelement location="${jboss.client}/jboss-saaj.jar"/>
  | 		</path>
  | 		<path id="ejb3.classpath">
  | 			<fileset dir="${jboss.deploy}/deploy/ejb3.deployer">
  | 				<include name="*.jar"/>
  | 			</fileset>
  | 			<pathelement location="${jboss.client}/jboss-ejb3-client.jar"/>
  | 			<pathelement location="${jboss.deploy}/lib/jboss-j2ee.jar"/>
  | 		</path>
  | 		<path id="wstools.classpath">
  | 			<pathelement location="${jboss.client}/jboss-xml-binding.jar"/>
  | 			<pathelement location="${jboss.client}/activation.jar"/>
  | 			<pathelement location="${jboss.client}/javassist.jar"/>
  | 			<pathelement location="${jboss.client}/jbossall-client.jar"/>
  | 			<pathelement location="${jboss.client}/jbossretro-rt.jar"/>
  | 			<pathelement location="${jboss.client}/jboss-backport-concurrent.jar"/>
  | 			<pathelement location="${jboss.client}/jbossws-client.jar"/>
  | 			<pathelement location="${jboss.client}/log4j.jar"/>
  | 			<pathelement location="${jboss.client}/mail.jar"/>
  | 			<path refid="core.classpath"/>
  | 			<path refid="jbossws.classpath"/>
  | 			<path refid="ejb3.classpath"/>
  | 		</path>
  | 		<path id="build.classpath">
  | 			<path refid="core.classpath"/>
  | 			<path refid="jbossws.classpath"/>
  | 			<path refid="ejb3.classpath"/>
  | 		</path>
  | 		<path id="client.classpath">
  | 			<fileset dir="${jboss.client}">
  | 				<include name="*.jar"/>
  | 			</fileset>
  | 			<path refid="core.classpath"/>
  | 			<path refid="jbossws.classpath"/>
  | 			<path refid="ejb3.classpath"/>
  | 			<pathelement location="${jboss40.home}/lib/endorsed/xercesImpl.jar"/>
  | 		</path>
  | 	</target>
  | 
  | 	<target name="wstools" depends="prepare-classpath">
  | 
  | 		<taskdef name="wstools" classname="org.jboss.ws.tools.ant.wstools"
  | 	 		classpathref="wstools.classpath"/>
  | 		<!-- <wstools dest="${bin.dir}" config="conf/wstools-config.xml"/>  -->
  | 		<taskdef name="wsconsume" classname="org.jboss.ws.tools.jaxws.ant.wsconsume">
  | 			<classpath refid="wstools.classpath"/>
  | 			<classpath location="${thirdparty.dir}/jbossws-wsconsume-impl.jar"/>
  | 			<classpath location="${thirdparty.dir}/jaxb-xjc.jar"/>
  | 		</taskdef>
  | 		<wsconsume wsdl="http://localhost:8080/MagicService/TestMagicBean?wsdl" package="com.client" sourcedestdir="${src.dir}" keep="true"/>
  | 
  | 
  | 	</target>
  | 
  | 
  | 	<target name="compile" depends="prepare-classpath">
  | 		<delete dir="${bin.dir}"/>
  | 		<mkdir  dir="${bin.dir}"/>
  | 		<javac destdir="${bin.dir}">
  | 			<src path="${src.dir}"/>
  | 			<classpath refid="build.classpath"/>
  | 		</javac>
  | 	</target>
  | 
  | 	<target name="package" depends="compile">
  | 		<delete dir="${dist.dir}"/>
  | 		<mkdir  dir="${dist.dir}"/>
  | 		<jar destfile="${dist.dir}/${project.name}-Client.jar">
  | 			<manifest>
  | 				<attribute name="Main-Class" value="ClientTest"/>
  |             </manifest>
  | 			<zipfileset dir="${bin.dir}">
  | 				<include name="**"/>
  | 			</zipfileset>
  | 			<zipfileset dir="${conf.dir}" prefix="META-INF">
  | 				<include name="jboss-wsse-client.xml"/>
  | 			</zipfileset>
  | 		</jar>
  | 	</target>
  | 
  | 
  | 	<target name="dist" depends="package">
  | 		<echo message="Preparing Dist"/>
  | 	</target>
  | 
  | 	<target name="run" depends="dist">
  | 		<echo message="About To RUN"/>
  | 
  | 
  | 		<java classname="ClientTest"  fork="true">
  | 			<classpath>
  | 				<pathelement location="${dist.dir}/${project.name}-Client.jar"/>
  | 				<fileset dir="${jboss.client}">
  | 					<include name="*.jar"/>
  | 				</fileset>
  | 				<pathelement location="${jboss40.home}/lib/endorsed/xercesImpl.jar"/>
  | 			</classpath>
  | 		</java>
  | 	</target>
  | </project>
  | 

Jar File structure:

  |   META-INF
  |       jboss-wsse-client.xml
  |       Manifest.mf
  |   ClientTest.class
  |   com
  |      client
  |           MagicService.class
  |           EndpointInterface.class
  | 

My above code works if I do not include the jboss-wsse-server.xml but once I add it, the client fails. I do know that I had to add the HandlerChain to the server class for things to work, is there something similar that I have to do to the client?


Thanks,
Richard K


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4033861#4033861

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4033861



More information about the jboss-user mailing list