Friday, May 11, 2012

SOAP/WSDL Wrangling

Went looking for how to do client-side SOAP in Java, given a WSDL file. Found a couple of tutorials on how to create the server side; not what I wanted. Down at the end, they mentioned "oh yeah, to test the server, write a client, and here's how to do that in Netbeans". We don't use Netbeans. Grrr.

Back to StackOverflow. Found mention of wsimport. Hey, I've already got that installed. Apparently, wsimport is part of JAX-WS, and Glassfish is the reference implementation. So how do I use it? Finally found docs for using wsimport to generate client-side stub classes, and sample client code to call it.

Initially, I thought running wsimport was as simple as wsimport foo.wsdl; doing that creates classfiles under the current directory. jar cf foo.jar com packs those up in a jar (minus the manifest; is that a problem?). Add that jar to your project, and start writing Java code with them.

It seems a typical JAX-WS pattern is to instantiate a Service class, and use it to get a Port class. From there, calls from the client to the server involve calling methods on the Port class, i.e.:

FreightRateService svc = new FreightRateService();
FreightRatePortType port = svc.getFreightRatePort();

FreightRateResponse frResp = port.processFreightRate( frReq, upsSec );

In this example, the frReq and upsSec objects are instantiated from other classes in the generated jars, that are used to pass data from the client to the server. frResp can then be examined for return data. It's actually not much more complicated than that.

Except!

Except, when you run wsimport on a local WSDL, the generated class files contain an absolute path to your WSDL file in them. Not sure why the class files aren't enough, but apparently the WSDL is also needed at runtime. Apparently there are a few different ways to go about getting the WSDL file loaded:
  1. Make sure the absolute path is correct and sufficient. This might be the case if you're building the WSDL jar on the same box that you're deploying on.
  2. Use wsimport's -wsdllocation parameter. This might work if you can put the WSDL file in the same place on all boxes (i.e. development and production) that you intend to run the system on.  In my case, I develop on Linux and deploy to Windows, so no dice.
  3. Use wsimport's -wsdllocation and -catalog parameter. Never got this to work, but saw a StackOverflow post that mentioned it, that was quite highly voted up.
  4. Pass in a URL to the Service constructor, with your own path. This is what I settled on for Suzuki (see UPSRating.java), as it lets us put the file wherever we want, and (in theory) put the location into a properties file. You also need to pass in a QName (whatever that is), which I copied verbatim from the generated Service source file (i.e. FreightRateService.java); looks like it points to the WSDL's xsd or dtd or somesuch, maybe.
One last thing to mention, that I never solved.  While working on options 2 and 3 up there, I tried just specifying a bare filename, i.e.-wsdllocation FreightRate.wsdl. On my Linux box, running under Eclipse, it was looking for the WSDL in my home directory, and when the file wasn't there, it said so with a nice, clear error message. Something like FileNotFoundException: /home/djaquay/FreightRate.wsdl. Polite. Then I deployed it to Windows, thinking/hoping that it'd tell me in like fashion where it was looking for the WSDL. But there, I got the following:

No wsdl metadata with the Service, cant create proxy! Try creating Service by providing a WSDL URL

And Google, for once, wasn't my friend.  No matches at all, outside of one lone forum post asking, essentially, WTF?, and getting no real answer.  So if anybody knows what's up with that error, leave a comment.  I ran out of time to get stuff working, and went with option 4, but I'd still like to know what that error is about.

So yeah, SOAP is nice in theory, and a hassle in practice.  Have fun.

Monday, March 05, 2012

GDB Basics

Not gonna try to do a GDB tutorial, but rather just post what I learned in trying to debug a C program that I had to modify. Some simple stuff:

break - set breakpoint at the start of that method
bt - print stack trace at current point
p - print (contents of) variable
l(ist) [nn] - print code around current point, or around line nn
run - start running program
c - continue (running freely)
n - next, step over
s - step into
quit - go home, all done

That'll get you pretty far, but the code I was modifying was using fork() to daemonize itself, and gdb was quitting as the initial process quit. So I used:

set follow-fork-mode

to get it to debug the child. Except, the child was forking as well, and I went the wrong way into that child. So I did the following:

1: set follow-fork-mode child
2: break forkChildProcesses
3: run
4: set follow-fork-mode parent
5: break 520
6: c

(1) set the follow mode, (2) set a breakpoint in the daemon, (3) ran to that breakpoint, (4) set the follow mode back, so I would stay in the daemon and not go into the daemon's children, (5) set a new breakpoint at line 520, where I thought the problem started, and (6) continued execution.

And yeah, run starts the program running, while c continues it. Got confused the first time I tried to run a program I'd already started, and it tried to confirm that I wanted to restart. Oops.

Tuesday, July 05, 2011

HP Laptop Headphone Fix

Love my HP Pavilion DV6 laptop, and love Ubuntu running on it, but found an issue with my headphone, that plugging into the jack didn't turn off the speakers.  Did some poking around, and found that adding:

options snd-hda-intel model=hp-dv5

