File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Services Certification (SCDJWS/OCEJWSD) and the fly likes creating web service client Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Services Certification (SCDJWS/OCEJWSD)
Bookmark "creating web service client" Watch "creating web service client" New topic

creating web service client

Abayomi Osamiluyi

Joined: Mar 22, 2011
Posts: 2
am finding it difficult to create a client for a web service created in coldfusion. I know the language in which the web service was implemented doesnt really matter.

Can anyone please show me the steps of creating the client from how to generate the artifacts using wsimport to using the artifacts to communicate with the service.

Thank you in anticipation.....
Bob Nedwor
Ranch Hand

Joined: Aug 17, 2005
Posts: 215


There are quite a few different ways to do this. Please check out the "wsimport" options. As long as you have your Java 1.6 $JAVA_HOME/bin in your $PATH environment variable, just type
"wsimport" from your command prompt (I think it is %JAVA_HOME%\bin in your %PATH% in Windows). If you do not have JDK 1.6, then wsimport should be in the bin directory in your jaxws-ri or glassfish3/glassfish directory, depending on how you are learning java web services.

If the cold fusion service that you are talking about is up and running and working as a real SOAP Web Service, then there should be a navigable WSDL you can see in your browser somehow ( http://localhost:8080/mycoldfusionservice?wsdl or something like that) that describes the operations, ports, messages, etc., of your service.

Once you know what it is, just create two folders, "src" and "bin", then say:
wsimport -keep -s src -d bin http://localhost:8080/mycoldfusionservice?wsdl (you might need to try this a few times using the -p option with the right package name before you actually get what you need).

Once this works, you have nearly everything you need for your client, but your class with the main method. You have to build that yourself, using a few lines of code that create an instance of the generated ?* class that wsimport gave you, then call its "get?Port()" method. See for an example of how to do this.

I hope this helps.

Bob N
SCJP - 1.4
SCJD - (B&S) Used 1.5 And It Runs On Solaris10
SCWCD - Thanks to HFSJ!!
Rick Roberts
Ranch Hand

Joined: Apr 07, 2005
Posts: 59

Coldfusion does it all for you.
All you need is something like:

Then just call your method with something like:
myResponse = myWS.someMethod(someRequestObject)

That's it.

The only tricky part is:
You need to make sure that you populate your request object "exactly" as described in the WSDL.
Or else you will get an error that says your method signature does not match.

The response object is automagically created for you by CF.

Coldfusion also has another way to create a webservice client also by using the <cfinvoke> tag.
Google it, but it goes something like:

Some other stuff that may be helpful:
CF7 uses Apache Axis-1.
CF8 & 9 use Apache Axis-2.

Just Google something like:

There are tons of examples.

Good Luck.

"Stay on the path."
Rick Roberts
Ranch Hand

Joined: Apr 07, 2005
Posts: 59

O.K. I just re-read your question.
Now I interpret it to mean that you are trying to consume a Coldfusion Web Service.
My post was all about how to consume one using a Coldfusion client.

Give me a bit to collect my thoughts and I will follow up with some "Java client" related ramblings.

Rick Roberts
Ranch Hand

Joined: Apr 07, 2005
Posts: 59

Alright. Don't hate on me if this is not perfect. Wife has me Bar-B-Que'ing, so in a rush.

Assuming these 2 Interfaces, 1 Local and 1 Remote:

Also assuming this webservice:

This client code should work:

You may also need a file that has a line something like:

Google it for details.

This may not be exactly complete, but it should get you on the right path.

Bar-B-Que is calling.
Good Luck.
I agree. Here's the link:
subject: creating web service client
It's not a secret anymore!