2009-07-13

how to programmaticaly change jaxws service endpoint

sometimes there is a need to override an endpoint address whom default value is specified in wsdl resource. everything works fine by doing something like:
SomeServicePort ssp = service.getSomeServicePort();
BindingProvider proxy = (BindingProvider) ssp;
proxy.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://ep");

if an protocol of endpoint address differes in wsdl and its java implementation it could be a problem.
the solution is to use a value in wsdl which doesn't contain protocol specification e.g. REPLACE_WITH_ACTUAL_URL.

2009-07-08

multiple executions of jaxws-maven-plugin

for executing jaxws-maven-plugin multiple times, it is necessary to add staleFile element to configuration section of the plugin for each execution. this is very useful when there is a need to specify different parameters for wsimport which runs on various wsdls for example.

<executions>
<execution>
<id>client</id>
<phase>generate-sources</phase>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<verbose>true</verbose>
<keep>true</keep>
<extension>true</extension>
<wsdlDirectory>${wsdl.dir}</wsdlDirectory>
<wsdlFiles>
<wsdlFile>client/CRECS.wsdl</wsdlFile>
</wsdlFiles>
<packageName>sk.example.client</packageName>
<wsdlLocation>CRECS.wsdl</wsdlLocation>
<staleFile>${project.build.directory}/jaxws/stale/client.stale</staleFile>
</configuration>
</execution>
<execution>
<id>server</id>
<phase>generate-sources</phase>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<verbose>true</verbose>
<keep>true</keep>
<extension>true</extension>
<wsdlDirectory>${wsdl.dir}</wsdlDirectory>
<wsdlFiles>
<wsdlFile>server/CRESS.wsdl</wsdlFile>
</wsdlFiles>
<packageName>sk.example.server</packageName>
<wsdlLocation>CRESS.wsdl</wsdlLocation>
<staleFile>${project.build.directory}/jaxws/stale/server.stale</staleFile>
</configuration>
</execution>
</executions>

2009-07-07

code formatting for blogspot entries

due to missing blogspot editor support for embedding source code in a blog entry (or my poor blog editing knowledge) i was forced to browse for a web solution. I found useful this web app.


for a prettyprint someone might find useful following scripts which have to be added to your template's header:

<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushBash.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushGroovy.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPlain.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js' type='text/javascript'/>
<link href='http://alexgorbatchev.com/pub/sh/current/styles/shCore.css' rel='stylesheet' type='text/css'/>
<link href='http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css' rel='stylesheet' type='text/css'/>
<script type='text/javascript'>
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.all();
</script>

your escaped code should be embeded in the following tag then:

<pre class="brush: java;"/>

endorsements and maven

see this entry.

my post has only backup, bookmark and memo purpose.

<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>process-resources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.1</version>
<outputDirectory>${project.build.directory}/endorsed
</outputDirectory>
</artifactItem>
<artifactItem>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>2.1</version>
<outputDirectory>${project.build.directory}/endorsed
</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgument>-Djava.endorsed.dirs="${project.build.directory}/endorsed"
</compilerArgument>
<compilerVersion>1.6</compilerVersion>
<encoding>UTF-8</encoding>
<debug>false</debug>
<showWarnings>true</showWarnings>
<source>1.6</source>
<target>1.6</target>
</configuration>
<inherited>true</inherited>
</plugin>

<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argline>-Djava.endorsed.dirs="${project.build.directory}/endorsed"
</argline>
</configuration>
</plugin>