Microsoft to enter the smartphone business?
Dell, now Microsoft? It seems highly unlikely, but there is some chatter out there.
The software technology hound. Sharing and discussing software technology news, tips, and more. Woof!
Dell, now Microsoft? It seems highly unlikely, but there is some chatter out there.
The Palm Pre is a beautiful thing indeed. Even Walt Mossberg was impressed.
Toyota is rolling out a service called Lexus Insider that involves delivering audio messages of up to 3 minutes in length to your Lexus. Its an opt-in service available only on certain models. This could have some potential as a reminder service, but the potential for it to become annoying is very high.
So you don't know SOAP from WSDL? Whether you're coming from the RESTful school when it comes to building out web services, or you've simply managed to not get involved in web services altogether, here's a really simple tutorial describing how you can access an existing SOAP web service from Java in less than 20 minutes.
% java org.apache.axis.wsdl.WSDL2Java Weather.wsdl
We can also accomplish this with a simple ant build.xml file:<project name="axisSamples" default="run-client">
<property name="librarydir" value="C:\axis-1_4\lib"/>
<path id="libraries">
<fileset dir="${librarydir}">
<include name="*.jar"/>
</fileset>
</path>
<target name="run-wsdl2java">
<java fork="true" dir="src" classname="org.apache.axis.wsdl.WSDL2Java" classpathref="libraries">
<arg line="../Weather.wsdl"/>
</java>
</target>
Either way, after successfully running the WSDL2Java tool you'll find the generated Java bindings for the services described in the WSDL file in the same directory. The generated classes will be found within a package hierarchy that was generated using the target namespace used within the WDSL file. In our example, the package will be com.cdyne,ws.WeatherWS. public com.cdyne.ws.WeatherWS.WeatherSoap getWeatherSoap() throws javax.xml.rpc.ServiceException {
java.net.URL endpoint;
try {
endpoint = new java.net.URL(WeatherSoap_address);
} catch (java.net.MalformedURLException e) {
throw new javax.xml.rpc.ServiceException(e);
}
return getWeatherSoap(endpoint);
}
This method returns an instance that implements the interface com.cdyne.ws.WeatherWS.WeatherSoap. If we take a look at the interface (in WeatherSoap.java) we can see the details of the operations the SOAP weather service makes available:public interface WeatherSoap extends java.rmi.Remote {
/**
* Gets Information for each WeatherID
*/
public com.cdyne.ws.WeatherWS.WeatherDescription[] getWeatherInformation() throws java.rmi.RemoteException;
/**
* Allows you to get your City Forecast Over the Next 7 Days,
* which is updated hourly. U.S. Only
*/
public com.cdyne.ws.WeatherWS.ForecastReturn getCityForecastByZIP(java.lang.String ZIP) throws java.rmi.RemoteException;
/**
* Allows you to get your City's Weather, which is updated hourly.
* U.S. Only
*/
public com.cdyne.ws.WeatherWS.WeatherReturn getCityWeatherByZIP(java.lang.String ZIP) throws java.rmi.RemoteException;
}
That's essentially all we need to know to write our simple Java client (TestClient.java) that accesses the remote web service:import com.cdyne.ws.WeatherWS.*;
import java.util.Calendar;
/**
* @author spkydog (http://spkydog.blogspot.com)
*
*/
public class TestClient {
public static void main(String[] args) {
try {
Weather wservice = new WeatherLocator();
WeatherSoap wsrv = wservice.getWeatherSoap();
ForecastReturn retVal = wsrv.getCityForecastByZIP("49426");
if (retVal.isSuccess()) {
System.out.println("The weather forecast for "
+ retVal.getCity() + ", "
+ retVal.getState() + " is:\n ");
Forecast[] forecasts = retVal.getForecastResult();
for(Forecast f : forecasts) {
Calendar date = f.getDate();
System.out.println(date.get(Calendar.DAY_OF_MONTH)
+ "/" + date.get(Calendar.YEAR)
+ ": " + f.getDesciption());
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
Notice that WSDL2Java also generates all the various types used as input and output to the methods supported by the web service. In this case, we have a variety of types, of which we use two in the simple client above (ForecastReturn.java and Forecast.java)% javac src/*.java src/com/cdyne/ws/WeatherWS/*.java
We can also build the code by adding a compile task to our build.xml file:<target name="compile" depends="run-wsdl2java">
<javac srcdir="src">
<classpath>
<path refid="libraries"/>
</classpath>
</javac>
</target>
We can run the client by entering the following command at a commandline console:% java TestClient
Or, if we haven't bothered to add the axis jar files to our environment's CLASSPATH variable, we can simply invoke the client via ant by adding this task:<target name="run-client" depends="compile">
<java fork="true" dir="src" classname="TestClient" classpathref="libraries">
<classpath path="src"/>
</java>
</target>
If all worked as planned, the client prints out the weather forecast ranging from yesterday to six days into the future:The weather forecast for Hudsonville, MI is:
28/2008: Partly Cloudy
29/2008: Mostly Cloudy
30/2008: Mostly Cloudy
31/2007: Partly Cloudy
1/2008: Mostly Cloudy
2/2008: Mostly Cloudy
3/2008: Mostly Cloudy
That's all there is to it! A zip archive with the complete source code and ant build.xml is available for download here.
TellMe's multimodal mobile directory search application won the Wall Street Journal's 2007 Innovation Award in the "Network/Internet Technologies" category.
Labels: multimodal, tellme
According to folks in the know, Microsoft is poised to gobble up Tellme.