to my /etc/modprobe.d/alsa-base.conf took care of it.  There are other values for model that can solve issues with other machines.  For reference, lspci reports:

00:1b.0 Audio device: Intel Corporation 5 Series/3400 Series Chipset High Definition Audio (rev 05)

for my audio card, and cat /proc/asound/card0/codec* | grep Codec reports:

Codec: IDT 92HD75B3X5
Codec: Intel IbexPeak HDMI

for my codec(s).

Tuesday, November 23, 2010

SQL Server 2000 notes

A place for stuff that I don't want to forget. (There's stuff I only do with it once a year, and I'm perpetually looking this stuff back up.)

1) bcp.exe will let you dump a table at a time to a CSV file. DTS absolutely sucks for the same task, as it's a stinkin' wizard, that doesn't remember what you did last time, etc., etc., blah blah freakin' blah. You can at least script bcp with a .bat file, and have a record of what you did, for next time.

Labels:

Thursday, November 18, 2010

Ubuntu 10.10 Upgrade

SpongeBob (my laptop): 10.04 -> 10.10

Done, no issues yet, love the new font.

Patrick (downstairs desktop): 9.10 -> 10.04 -> 10.10

9.10 to 10.4 went smoothly.

10.4 to 10.10 wouldn't bring up X. Poked around on forums, found "no screens found" message in /var/log/Xorg.0.log, moved xorg.conf out of /etc/X11, did "restart gdm" and it worked. Rebooted, and it worked.

MrCrabs (Son's laptop): 9.10 -> 10.04 -> 10.10

Done, no issues yet.

(work laptop): 10.04 -> 10.10

Screen started working again, wireless works on reboot (both were problems with 10.04). alsamixer still doesn't retail settings over a reboot (which it hasn't done since at least 9.10, maybe 9.04).

New problems:

1) Audio cuts out in just a few minutes of use.

2) CPU usage is up. Looking at top, appears to be processes called kslowd000 and kslowd001. Googled them, and apparently they're kernel daemons used for background processing (so as not to interfere with main CPU processing?). Looking further, this might be related to my GPU, as others with kslowd issues were also using an Intel 855GM.

Decided to reboot; didn't fix #2. Decided to boot into 2.6.32-25 (was running 2.6.35, which is apparently when the kslowd problems started, at least for Ted T'so on the kernel mailing list). Not only did kslowd stop showing up in top, but now problem #1, with the audit, seems to be fixed as well (quite possibly unrelated to #2, except by differing code between the two kernels).

So, for now, will stay in 2.6.32, as it's nice to not need to schlep MP3's over to my phone to listen to music at work. Will try out 2.6.36 when it comes down the pipe, probably.

Update: went up to 2.6.35-23-generic, and it seems to have improved both issues. Will keep this updated, but for now, I'm back up to 2.6.35.

Another update: while my audio and CPU usage issues were better, laptop was locked up with a blank screen for the past two mornings when I came into work. So I'm back to 2.6.32 for now.

(work desktop): 10.04 -> 10.10

Done, no issues yet. Well, except for that odd thing with my 2nd HD coming up randomly as /dev/sda and /dev/sdc. Fixed it by putting the drive's UUID in /etc/fstab.

Labels:

Friday, August 20, 2010

Bind for Logging

Talked to Rob and Nate, and both agree that to log internal web requests, setting up my own bind is the easy way to go, then set the router to set all internal machines to it via static dns on dhcp.

Installing was a snap (straight out of Synaptic), and it just worked, right out of the box. Logging wasn't turned on, but that took 5 mins. Don't need logrotate, as bind9 logging has that built in. Manually, I wrote a cut/sort/uniq/grep script, but I didn't have mail installed, (or the brainpower left at end of day), so the script will have to wait briefly.

I set the router's static DNS to this box, and by this morning, was getting requests from the XBox and Wii, as well as Wife's Macbook.

I added an entry to my crontab to generate the filtered list, putting it into ~/bin (for no real good reason). Given the size of it, I'll probably generate it nightly, but only mail it out weekly, and just poke around with adding things to the grep filter.

Installed first mailutils, then exim4, then mutt, then finally sendemail until the latter let me send email from the command line simply, without configuring an MTA. Configuring an MTA just isn't something I have the brainpower for tonight. Anyway, my ISP doesn't require authentication from within their network, so sendemail worked like a charm, after bzipping the file down, (apparently they have a size limit, or something?)

So crontab is setup to mail the log out weekly, and we'll see how it goes.

Thursday, August 19, 2010

Kicking Ivy out of Eclipse

To make Ivy-less operation easier, I:
  • Removed all of the jars from my development project in Eclipse
  • Created a directory (outside of the project)
  • Made symbolic links from that directory to my common jar path (i.e. "ln -s /usr/share/java/spring.jar ~/dist/project", etc.)
  • Added all of the jars to my Eclipse project in one operation (by clicking Add External JARs and highlighting all of the jars in that dir)
  • Scripted the creation of the symlinks, and added the script to SVN.
It might also be worth looking into how SVN handles symbolic links, which could make it feasible to add the symlinks into the projects as well.

Labels: