Meaningless Drivel is fun!*
The moose likes Web Services and the fly likes Calling a ColdFusion Web Service method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Calling a ColdFusion Web Service method" Watch "Calling a ColdFusion Web Service method" New topic
Author

Calling a ColdFusion Web Service method

Eugene Abarquez
Ranch Hand

Joined: May 18, 2006
Posts: 211
Hi All,

I am new to Web Services and I am developing an application that calls an external web service method to carry out its operation.

Here are the details of what I am trying to achieve. I am creating a simple order form in JSF. When the user clicks the order button from this form, two methods will be called from the web service. One is to create a user and the other to carry out the order. The web service is already available, so I don't have to worry about that, all I need to do is just call the web service methods but I don't know how to do this exactly. Also I need to generate an XML string from the form which conforms to a certain XML schema, which again, I don't have any idea on how to do.

Can somebody please help me out or point me to useful resources to get me started on this. I am a newbie so go easy on the jargons.

Thanks in advance.


There's so much to learn in this industry, and not everybody has the necessary interest.
Eugene Abarquez
Ranch Hand

Joined: May 18, 2006
Posts: 211
Anyone?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42277
    
  64
The easiest way to create Java client code for a web service would be if the WS has a WSDL available (that's jargon, I know), because there are tools that can generate access code for a WS described by a WSDL. Maybe you can ask the people who set up the WS if there is one.

For learning WS, there are a number of resources linked from our Web Services FAQ.


Ping & DNS - my free Android networking tools app
Eugene Abarquez
Ranch Hand

Joined: May 18, 2006
Posts: 211
Thanks Ulf for the reply.

Yes, there is a WSDL document available. Can you give me examples of the tools that can generate access code from a WSDL? Also, I will need to generate an XML document to pass as a parameter to the web service method. What's the best tool that you can suggest to carry out this operation. I've read about DOM, SAX and JDOM. Which do you recommend?
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
Originally posted by Eugene Abarquez:
Can you give me examples of the tools that can generate access code from a WSDL?


Have a look at 3. WSDL2Java: Generate the Server-side Wrapper Code and Stubs For Easy Client Access from Creating Web Services with Apache Axis. You may actually want to try the whole thing - it will probably give you a much better feeling how things fit together.

Originally posted by Eugene Abarquez:
Also, I will need to generate an XML document to pass as a parameter to the web service method. What's the best tool that you can suggest to carry out this operation. I've read about DOM, SAX and JDOM. Which do you recommend?


Depending on the web service specification you may not have to - WSDL2Java will do most of the work for you. If however you do get handed an XML document in a string then have a look at JAXB 2.0 or JAXB 1.0.
Java Architecture for XML Binding (JAXB)
JAXB 2.0 Tutorial
Eugene Abarquez
Ranch Hand

Joined: May 18, 2006
Posts: 211
Thanks Peer! I will look into it.

Does this work with Cold Fusion too? The web service that I will access is Cold Fusion, and I am using JBoss as an application server.

Also, I think I will have to generate an XML document. I have an XML schema of which I will generate an XML from. I've read JDOM is a good option. Is it? Or will I be better off using JAXB?
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
Originally posted by Eugene Abarquez:
Does this work with Cold Fusion too?


In principle it should, however it depends on which specifications the web service complies with. In general web services are nothing more that XML transmitted via HTTP - SOAP web services also use the SOAP which itself is XML-based. Problems usually arise when the service uses some encoding-scheme that cannot be expressed in terms of XML Schema, i.e. some additional information is needed on top of the XSDs and WSDL in order to make sense of the data. Another source of problems is when a web service tries to force programming-language specific constructs into the data - constructs that may not necessarily have an equivalent in the client's programming language. As long as everybody treats it simply as an exchange of XML documents everything should be fine.

Originally posted by Eugene Abarquez:
I've read JDOM is a good option. Is it? Or will I be better off using JAXB?

Whatever you can justify.

JDOM is a java-fied version of DOM and you have to write the code to build and read the XML documents. JDOM is supposed to be easier to use than DOM but will never be part of core Java.

JAXB generates the marshalling and de-marshalling code for you based on the XML schema that you supply. You can further influence the code generation through configuration files. JAXB 2.0 will be part of core Java starting with version 6. The current reference implementation works with version 5. JAXB 1.0 works with version Java version 1.4 and the necessary jars of the reference implementation can be extracted from any JWSDP 1.x (jaxb-api, jaxb-impl, jaxb-libs, jaxb-xjc, relaxngDatatype, xsdlib).

But then again you may not need to work with the XML directly.
JBoss WS module seems to be based on Apache Axis:
JBoss: J2EE Web Services
JBossWS
Eugene Abarquez
Ranch Hand

Joined: May 18, 2006
Posts: 211
Thanks Peer for the detailed explanation. I think the links that you provided are enough to get me started on this. Thanks again and to Ulf too.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Calling a ColdFusion Web Service method