Another Prague? In the U.S.?

NetBeans IDE has taught me a lot, but not that there's another Prague. You would've thought that one would be more than enough. Well, here's the proof -- thanks to a web service that Lukas Jungmann helped me with, I typed a random zip code in a web page:

When I clicked "Find the City!", a new web page popped up and this is what I saw:

Of course, NetBeans didn't do this on its own -- it used this WSDL file:

http://www.innergears.com/WebServices/CityStateByZip/CityStateByZip.asmx?WSDL

NetBeans IDE includes a cool template that very quickly generates a web service client for you. There's even a built-in client, which means that you need not do any coding -- you can test your web service right away. Then, knowing that the WSDL works as expected, you can add a very small bit of code to a servlet and bob's your uncle. This was the important part that I had a little trouble with, it's part of the processRequest method in the servlet:

String zipCode = request.getParameter("zipCode");
out.println("<b>Zip:</b>");
out.println(zipCode);
out.println("<p><b>City and State:</b>");
String[] s = getCityStateByZipSoap().getCityStateByZip(zipCode).getString();
out.println(Arrays.asList(s));

Now that I know how to work with complex types, working with web services is going to be much easier, since many (if not most) web services seem to use complex types.

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
12
13
14
23
24
25
26
27
28
29
30
   
       
Today