WSIT, Maven and wsimport - can they work together?

I am working on a small multi-module project in Maven. We separated the user interface from the database level using web services, and thanks to the jaxws-maven plugin, the creation of the WSDL and the WS client is more or less handled for us. (The plugin is essentially a wrapper around wsgen and wsimport.) So far, so good.

The problem occurs when I try to include WSIT security in the image. NetBeans allows me to easily create security metadata, but wsimport seems completely unable to deal with anything other than the Basic-auth level of security.

Here is our current, unsafe way to call wsimport during Maven build:

<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>jaxws-maven-plugin</artifactId> <version>1.10</version> <executions> <execution> <goals> <goal>wsimport</goal> </goals> <configuration> <wsdlUrls> <wsdlUrl>${basedir}/../WebService/target/jaxws/wsgen/wsdl/WebService.wsdl</wsdlUrl> </wsdlUrls> <packageName>com.yourcompany.appname.ws.client</packageName> <sourceDestDir>${basedir}/src/main/java</sourceDestDir> <destDir>${basedir}/target/jaxws</destDir> </configuration> </execution> </executions> </plugin> 

I tried playing with xauthFile, xadditionalHeaders, passing javax.xml.ws.security.auth.username and password through args. I also tried using wsimport from the command line to point to the WSDL created by Tomcat, which contains additional security information. However, nothing changes the composition of wsimport files created.

So, I think my question here is to get a WSIT-compatible client, did I leave Maven and the jaxws plugin unchanged? Is there a way to get the WSIT client to automatically generate? Or do I need to create a client manually?

Let me know if you need more information besides what I wrote here. I am deploying Tomcat, although this does not seem to be a problem, since Maven seems pleased to pull Metro into a deployed WAR file.

Thanks in advance!

EDIT: After many games with WSIT, this is what worked for me.

First, use Netbeans to create the WSIT client. Test it to make sure it works, and then move the WSIT configuration files (wsit-client.xml and [web service name] .xml) to the META-INF directory of the WS client project.

A relevant addition to your project in terms of security is the tag in the xml web service:

 <wsp:Policy wsu:Id="WebPortBindingPolicy"> <wsp:ExactlyOne> <wsp:All> <sc:CallbackHandlerConfiguration wspp:visibility="private"> <sc:CallbackHandler default="wsitUser" name="usernameHandler"/> <sc:CallbackHandler default="changeit" name="passwordHandler"/> </sc:CallbackHandlerConfiguration> <sc:TrustStore wspp:visibility="private" location="C:\Apps\apache-tomcat-6.0.24\certs\client-truststore.jks" type="JKS" storepass="changeit" peeralias="xws-security-server"/> </wsp:All> </wsp:ExactlyOne> </wsp:Policy> 

Obviously, there are some hard-coded dependencies here that we will need to manage during our build. User, password, trust store location and peeralias are the default development defaults and will change as the system moves from dev to testing and production. We play with several different strategies to manage this, but we will probably finish setting up the environment variables in Hudson to create in each environment.

The screenshot with the Maven jaxws plugin setup is a bit. We generate WSDL as part of the assembly, so we do not need to reference it locally. Here is the plugin tag for the wsimport command in our target WS client:

 <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>jaxws-maven-plugin</artifactId> <version>1.12</version> <executions> <execution> <goals> <goal>wsimport</goal> </goals> <configuration> <wsdlUrls> <wsdlUrl>${basedir}/../WebService/target/jaxws/wsgen/wsdl/WebService.wsdl</wsdlUrl> </wsdlUrls> <staleFile>${project.build.directory}/jaxws/stale/WebService.stale</staleFile> <packageName>com.yourcompany.appname.ws.client</packageName> <sourceDestDir>${basedir}/src/main/java</sourceDestDir> <destDir>${basedir}/target/jaxws</destDir> </configuration> <id>wsimport-generate-WebService</id> <phase>generate-sources</phase> </execution> </executions> <dependencies> <dependency> <groupId>javax.xml</groupId> <artifactId>webservices-api</artifactId> <version>2.0-b30</version> </dependency> </dependencies> <configuration> <sourceDestDir>${project.build.directory}/generated-sources/jaxws-wsimport</sourceDestDir> <xnocompile>true</xnocompile> <verbose>true</verbose> <extension>true</extension> </configuration> </plugin> 

And finally, of course, make sure that all of your projects that need to call the web services have the correct Metro setting.

+6
maven-2 web-services maven-plugin jax-ws wsit
source share
1 answer

Shouldn't you provide client WSIT configuration files for the client? What do you expect from wsimport exactly?

Edit: As implied, the WSIT document describes two client configuration files: wsit-client.xml and {wsdl file name}.xml and:

When the client starts, these files must be in the class path, either in the root directory of the path (for example, build / classes), or in the META-INF directory under the root of the classpath.

Transposed into a Maven project, the natural place for these files would be src/main/resources or src/main/resources/META-INF . Personally, I prefer to put them in META-INF.

+2
source share

All Articles