Thursday, January 07, 2010

SOAPUI : Adding a wsdl

Assume a WSDL like:

http://host:port/ApplicationServer/Service

Sometimes when you are adding a WSDL like the above you get an error:

SOAPUIException: Error inporting wsdl

Try qualifying the URL i.e.

http://host:port/ApplicationServer/Service?wsdl

Enjoy!

Wednesday, January 06, 2010

SOAPUI : NoClassDefFoundError

Using SOAPUI 3.0.1 to test web services created using Netbeans, JAX-WS and Metro.

When I try and run the TestRunner, I get:


java.lang.NoClassDefFoundError: org/apache/commons/cli/CommandLineParser


My solution was to edit soapui.bat (in the /bin directory) and add:

set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_16

at the top.

Then, instead of running soapui.exe from the desktop shortcut, I open a command prompt and run soapui.bat from there manually.

Problem solved.

Enjoy!

Tuesday, January 05, 2010

Metro : Sniffing the traffic with JAX-WS, Netbeans and Metro

I often use Fiddler to view / log browser traffic.

From the web site: "Fiddler is a Web Debugging Proxy which logs all HTTP(S) traffic between your computer and the Internet. Fiddler allows you to inspect all HTTP(S) traffic, set breakpoints, and "fiddle" with incoming or outgoing data. Fiddler includes a powerful event-based scripting subsystem, and can be extended using any .NET language."

However, it doesn't work when you want to look at Java web service (SOAP) traffic generated by the JAX-WS support in Netbeans (i.e. Metro).

I have a number of command line tools that I use to generate various types of traffic with a command line like:


java -jar SomeProgram.jar


To get Fiddler to work, you need to change the command line to:


java -DproxySet=true -DproxyHost=127.0.0.1 -DproxyPort=8888 -jar SomeProgram.jar


Fiddler uses port 8888 as default.

Enjoy!

Tuesday, October 20, 2009

Blogger : Syntax highlighting for code

I hate the way Blogger displays code , XML etc, inside the "blockqoute" construct.

Then I came across this:

How to add syntax highlight to Blogger.

This uses Syntax Highlighter.

Just to add:

You don't need to host the files. You can use:

http://syntaxhighlighter.googlecode.com/svn/trunk/

e.g. the link in the article would become:
http://syntaxhighlighter.googlecode.com/svn/trunk/Styles/SyntaxHighlighter.css

Update: As per the comment:

More info. available here:
http://mlawire.blogspot.com/2009/07/blogger-syntax-highlighting.html

Warning: There are a number of posts around on how to do this - all slightly different - use at your own risk.

Enjoy!

Log4J : Path to properties file

For Glassfish, we normally put the log4j.properties in the "domain / config" directory.

To enable Glassfish to find it, add the following to the Glassfish JVM settings. Easiest way is to use the Admin console i.e. Application Server / JVM Settings / JVM Options.

Add this line:

-Dlog4j.configuration=file:///${com.sun.aas.instanceRoot}/config/log4j.properties

Enjoy!

Netbeans : Generating getters and setters for a Java class

Using Netbeans 6.5.

Unlike Eclipse (where the link to do this is obvious), in Netbeans you will find this under:

Refactor / Encapsulate Fields

Enjoy!

Metro : JAX WS catalogue

One of the problems with using Netbeans to generate web services using Glassfish / Metro is that when you want to create a new Web service client, you are asked to select the web service which is normally on your local machine.

This means that the web service has an address like http://localhost:8080 and it then becomes a problem when you deploy to other environments.

One way around this is to use a catalog to resolve the addresses at run time. The file is called jax-ws-catalog.xml and it's placed in the META-INF directory.

It looks like e.g.

 
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="system">
<rewriteSystem
systemIdStartString="http://localhost:8080/"
rewritePrefix="http://some url:some port/"/>
<rewriteURI
uriStartString="http://localhost:8080/"
rewritePrefix="http://some url:some port/" />
</catalog>


