<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Logic Sector</title>
	<atom:link href="http://www.logicsector.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.logicsector.com</link>
	<description>I create cool software for a living. This is my site.</description>
	<lastBuildDate>Thu, 09 Feb 2012 08:54:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How to set up Streambaby under Mac OS X Lion 10.7</title>
		<link>http://www.logicsector.com/mac/how-to-set-up-streambaby-under-mac-os-x-lion-10-7/</link>
		<comments>http://www.logicsector.com/mac/how-to-set-up-streambaby-under-mac-os-x-lion-10-7/#comments</comments>
		<pubDate>Sat, 28 Jan 2012 20:50:59 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
				<category><![CDATA[mac]]></category>
		<category><![CDATA[tivo]]></category>
		<category><![CDATA[lion]]></category>
		<category><![CDATA[streambaby]]></category>
		<category><![CDATA[streaming]]></category>

		<guid isPermaLink="false">http://www.logicsector.com/?p=472</guid>
		<description><![CDATA[This post will help you set up Streambaby so it works on your Mac running Lion. You&#8217;ll see how to share your Mac&#8217;s Movies folder so you can easily view your videos on your big screen TV. To access Streambaby on your TiVo you will need a Tivo Premiere, TiVo Series 3, or TiVo HD. [...]]]></description>
			<content:encoded><![CDATA[<p>This post will help you set up <a href="http://code.google.com/p/streambaby/">Streambaby</a> so it works on your Mac running Lion. You&#8217;ll see how to share your Mac&#8217;s Movies folder so you can easily view your videos on your big screen TV. To access Streambaby on your TiVo you will need a Tivo Premiere, TiVo Series 3, or TiVo HD. The installation and configuration process takes roughly 10 minutes.</p>
<p>First&#8230; What is Streambaby? Basically, Streambaby is a free application that works with your current model TiVo to stream video from your computer to your TiVo DVR. It automatically shows up in your TiVo&#8217;s menus when Streambaby is running on your Mac.</p>
<p>In other words, having Streambaby is like hosting your own Netflix service, but with all of your own personal videos. <img src='http://www.logicsector.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Note the purpose of Streambaby is to <i>stream</i> rather than <i>transfer</i> your videos. Streambaby <i>does not</i> transfer video from your computer to your TiVo. (If you want to transfer videos from your computer to your TiVo then you&#8217;re looking for a different program called <a href="http://pytivo.sourceforge.net/wiki/index.php/OS_X_Install">pyTivo</a>.)</p>
<p>One of the things that makes Streambaby great is that you can store many terabytes of video on your Mac. With Streambaby your terabytes of video don&#8217;t consume valuable disk space on your TiVo itself, yet you can easily view the video anytime on any TiVo in your home. The video can be in any format supported by Streambaby and its dependent library, <a href="http://en.wikipedia.org/wiki/Ffmpeg">FFmpeg</a>.</p>
<p><i>This post assumes you have basic familiarity with the command line, etc. This is a pretty safe procedure, but the standard disclaimers apply about messing up your computer etc.</i> <img src='http://www.logicsector.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><span id="more-472"></span></p>
<h4>Java Installation</h4>
<p>Unlike previous versions of Mac OS X, Lion does not come with Java installed by default. If you have not installed Java on your Mac, then follow the steps below to install Java.</p>
<p>1. In Finder, go to <b>Applications</b> > <b>Utilities</b> > <b>Java Preferences</b> to launch the Java Preferences application.</p>
<p>2. If Java is not installed you&#8217;ll see an alert panel with the following text:<br />
<tt>"To open 'Java Preferences', you need to install a Java runtime. Would you like to install one now?"</tt><br />
If you <i>don&#8217;t</i> see the alert panel then Java is already installed and you can skip step 3.</p>
<p>3. Click the Install button on the alert panel and accept the license agreement. The Java runtime will be downloaded and installed.</p>
<h4>Streambaby Installation</h4>
<p>Now that Java is installed let&#8217;s install Streambaby itself.</p>
<p>1. Download the latest zipped copy of Streambaby from the Streambaby download page:<br />
<a href="http://code.google.com/p/streambaby/downloads/list">http://code.google.com/p/streambaby/downloads/list</a></p>
<p>2. Extract the zipped file you just downloaded and rename the folder to &#8220;streambaby&#8221; (lower case). Move the streambaby folder into your <tt>/Applications</tt> folder.</p>
<h4>FFmpeg Installation</h4>
<p>The ffmpeg library is used by Streambaby to transform your various video files into something that your TiVo can understand.</p>
<p>1. Download the latest <b>0.8.X</b> release of ffmpeg from here.<br />
<a href="http://pytivo.sourceforge.net/forum/ffmpeg-builds-for-mac-os-x-t1803.html">http://pytivo.sourceforge.net/forum/ffmpeg-builds-for-mac-os-x-t1803.html</a><br />
The one I downloaded was called &#8220;<tt>ffmpeg_mac-0.8.10-x64.zip</tt>&#8220;.</p>
<p>2. Extract the zipped file and copy it into the <tt>/Applications/streambaby</tt> folder.</p>
<h4>Streambaby Configuration</h4>
<p>The next step is creating a configuration file that Streambaby will use each time it runs. </p>
<p>1. There is already a file called &#8220;<tt>streambaby.ini</tt>&#8221; in the <tt>/Applications/streambaby</tt> folder. This contains the default Streambaby configuration. Open it in a text editor, such as TextEdit.app.</p>
<p>2. Replace the entire contents of the file with the text below. Edit it to contain the <i>path to your Movies folder</i> and the <i>shared folder name</i>. In this example the movies are stored in <tt>/Users/justin/Movies</tt> and the corresponding name that will appear in the TiVo menus is <tt>Justin's Movies</tt>.</p>
<pre class="brush: plain; light: true; title: ; notranslate">
dir.1=/Users/justin/Movies
dir.1.name=Justin's Movies
com.unwiredappeal.tivo.vm.ffjava.FFmpegJavaVideoModule=false
ffmpeg.path=/Applications/streambaby/ffmpeg
</pre>
<p>Don&#8217;t change the last two lines above. Save the configuration file and close it.</p>
<h4>Launching Streambaby</h4>
<p>There are two ways to launch Streambaby, manually via the command line or automatically at login. For your first test I recommend running Streambaby from the command line. Once you&#8217;ve verified it&#8217;s working then switch to the automatic startup method.</p>
<h5 style="color: LightSlateGray;">Manually Launching Streambaby</h5>
<p>The advantage of manually launching is that you&#8217;ll see the Streambaby app log in the terminal window.</p>
<p>1. You can manually start Streambaby by typing the following command in a Terminal window:</p>
<pre class="brush: plain; light: true; title: ; notranslate">
/Applications/streambaby/streambaby
</pre>
<p>You should see several lines of text as Streambaby starts up, similar to this example:</p>
<pre class="brush: plain; light: true; title: ; notranslate">
[justin@arwen:~]$ /Applications/streambaby/streambaby
Initializing StreamBaby v20111203-2132...
01/28/12 20:57:34 Listener: added factory
01/28/12 20:57:34 Main: streambaby ready &amp; listening.
</pre>
<p>2. You can now test access to your streaming folder from your TiVo (see &#8220;<b>Using Streambaby</b>&#8221; below). After you&#8217;ve verified it works, you can stop Streambaby with Control-C.</p>
<h5 style="color: LightSlateGray;">Automatically Launching Streambaby At Login</h5>
<p>You can have Mac OS X automatically launch Streambaby when you log into your Mac. Naturally, if you have auto-login turned on then Streambaby will start whenever you start your Mac. Streambaby will be automatically shut down when you log out.</p>
<p>1. Create a plain-text file in TextEdit with the following contents:</p>
<pre class="brush: xml; light: true; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;!DOCTYPE plist PUBLIC &quot;-//Apple Computer//DTD PLIST 1.0//EN&quot;
    &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt;
&lt;plist version=&quot;1.0&quot;&gt;
&lt;dict&gt;
    &lt;key&gt;Label&lt;/key&gt;
	&lt;string&gt;streambaby&lt;/string&gt;
    &lt;key&gt;WorkingDirectory&lt;/key&gt;
	&lt;string&gt;/Applications/streambaby/&lt;/string&gt;
    &lt;key&gt;ProgramArguments&lt;/key&gt;
	&lt;array&gt;
	    &lt;string&gt;/Applications/streambaby/streambaby&lt;/string&gt;
	&lt;/array&gt;
    &lt;key&gt;RunAtLoad&lt;/key&gt;
	&lt;true/&gt;
    &lt;key&gt;KeepAlive&lt;/key&gt;
	&lt;true/&gt;
&lt;/dict&gt;
&lt;/plist&gt;
</pre>
<p>2. Save your file as &#8220;streambaby.plist&#8221; in your personal LaunchAgents folder, for example within <tt>/Users/justin/Library/LaunchAgents</tt>.</p>
<p>3. Log out and log in again. You can now test access to your streaming folder from your TiVo (see &#8220;<b>Using Streambaby</b>&#8221; below).</p>
<h4><i>Optional:</i> Hiding The Streambaby Icon In The Dock</h4>
<p>Streambaby is a Java application, and like most applications it will show an icon in the Dock when it runs. If you perform this optional step, then it will hide the Streambaby app icon when Streambaby runs. Other than hiding the app icon, there is no functional difference if you skip this step.</p>
<p>1. There is a file called &#8220;<tt>streambaby</tt>&#8221; in the <tt>/Applications/streambaby</tt> folder. This file is what is invoked when you run Streambaby. Open it in a text editor, such as TextEdit.app.</p>
<p>2. Add the following text (<span style="color: Chocolate; font-weight:bold;">in brown text</span>) to the &#8220;<tt>streambaby</tt>&#8221; file:</p>
<div style="font-family: Consolas,'Bitstream Vera Sans Mono','Courier New',Courier,monospace;">
#!/bin/bash<br />
DIRNAME=`dirname $0`<br />
java -Djava.net.preferIPv4Stack=true <span style="color: Chocolate; font-weight:bold;">-Dapple.awt.UIElement=true</span> -Xmx256m -jar &#8220;$DIRNAME/jbin/streambaby.jar&#8221; $@
</div>
<p></p>
<p>Save the file and close it.</p>
<h4>Using Streambaby</h4>
<p>On a Tivo Premiere running with HD menus enabled, the Streambaby menu shows up under <b>Showcases &#038; Apps</b> > <b>Stream, Baby, Stream</b>. Navigate to that menu item to see the videos that Streambaby is sharing with your TiVo. Note that the folder structure is hierarchical, so you can place subfolders within subfolders in your Mac&#8217;s video folder, and Streambaby will let you drill down into them on your TiVo. When you&#8217;re ready, simply select a video and click Play to start the stream. Voila!</p>
<p>BTW, when Streambaby is running it&#8217;s normal to see a generic Java app icon appear in your Mac&#8217;s Dock. Don&#8217;t shut down or otherwise mess with this Java app or else Streambaby will stop and you&#8217;ll have to restart it.</p>
<p>Advanced users may want to set up more than one shared video folder. For example, in addition to my <i>Movies</i> folder I share my <i>iTunes U</i> videos from within my iTunes folder on my Mac. See the Streambaby site for <a href="http://code.google.com/p/streambaby/wiki/StreamBabyIni">more details about how configure Streambaby</a>. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.logicsector.com/mac/how-to-set-up-streambaby-under-mac-os-x-lion-10-7/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>How to create a WSDL-first SOAP client in Java with CXF and Maven</title>
		<link>http://www.logicsector.com/java/how-to-create-a-wsdl-first-soap-client-in-java-with-cxf-and-maven/</link>
		<comments>http://www.logicsector.com/java/how-to-create-a-wsdl-first-soap-client-in-java-with-cxf-and-maven/#comments</comments>
		<pubDate>Tue, 06 Dec 2011 18:07:08 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[cxf]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[soap]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.logicsector.com/?p=154</guid>
		<description><![CDATA[This article was originally written in October 2008 and posted on my old blog at wordpress.com. I&#8217;ve retired that blog, so I&#8217;ve reposted the original contents here in the hope someone finds it useful. As of December 2011 the code still works great. Note I&#8217;m an iOS developer nowadays, not a Java developer, so regretfully [...]]]></description>
			<content:encoded><![CDATA[<p><font color="gray"><i>This article was originally written in October 2008 and posted on my old blog at <a href="http://logicsector.wordpress.com/2008/10/19/how-to-create-a-wsdl-first-soap-client-in-java-with-cxf-and-maven/">wordpress.com</a>. I&#8217;ve retired that blog, so I&#8217;ve reposted the original contents here in the hope someone finds it useful. As of December 2011 the code still works great. Note I&#8217;m an iOS developer nowadays, not a Java developer, so regretfully </i>I can&#8217;t offer any support nor updates if it doesn&#8217;t work for you<i>. Please feel free to read, comment, and link to the article here at its new home.</i></font></p>
<h3>Background</h3>
<p>About a week ago I needed to write a SOAP-based client for work.  The SOAP framework I&#8217;m using is Apache CXF.  I&#8217;m a total noob when it comes to SOAP services, and so I was a little apprehensive about this at first.  My apprehension sprung from hearing horror stories a few years ago from coworkers who were writing Axis SOAP applications, and they were basically tearing their hair out over Axis.  </p>
<p>However, word has it that CXF is much easier to use.  Well, it took me a while to get it working correctly.  In an effort to save other folks the same grief, I&#8217;ve posted my code here.  If you&#8217;re reading this, I&#8217;m assuming you&#8217;re acquainted with Java and Maven, but fairly new to SOAP, WSDL, etc.<br />
<span id="more-154"></span></p>
<p>To keep things simple, I decided to write a &#8220;Hello World&#8221; type of application first to make sure I could get the technology stack working correctly.  To keep things <i>really</i> simple, I decided to create a trivial Java &#8220;main&#8221; function that calls a SOAP service, logs the result to the console, and exits (no fancy web interface or anything like that).</p>
<h3>The SOAP Service Provider</h3>
<p>First I had to select an appropriate web service to test against.  There are a bunch of free SOAP-based web services out there, and I chose the CDyne weather service.  You can go <a href="http://wiki.cdyne.com/wiki/index.php?title=CDYNE_Weather">read all about it</a> if you want.</p>
<h3>Obtain the Service&#8217;s WSDL</h3>
<p>When you&#8217;re writing a new client in CXF for an existing web service, you start with the WSDL and work from there.  This means you need to get a copy of the WSDL from the service provider.  The WSDL for the CDyne weather service can be <a href="http://ws.cdyne.com/WeatherWS/Weather.asmx?wsdl">downloaded from their site</a>. You can simply right-click that link and save the WSDL on your hard drive.</p>
<p>Once you have the WSDL in hand, you can build your client around it.  Basically, you&#8217;ll use a CXF tool called <i>wsdl2java</i> to turn the WSDL into Java stub code that you then compile along with your application.</p>
<h3>Create the Maven Project</h3>
<p>As a recent convert to Maven, I set up a new Maven project.  I created a new project directory called <tt>weather-client</tt>, which is the <i>${basedir}</i>.  Also, I put the WSDL file in <tt>${basedir}/src/main/wsdl/weather.wsdl</tt>.  </p>
<p>Yeah, I know Maven has its fancy archetype creator thingie to emit the initial POM file, but like most pragmatic programmers I simply copy and paste a similar POM from somewhere else and modify it to suit my needs.  Here&#8217;s the project file I came up with.</p>
<p><tt>weather-client/<b>pom.xml</b></tt></p>
<pre class="brush: xml; title: ; notranslate">
&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
    xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0

http://maven.apache.org/maven-v4_0_0.xsd&quot;&gt;

    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
    &lt;groupId&gt;com.logicsector&lt;/groupId&gt;
    &lt;artifactId&gt;weather-client&lt;/artifactId&gt;
    &lt;version&gt;1.0&lt;/version&gt;
    &lt;name&gt;SOAP weather client&lt;/name&gt;
    &lt;packaging&gt;jar&lt;/packaging&gt;

    &lt;dependencies&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.apache.cxf&lt;/groupId&gt;
            &lt;artifactId&gt;cxf-rt-frontend-jaxws&lt;/artifactId&gt;
            &lt;version&gt;2.1.2&lt;/version&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.apache.cxf&lt;/groupId&gt;
            &lt;artifactId&gt;cxf-rt-transports-http&lt;/artifactId&gt;
            &lt;version&gt;2.1.2&lt;/version&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
            &lt;artifactId&gt;slf4j-api&lt;/artifactId&gt;
            &lt;version&gt;1.5.2&lt;/version&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
            &lt;artifactId&gt;slf4j-log4j12&lt;/artifactId&gt;
            &lt;version&gt;1.5.2&lt;/version&gt;
        &lt;/dependency&gt;
    &lt;/dependencies&gt;

    &lt;build&gt;
        &lt;finalName&gt;weather-client&lt;/finalName&gt;
        &lt;plugins&gt;
            &lt;!-- Generate Java classes from WSDL during build --&gt;
            &lt;plugin&gt;
                &lt;groupId&gt;org.apache.cxf&lt;/groupId&gt;
                &lt;artifactId&gt;cxf-codegen-plugin&lt;/artifactId&gt;
                &lt;version&gt;2.1.2&lt;/version&gt;
                &lt;executions&gt;
                    &lt;execution&gt;
                        &lt;id&gt;generate-sources&lt;/id&gt;
                        &lt;phase&gt;generate-sources&lt;/phase&gt;
                        &lt;configuration&gt;
                            &lt;sourceRoot&gt;${basedir}/target/generated/src/main/java&lt;/sourceRoot&gt;
                            &lt;wsdlOptions&gt;
                                &lt;wsdlOption&gt;
                                    &lt;wsdl&gt;${basedir}/src/main/wsdl/weather.wsdl&lt;/wsdl&gt;
                                    &lt;extraargs&gt;
                                        &lt;extraarg&gt;-client&lt;/extraarg&gt;
                                    &lt;/extraargs&gt;
                                &lt;/wsdlOption&gt;
                            &lt;/wsdlOptions&gt;
                        &lt;/configuration&gt;
                        &lt;goals&gt;
                            &lt;goal&gt;wsdl2java&lt;/goal&gt;
                        &lt;/goals&gt;
                    &lt;/execution&gt;
                &lt;/executions&gt;
            &lt;/plugin&gt;
            &lt;!-- Add generated sources - avoids having to copy generated sources to build location --&gt;
            &lt;plugin&gt;
                &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
                &lt;artifactId&gt;build-helper-maven-plugin&lt;/artifactId&gt;
                &lt;executions&gt;
                    &lt;execution&gt;
                        &lt;id&gt;add-source&lt;/id&gt;
                        &lt;phase&gt;generate-sources&lt;/phase&gt;
                        &lt;goals&gt;
                            &lt;goal&gt;add-source&lt;/goal&gt;
                        &lt;/goals&gt;
                        &lt;configuration&gt;
                            &lt;sources&gt;
                                &lt;source&gt;${basedir}/target/generated/src/main/java&lt;/source&gt;
                            &lt;/sources&gt;
                        &lt;/configuration&gt;
                    &lt;/execution&gt;
                &lt;/executions&gt;
            &lt;/plugin&gt;
            &lt;!-- Build the JAR with dependencies --&gt;
            &lt;plugin&gt;
                &lt;artifactId&gt;maven-assembly-plugin&lt;/artifactId&gt;
                &lt;configuration&gt;
                    &lt;descriptorRefs&gt;
                        &lt;descriptorRef&gt;jar-with-dependencies&lt;/descriptorRef&gt;
                    &lt;/descriptorRefs&gt;
                &lt;/configuration&gt;
            &lt;/plugin&gt;
        &lt;/plugins&gt;
        &lt;!-- Build with Java 1.5 --&gt;
        &lt;pluginManagement&gt;
            &lt;plugins&gt;
                &lt;plugin&gt;
                    &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                    &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                    &lt;configuration&gt;
                        &lt;source&gt;1.5&lt;/source&gt;
                        &lt;target&gt;1.5&lt;/target&gt;
                    &lt;/configuration&gt;
                &lt;/plugin&gt;
            &lt;/plugins&gt;
        &lt;/pluginManagement&gt;
    &lt;/build&gt;

&lt;/project&gt;
</pre>
<p>The only items of interest in the POM are:
<ul>
<li>We depend on the CXF v2.1.2 client libraries and the (most excellent) SLF4J logging system</li>
<li>We invoke the <b>cxf-codegen-plugin</b> to run <i>wsdl2java</i> to generate our Java stub code into <tt>${basedir}/target/generated/src/main/java</tt></li>
<li>We use the <b>build-helper-maven-plugin</b> so that Maven can compile from two source directories (normally Maven just compiles what&#8217;s in <tt>${basedir}/src/main</tt> and not <tt>${basedir}/target/generated/src</tt>, so we tell Maven to go compile the generated stub code too)</li>
<li>We use the <b>maven-assembly-plugin</b> to create a final JAR containing all necessary dependencies, which Maven will create as <tt>weather-client-jar-with-dependencies.jar</tt> when we perform a <tt>mvn assembly:assembly</tt></li>
</ul>
<p>At this point, even though I had no code in the project, I ran <tt>mvn assembly:assembly</tt> to build the Java stubs from the WSDL file.  The output is in the generated source directory mentioned earlier, in case you want to go poke at it.</p>
<h3>The Client Code</h3>
<p>Once we have the autogenerated stubs we can use them in a real Java program.  Before you can use the stubs, you have to identify what the actual <i>service object</i> is.  You can find out by looking at the generated stub code and see which Java class extends Service.  That will be the service interface that you call in your client.  In this case, the service is called simply &#8220;Weather&#8221;.</p>
<p>Without further ado, here&#8217;s the code I wrote to invoke the SOAP service:</p>
<p><tt>weather-client/src/main/java/com/logicsector/soapclient/<b>SoapClient.java</b></tt></p>
<pre class="brush: java; title: ; notranslate">
package com.logicsector.soapclient;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.cdyne.ws.weatherws.Forecast;
import com.cdyne.ws.weatherws.ForecastReturn;
import com.cdyne.ws.weatherws.POP;
import com.cdyne.ws.weatherws.Temp;
import com.cdyne.ws.weatherws.Weather;
import com.cdyne.ws.weatherws.WeatherSoap;

public class SoapClient {
    private static final Logger           LOGGER      = LoggerFactory.getLogger(SoapClient.class);
    private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat(&quot;EEEE, MMMM d yyyy&quot;);

    public static void main(String[] args) {
        try {
            LOGGER.debug(&quot;Creating weather service instance (Note: Weather = Service subclass)...&quot;);
            long start = new Date().getTime();
            // Get a reference to the SOAP service interface.
            Weather weatherService = new Weather();
            WeatherSoap weatherSoap = weatherService.getWeatherSoap();
            // An alternate way to get the SOAP service interface; includes logging interceptors.
            // JaxWsProxyFactoryBean factory = new org.apache.cxf.jaxws.JaxWsProxyFactoryBean();
            // factory.setServiceClass(WeatherSoap.class);
            // factory.setAddress(&quot;http://ws.cdyne.com/WeatherWS/Weather.asmx&quot;);
            // factory.getInInterceptors().add(new org.apache.cxf.interceptor.LoggingInInterceptor());
            // factory.getOutInterceptors().add(new org.apache.cxf.interceptor.LoggingOutInterceptor());
            // WeatherSoap weatherSoap = (WeatherSoap) factory.create();
            long end = new Date().getTime();
            LOGGER.debug(&quot;...Done! weatherService instance: {}&quot;, weatherService);
            LOGGER.debug(&quot;Time required to initialize weather service interface: {} seconds&quot;, (end - start) / 1000f);

            // Send a SOAP weather request for zip code 94025 (Menlo Park, CA, USA).
            LOGGER.debug(&quot;weatherSoap instance: {}&quot;, weatherSoap);
            start = new Date().getTime();
            ForecastReturn forecastReturn = weatherSoap.getCityForecastByZIP(&quot;94025&quot;);
            end = new Date().getTime();
            LOGGER.debug(&quot;Time required to invoke 'getCityForecastByZIP': {} seconds&quot;, (end - start) / 1000f);
            LOGGER.debug(&quot;forecastReturn: {}&quot;, forecastReturn);
            LOGGER.debug(&quot;forecastReturn city: {}&quot;, forecastReturn.getCity());
            LOGGER.debug(&quot;forecastReturn state: {}&quot;, forecastReturn.getState());
            LOGGER.debug(&quot;forecastReturn result: {}&quot;, forecastReturn.getForecastResult());
            LOGGER.debug(&quot;forecastReturn response text: {}&quot;, forecastReturn.getResponseText());
            LOGGER.debug(&quot;&quot;);
            List&lt;Forecast&gt; forecasts = forecastReturn.getForecastResult().getForecast();
            for (Forecast forecast : forecasts) {
                LOGGER.debug(&quot;  forecast date: {}&quot;, DATE_FORMAT.format(forecast.getDate().toGregorianCalendar().getTime()));
                LOGGER.debug(&quot;  forecast description: {}&quot;, forecast.getDesciption());
                Temp temps = forecast.getTemperatures();
                LOGGER.debug(&quot;  forecast temperature high: {}&quot;, temps.getDaytimeHigh());
                LOGGER.debug(&quot;  forecast temperature low: {}&quot;, temps.getMorningLow());
                POP pop = forecast.getProbabilityOfPrecipiation();
                LOGGER.debug(&quot;  forecast precipitation day: {}%&quot;, pop.getDaytime());
                LOGGER.debug(&quot;  forecast precipitation night: {}%&quot;, pop.getNighttime());
                LOGGER.debug(&quot;&quot;);
            }
            LOGGER.debug(&quot;Program complete, exiting&quot;);
        }
        catch (Exception e) {
            LOGGER.error(&quot;An exception occurred, exiting&quot;, e);
        }
    }

}
</pre>
<p>Note that we&#8217;re importing the stubs as <b>import com.cdyne.ws.weatherws.Forecast</b>, etc, within the client program.  The client is also hard-coded to get the weather report from the 94025 zip code, although you could easily alter the client to take the zip code as a command-line argument.</p>
<h3>The All-Important CXF Client Configuration File</h3>
<p>This is the part of the development process that threw me for a loop.  I didn&#8217;t see any CXF documentation that indicated a <tt>cxf.xml</tt> file needs to be in the classpath of the client, so I hadn&#8217;t included one in the project.  My client program kept failing with a (very cryptic, very unhelpful) CXF <i>BusException</i> (the complete message was <b>org.apache.cxf.BusException: No binding factory for namespace http://schemas.xmlsoap.org/soap/ registered</b>, which I&#8217;m mentioning here in case anyone else is Googling with the same problem).</p>
<p>Sure, there are plenty of CXF tutorials on the Internet, but they mostly seem to build a client and a service in the same project (sharing a cxf.xml file) and I had assumed the configuration file was for configuring only the <i>server</i>.  Silly me.  </p>
<p>It took me several <i>days</i> of Googling, trying different JAR dependencies, Googling again, testing various source code modifications, Googling some more, asking for help on the cxf-user mail list &#8212; all to no avail.  </p>
<p>Eventually, while reading the solution to an unrelated problem, I finally discovered the cause.  On start-up for a server OR A CLIENT, the CXF system looks for a cxf.xml file, and fails without it.  Just for the record, the BusException message is incredibly unhelpful.  Grrr!!  I think it should read something like <b>org.apache.cxf.BusException: No binding factory for namespace http://schemas.xmlsoap.org/soap/ registered <i>(did you include a cxf.xml file somewhere in the classpath?)</i></b>, or some such.</p>
<p>Anyhoo, here&#8217;s the CXF configuration file I used.  Not much to it.  It&#8217;s basically just a trivial Spring configuration with three lines of imports.</p>
<p><tt>weather-client/src/main/resources/<b>cxf.xml</b></tt></p>
<pre class="brush: xml; title: ; notranslate">
&lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
    xmlns:http-conf=&quot;http://cxf.apache.org/transports/http/configuration&quot;
    xsi:schemaLocation=&quot;http://cxf.apache.org/transports/http/configuration

http://cxf.apache.org/schemas/configuration/http-conf.xsd

http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans.xsd&quot;&gt;

    &lt;import resource=&quot;classpath:META-INF/cxf/cxf.xml&quot;/&gt;
    &lt;import resource=&quot;classpath:META-INF/cxf/cxf-extension-soap.xml&quot;/&gt;
    &lt;import resource=&quot;classpath:META-INF/cxf/cxf-servlet.xml&quot;/&gt;

&lt;/beans&gt;
</pre>
<p>Good thing this is easier than Axis.</p>
<h3>Logging Configuration</h3>
<p>For completeness, I&#8217;ve included the logging file I used.  Since we&#8217;re using LOG4J as the logging layer under SLF4J, we need to supply a log4j.properties file.</p>
<p><tt>weather-client/src/main/resources/<b>log4j.properties</b></tt></p>
<pre class="brush: java; title: ; notranslate">
log4j.rootCategory=WARN, CONSOLE
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=[%d{ABSOLUTE} %-5p %c{1}]: %m%n
log4j.logger.com.logicsector=DEBUG
</pre>
<h3>Building and Running the Client</h3>
<p>Once you have all the code in order, it&#8217;s time to build it.  From within the <tt>weather-client</tt> directory, just use the previously-mentioned Maven build command to create a JAR file with dependencies:</p>
<p><tt>mvn assembly:assembly</tt></p>
<p>Now we can run the client.  As mentioned previously, the client is hard-coded to get the weather report for the 94025 zip code (Menlo Park, California).  From within the <tt>weather-client</tt> directory, the following command will start the client and invoke the service:</p>
<p><tt>java -cp target/weather-client-jar-with-dependencies.jar com.logicsector.soapclient.SoapClient</tt></p>
<p>The command above should all be on a single line. Note you may need to change your path separator if you&#8217;re not on a Unix-based system. If everything went smoothly you should see output something like this:</p>
<pre class="brush: java; title: ; notranslate">
[17:31:06,278 DEBUG SoapClient]: Creating weather service instance (Note: Weather = Service subclass)...
Oct 18, 2008 5:31:08 PM org.apache.cxf.service.factory.ReflectionServiceFactoryBean buildServiceFromWSDL
INFO: Creating Service {http://ws.cdyne.com/WeatherWS/}Weather from WSDL: file:/c:/Projects/weather-client/src/main/wsdl/weat
her.wsdl
[17:31:08,325 DEBUG SoapClient]: ...Done! weatherService instance: com.cdyne.ws.weatherws.Weather@754fc
[17:31:08,325 DEBUG SoapClient]: Time required to initialize weather service interface: 2.047 seconds
[17:31:08,325 DEBUG SoapClient]: weatherSoap instance: org.apache.cxf.jaxws.JaxWsClientProxy@6458a6
[17:31:08,825 DEBUG SoapClient]: Time required to invoke 'getCityForecastByZIP': 0.5 seconds
[17:31:08,825 DEBUG SoapClient]: forecastReturn: com.cdyne.ws.weatherws.ForecastReturn@aea710
[17:31:08,825 DEBUG SoapClient]: forecastReturn city: Menlo Park
[17:31:08,825 DEBUG SoapClient]: forecastReturn state: CA
[17:31:08,825 DEBUG SoapClient]: forecastReturn result: com.cdyne.ws.weatherws.ArrayOfForecast@5a2eaa
[17:31:08,825 DEBUG SoapClient]: forecastReturn response text: City Found
[17:31:08,825 DEBUG SoapClient]:
[17:31:08,825 DEBUG SoapClient]:   forecast date: Friday, October 17 2008
[17:31:08,825 DEBUG SoapClient]:   forecast description: Sunny
[17:31:08,825 DEBUG SoapClient]:   forecast temperature high: 82
[17:31:08,825 DEBUG SoapClient]:   forecast temperature low: 58
[17:31:08,825 DEBUG SoapClient]:   forecast precipitation day: 00%
[17:31:08,825 DEBUG SoapClient]:   forecast precipitation night: 00%
[17:31:08,825 DEBUG SoapClient]:
[17:31:08,825 DEBUG SoapClient]:   forecast date: Saturday, October 18 2008
[17:31:08,825 DEBUG SoapClient]:   forecast description: Sunny
[17:31:08,841 DEBUG SoapClient]:   forecast temperature high: 73
[17:31:08,841 DEBUG SoapClient]:   forecast temperature low: 55
[17:31:08,841 DEBUG SoapClient]:   forecast precipitation day: 00%
[17:31:08,841 DEBUG SoapClient]:   forecast precipitation night: 00%
[17:31:08,841 DEBUG SoapClient]:
[17:31:08,841 DEBUG SoapClient]:   forecast date: Sunday, October 19 2008
[17:31:08,841 DEBUG SoapClient]:   forecast description: Partly Cloudy
[17:31:08,841 DEBUG SoapClient]:   forecast temperature high: 70
[17:31:08,841 DEBUG SoapClient]:   forecast temperature low: 55
[17:31:08,841 DEBUG SoapClient]:   forecast precipitation day: 00%
[17:31:08,841 DEBUG SoapClient]:   forecast precipitation night: 00%
[17:31:08,841 DEBUG SoapClient]:
[17:31:08,841 DEBUG SoapClient]:   forecast date: Monday, October 20 2008
[17:31:08,841 DEBUG SoapClient]:   forecast description: Partly Cloudy
[17:31:08,841 DEBUG SoapClient]:   forecast temperature high: 70
[17:31:08,841 DEBUG SoapClient]:   forecast temperature low: 53
[17:31:08,841 DEBUG SoapClient]:   forecast precipitation day: 00%
[17:31:08,841 DEBUG SoapClient]:   forecast precipitation night: 00%
[17:31:08,841 DEBUG SoapClient]:
[17:31:08,841 DEBUG SoapClient]:   forecast date: Tuesday, October 21 2008
[17:31:08,856 DEBUG SoapClient]:   forecast description: Sunny
[17:31:08,856 DEBUG SoapClient]:   forecast temperature high: 73
[17:31:08,856 DEBUG SoapClient]:   forecast temperature low: 54
[17:31:08,856 DEBUG SoapClient]:   forecast precipitation day: 00%
[17:31:08,856 DEBUG SoapClient]:   forecast precipitation night: 10%
[17:31:08,856 DEBUG SoapClient]:
[17:31:08,856 DEBUG SoapClient]:   forecast date: Wednesday, October 22 2008
[17:31:08,856 DEBUG SoapClient]:   forecast description: Sunny
[17:31:08,856 DEBUG SoapClient]:   forecast temperature high: 74
[17:31:08,856 DEBUG SoapClient]:   forecast temperature low: 55
[17:31:08,856 DEBUG SoapClient]:   forecast precipitation day: 00%
[17:31:08,856 DEBUG SoapClient]:   forecast precipitation night: 00%
[17:31:08,856 DEBUG SoapClient]:
[17:31:08,856 DEBUG SoapClient]:   forecast date: Thursday, October 23 2008
[17:31:08,856 DEBUG SoapClient]:   forecast description: Sunny
[17:31:08,856 DEBUG SoapClient]:   forecast temperature high: 73
[17:31:08,856 DEBUG SoapClient]:   forecast temperature low: 55
[17:31:08,856 DEBUG SoapClient]:   forecast precipitation day: 00%
[17:31:08,856 DEBUG SoapClient]:   forecast precipitation night: 00%
[17:31:08,856 DEBUG SoapClient]:
[17:31:08,856 DEBUG SoapClient]: Program complete, exiting
</pre>
<p>Interestingly, it takes 2 seconds on my machine to initialize the interface, which seems like a really long time.  CXF is probably doing a lot of stuff under the covers, but still, 2 seconds is <i>forever</i> in computer time.</p>
<p>The call to the weather service interface, once initialized, takes about half a second every time, which includes marshalling a SOAP request, sending it over the internet, receiving the response, and unmarshalling its contents.  Not too bad I guess.</p>
<h3>Concluding Thoughts</h3>
<p>Hopefully this example will form the basis of your next SOAP client.  It really is pretty easy once you see a complete and working example.</p>
<p>If you were ambitious, parts of this code could easily be incorporated into a web application that provides a weather report for the user.  You&#8217;d simply create a servlet that takes the zip code as a parameter, invokes the SOAP service, and shows the weather report in the response.  In other words, the technique of calling the SOAP service would be the same even if this was a web application.</p>
<p>Well, that&#8217;s the end of my post about creating a CXF client with Maven.  I&#8217;d love to read your comments if you found this post helpful.</p>
<h3><i>EDIT:</i> Download the Source!</h3>
<p>All the code necessary to build the project is listed above.  However, to save time, you can simply <a href="http://www.logicsector.com/wp-content/uploads/2011/12/weather-client.zip">download the code</a> from my web site.  Happy coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.logicsector.com/java/how-to-create-a-wsdl-first-soap-client-in-java-with-cxf-and-maven/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>BMW Angel Eyes</title>
		<link>http://www.logicsector.com/bmw/angel-eyes/</link>
		<comments>http://www.logicsector.com/bmw/angel-eyes/#comments</comments>
		<pubDate>Thu, 11 Aug 2011 06:55:34 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
				<category><![CDATA[bmw]]></category>
		<category><![CDATA[angel eyes]]></category>
		<category><![CDATA[halos]]></category>

		<guid isPermaLink="false">http://www.logicsector.com/?p=73</guid>
		<description><![CDATA[Some German cars come with &#8220;bling&#8221;. For example, Audis have a rope of LED &#8220;Christmas lights&#8221; under the headlights. New BMWs these days come with bright pure white halos around the headlights. These provide a unique high-tech look and are often called &#8220;angel eyes&#8221;. Angel eyes have changed over the years. BMWs that shipped back [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.logicsector.com/bmw/angel-eyes/"><img alt="" src="http://www.e92-lighting.com/images/mteca.jpg" title="MTEC angel eyes" class="alignright" width="46%" /></a>Some German cars come with &#8220;bling&#8221;. For example, Audis have a rope of LED &#8220;Christmas lights&#8221; under the headlights. New BMWs these days come with bright pure white halos around the headlights. These provide a unique high-tech look and are often called &#8220;angel eyes&#8221;.</p>
<p>Angel eyes have changed over the years. BMWs that shipped back in 2005 (the year my car was built) have a much dimmer, yellowish halos as original equipment. Fortunately the aftermarket has stepped up to offer upgrades to our dim, yellow halos.</p>
<p>The first generation of angel eye upgrades were just as dim as BMW&#8217;s original equipment at about 1 Watt, but they changed the yellow halos to white.</p>
<p>The latest aftermarket halo upgrades are not only white, but much brighter than the original halo upgrades. They&#8217;re still not quite as bright as halos on a new BMW, perhaps, but not too shabby either.</p>
<p>Armed with the above information I went searching for a nice halo upgrade. Here&#8217;s what I found. <span id="more-73"></span></p>
<h5>Where To Buy</h5>
<p>I discovered that a company called MTEC offers an upgrade to pure white halos that are rated at 6W with their so-called &#8220;V3&#8243; model. The LEDs in these units are made by Cree. These halos are about as bright as you can get, currently, without some extensive modifications to the car.</p>
<p>You can pick up MTEC parts at various online resellers or directly off eBay. I went the eBay route by purchasing from a vendor named &#8220;mtecpower&#8221;. If you&#8217;re an e63/e64 BMW driver you can find the right angel eyes by <a href="http://shop.ebay.com/i.html?_nkw=mtec+v3+cree+e64&amp;_sacat=0&amp;_odkw=mtec+v3+e64&amp;_osacat=0&amp;_trksid=p3286.c0.m270.l1313">clicking this eBay search link</a>. Total price should be less than $200.</p>
<h5>A Note About Installation</h5>
<p>The nice thing about the MTEC upgrades is that they are really easy to do yourself. It took me about 15 minutes to swap out both halo lights, but if I had known what I was doing it would have literally taken about 5 minutes. The only price was some scuffed knuckles and a cut pinky finger. For a 6 series like mine the headlights themselves don&#8217;t need to be removed, only the halo bulbs.</p>
<p>Note that to perform the upgrade you have to have pretty small hands since the gap in the engine bay near the halo bulbs is pretty tight. My pudgy hands barely fit.</p>
<p><a href="http://www.youtube.com/watch?v=E_xdeWqv5u4">Here is a link to a YouTube video that shows how it&#8217;s done.</a></p>
<h5>How It Looks</h5>
<p>With no further ado, here is the new look that shows the difference&#8230;</p>
<div id="attachment_86" class="wp-caption alignnone" style="width: 310px"><a href="http://www.logicsector.com/wp-content/uploads/2011/08/IMG_0206.jpg"><img class="size-medium wp-image-86" title="Halo Partial Install" src="http://www.logicsector.com/wp-content/uploads/2011/08/IMG_0206-300x224.jpg" alt="" width="300" height="224" /></a><p class="wp-caption-text">New halo on left, OEM halo on right. Taken in late afternoon.</p></div>
<div id="attachment_87" class="wp-caption alignnone" style="width: 310px"><a href="http://www.logicsector.com/wp-content/uploads/2011/08/IMG_0227.jpg"><img class="size-medium wp-image-87" title="MTEC Halo" src="http://www.logicsector.com/wp-content/uploads/2011/08/IMG_0227-300x224.jpg" alt="" width="300" height="224" /></a><p class="wp-caption-text">MTEC V3 halo upgrades installed in my car. Nice and bright!</p></div>
<div id="attachment_88" class="wp-caption alignnone" style="width: 310px"><a href="http://www.logicsector.com/wp-content/uploads/2011/08/IMG_0218.jpg"><img class="size-medium wp-image-88" title="MTEC V3 Halo With Headlight" src="http://www.logicsector.com/wp-content/uploads/2011/08/IMG_0218-300x224.jpg" alt="" width="300" height="224" /></a><p class="wp-caption-text">Headlight lit along with upgraded halos. Note white halo color matches headlight now.</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.logicsector.com/bmw/angel-eyes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

