Before going thru my solution of your requirement, I would suggest you to go thru a couple of approaces:
(1) Using Dynamic Proxy to generate client. I found something useful here<http://jaitechwriteups.blogspot.com/2007/04/webservice-client-using-dynamic-proxy.html>. (2) Its also worth looking at WSIF <http://ws.apache.org/wsif/>. --- --- --- Coming to your issue, I too had to make a web-service consumer that would consume many webservices. Here's how I did it: I am using Maven2 for managing my project. - I generate web-service stubs in a sub-project, & package them in a jar file. Here<http://javarushi.blogspot.com/2008/04/running-axis-wsdl2java-from-within.html>is the pom.xml for this sub-project. I am showing the ant tasks for doing it here. <property name="legacyService.wsdl" value="src/main/resources/ref-wsdl/legacy.wsdl"/> <property name="newOne.wsdl" value="http://your.host/service.wsdl"/> <property name="generated.dir" value="src/main/java"/> <axis-wsdl2java output="${generated.dir}" verbose="true" url="${legacyService.wsdl}" > <mapping namespace="urn:ServiceNameSpace" package="com.rst.webservice.legacy.client.axis14.util" /> </axis-wsdl2java> <axis-wsdl2java output="${generated.dir}" verbose="true" url="${newOne.wsdl}" > <mapping namespace="http://webservice.rst.com" package="com.rst.webservice.newone.client.axis14.util" /> </axis-wsdl2java> I found this a neat approach for working with many WSDL's (i.e. WebServices). - I added dependency to this jar in my WebService-Consumer sub-project. --- --- --- I hope this helps. -Rushikesh On Tue, May 20, 2008 at 5:58 PM, <[EMAIL PROTECTED]> wrote: > Hi Paul, > > I have used the XMLBeans binding with Axis2 to generate client stubs. I > have a number of potential end-points too, and I instantiate one > 'Service' object (from the generated code) for each one. I pass the > Service object with the end-point I'm interested in to my framework/code > doing the actual call on this stub. > > So far I have avoided touching the generated code at all so as to > minimize the coupling. I package the generated code in one archive, and > my framework in another to allow me to regenerate the stub as needed. I > user Spring to hook up the necessary resources. > > As for package naming, use the -ns2p option in wsdl2java: > > -ns2p ns1=pkg1,ns2=pkg2 Specify a custom package name for each > namespace specified in the wsdls schema. > > > Hope this helps! > > Martin > > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > Sent: Tuesday, May 20, 2008 7:42 AM > To: [email protected] > Subject: Generating generic stubs > > Hi, > > We have provided an api that people wishing to interface with our system > must code to. This ensures that any users will provide the same objects > and the same service name that we will call. > > What we would like to do is to create a set of generic stubs that we can > use to make a call to any provider, by looking up the end point in the > database for a particular system. So far I have in part achieved this by > calling > getService() and passing in an endpoint URL. > > When I look at the code generated with wsdl2java it is not completely > generic though, I have overridden the package structure to look like > 'stub.generic.ltc' but the namespaces in the generated classes still map > to the packages defined by the provider (I guess this is due to the WSDL > namespaces). > > Has anybody done this sort of thing before? Is it possible? Am I > approaching this in the right way if it is possible? And should I be > editing the generated code to remove any namespaces? > > Ideally the situation we would like to end up with is one set of stubs > generated and placed into a jar file, with the endpoint switched at > runtime to point to a particular provider, we would only ever use one > wsdl to generate the stubs and all new providers that would like us to > call this service would only need to provide us with an endpoint. > > Thanks, > > Paul Ockleford > > > ********************************************************************** > This message may contain confidential and privileged information. > If you are not the intended recipient please accept our apologies. > Please do not disclose, copy or distribute information in this e-mail > or take any action in reliance on its contents: to do so is strictly > prohibited and may be unlawful. Please inform us that this message has > gone astray before deleting it. Thank you for your co-operation. > > NHSmail is used daily by over 100,000 staff in the NHS. Over a million > messages are sent every day by the system. To find out why more and > more NHS personnel are switching to this NHS Connecting for Health > system please visit www.connectingforhealth.nhs.uk/nhsmail > ********************************************************************** > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- -Rushikesh