This searches for any URL that starts with "http://localhost:8080/" and replaces this with "http://some url:some port/" e.g.

http://localhost:8080/webserver/WebService

becomes

http://some url:some port/webserver/WebService

The ant build files in Netbeans use the -catalog option to point to a file called catalog.xml in the project root directory. You can apply the same principles to this file to resolve addresses at compile time.

Some useful links:

Using a JAX-WS Catalog

How to write an XML catalog file

Global URI re-writing with jax-ws-catalog

Enjoy!

Friday, August 07, 2009

Netbeans : New Web Service client error

I use Netbeans 6.7.

In the web applications project where you are trying to add a web service call to e.g. a servlet, click "New / Web Service Client" and select the project where the actual web service lives. When you click Finish, you get the error.

"wsimport doesn't support the "xnocompile" attribute"

To get round this:

In the project where you are trying to add the web service client, right-click the web service under the "Web Service Reference" sub-tree.

Select "Edit Web Service Attributes".

Click "WsImport Options" tab.

Select the xnocompile line and Remove then OK.

Right-click again on the web service under the "Web Service Reference" sub-tree.

Select "Refresh Client"

The client should now be created.

These a good tutorial about Netbeans web services
here

Enjoy!

Netbeans : Display Web Service Designer and Axis2

This is displayed (I use Netbeans 6.7) when you right click on a web applications project and select "New / Web Service".

You then get two tabs - Source and Design.

However, you do NOT see these tabs if you have previously loaded the Axis2 support plugin.

Enjoy!

Thursday, July 09, 2009

Eclipse : Problems with web.xml

If you use Eclipse with the Sysdeo plugin you sometimes get problems with web.xml when you add more servlet mappings. The message is:

The content of element type "web-app" must match "(icon?,display-
name?,description?,distributable?,context-param*,filter*,filter-mapping*,listener*,servlet*,servlet-
mapping*,session-config?,mime-mapping*,welcome-file-list?,error-page*,taglib*,resource-env-
ref*,resource-ref*,security-constraint*,login-config?,security-role*,env-entry*,ejb-ref*,ejb-local-
ref*)".


e.g. you may have


web-app
servlet A
servlet-name
servlet-class
/servlet

servlet-mapping A
servlet-name
url-pattern
/servlet-mapping

servlet B
servlet-name
servlet-class
/servlet

servlet-mapping B
servlet-name
url-pattern
/servlet-mapping

/web-app


The problem is in the order. You can't intermix servlet and servlet-mapping. All the servlets have to come first followed by all the servlet-mappings. So the above would look like:


web-app
servlet A
servlet-name
servlet-class
/servlet

servlet B
servlet-name
servlet-class
/servlet

servlet-mapping A
servlet-name
url-pattern
/servlet-mapping

servlet-mapping B
servlet-name
url-pattern
/servlet-mapping

/web-app


You can check this by : Right click inside the xml window - Validate.

Enjoy!

Tuesday, July 07, 2009

Notepad++ : Error with nppcm.dll

Use this freebie program a lot as a simple text editor on Windows XP. I used the right context click plugin which one day suddenly came up with:

""Error creating process: nppcm.dll needs to be in the same directory than notepad++.exe"

Mr Google to the rescue and found the answer.

There is a file in the root of the hard drive called 'Program' - no extension.

Delete this file and all is sweetness and light!

Enjoy!

Wednesday, June 17, 2009

Eclipse : Preview html / jsp pages

When you view some kinds of files in Eclipse e.g. wsdl files the "wizard" shows you two tabs at the bottom right viz. "Design" and "Source".

This doesn't automatically happen with html or jsp files.

Right-click on the html or jsp file in the "Package Explorer" window and either "Open with - "

"Web Browser" (which just shows you the preview - note the the "Refresh" button at the top) or

"Web Page Editor" (which enables "Design / Preview" tabs). It also splits the screen in half so you can see both at the same time.

Ensure that "Windows / Preferences / General / Web Browser" option is set to "Use internal web browser".

Very neat.

Enjoy!