jQuery in Action, 2nd edition*
The moose likes Web Services and the fly likes Best practices regarding client code generation to a third party webservice and deployment issues Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Best practices regarding client code generation to a third party webservice and deployment issues" Watch "Best practices regarding client code generation to a third party webservice and deployment issues" New topic
Author

Best practices regarding client code generation to a third party webservice and deployment issues

Uffe Roenne
Greenhorn

Joined: May 18, 2009
Posts: 6
Hi all

Hope you can help me this.

We are developing a solution to a client which is going to be deployed in JBoss 4.2.2 on Java6. The solution has to deliver certain messages to the clients legacy systems by invoking a webservice. So far all I have got from them are the wsdl and some xsd.

So far I have created a project which is going to host the webservice locally. Just a dummy one returning dummy data. I used the wsimport tool to generate the java code for me server side. All I did was to write an implementation class. All that works fine and is deployed to JBoss.

My struggle is the client side. When I use the wsimport tool and point to a local wsdl file (c:\projects.......Service.wsdl), the generated code has a lot of references to this file (c:\projects.......Service.wsdl). When I run a test it fails because it points to some local file system stuff and not the one deployed in JBoss.

I could of course point to the wsdl deployed in JBoss (http://localhost:8080......Service?wsdl) when I run wsimport but that only helps me when I run the stuff locally. What to do when you deploy it to the client? Then the hostname will change for sure.

What is recommended way of handling this. Should you run wsimport with the clients hostname and wsdl path?

Regards

Uffe
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Yes, either you run wsimport using the URL of the deployed web service. However, you may still have problems if you move the service, in which case you will have to regenerate or edit the generated artifacts.
Another solution is to use the Oasis XML Catalog facility that is mandated by the JAX-WS specification. See section 4.4 in the JAX-WS 2.1 specification document.
This way you can map the URIs of your WSDL(s) and XML schema(s) and if you change the location of the service, you do not have to regenerate artifacts but only edit the catalog file.
Best wishes!
Uffe Roenne
Greenhorn

Joined: May 18, 2009
Posts: 6
Hi Ivan

Thanks a lot for your answer. I'm still a bit confused though. I read the specification and I don't think I understand it. Can you perhaps explain it in more detail or post a link with an example regarding the Oasis catalog. Haven't been able to find that much on the topic.

So far though I have managed to solve my problem by using a BindingProvider

String endpointURL = "configurable path to webservice";
BindingProvider bp = (BindingProvider)client;
bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointURL);

I pass on the "wsdlLocation" parameter to wsimport pointing to the wsdl which I ship in the jar (wsdlLocation="xsd/webservice.wsdl"). notice the relative path. Of course, this is only possible if you have a copy of the wsdl.

I'm still very interested in learning more about the Oasis XML Catalog so I hope you can fill me in.

Regards

Uffe
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
I have wanted to write up an example myself for some time now, but so far, I haven't had time
I guess you already found some webpages yourself - this was the best one I could find doing a quick search:
http://xerces.apache.org/xerces2-j/faq-xcatalogs.html
I'll get back if I run into something useful for you.
Best wishes!
Uffe Roenne
Greenhorn

Joined: May 18, 2009
Posts: 6
Hi Ivan

Thanks a lot for your help :-)

Best regards

Uffe
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Some additional scraps of info on the subject:
Nice introductory article on XML Catalog:
http://norman.walsh.name/2003/06/05/xmlcatalogs

Here is an article that talks about how to use the XML Catalog facility to improve performance of your own program.
http://norman.walsh.name/2007/09/07/treadLightly

Note that, according to section 4.4 of the JAX-WS 2.1 specification, this mechanism is already implemented in JAX-WS so you only need to supply an XML Catalog file in order to use this mechanism.
Best wishes!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Best practices regarding client code generation to a third party webservice and deployment issues
 
Similar Threads
SSLHandshakeException
JAX-RPC client side programming
NetBeans Web Service client attempt
WSDL Reference in generated Client Stub.
Jboss 5.0 throwing “Endpoint does not contain operation meta data for http://services.upc.tecno.com