03 December 2007 - 2.0-beta2 |
Implementing or consuming a Web Service refers to the process of starting with an existing WSDL contract and then creating the java classes that either fulfill or consume this contract. The WSDL can either be remotely available over http or a local file in the current project. In either case, the process consists of 4 steps:
Step 1 and 2 above are the same as described under Consuming Web Services, please refer to that document for these. Be sure to generate the required JAX-RPC mapping file as it is reused in the publish process.
When generating artifacts as described under Consuming Web Services, a java Interface will be generated corresponding to the imported interface. For example when generating for the freely available CurrencyConverter available at http://www.webservicex.net/CurrencyConvertor.asmx?WSDL, the following interface is generated for the services SOAP Binding:
/* * JBossWS WS-Tools Generated Source * * Generation Date: Sat Sep 30 15:27:28 CEST 2006 * * This generated source code represents a derivative work of the input to * the generator that produced it. Consult the input for the copyright and * terms of use that apply to this source code. */ package test; public interface CurrencyConvertorSoap extends java.rmi.Remote { public test.ConversionRateResponse conversionRate( test.ConversionRate conversionRate) throws java.rmi.RemoteException; }
Now implement this interface in a java class:
package test.impl; import java.rmi.RemoteException; import test.ConversionRate; import test.ConversionRateResponse; import test.CurrencyConvertorSoap; public class CurrencyConverterSoapImpl implements CurrencyConvertorSoap { public ConversionRateResponse conversionRate(ConversionRate conversionRate) throws RemoteException { return new ConversionRateResponse(0.0); } }
Once implemented, publish the Web Service as described in the Publish document. Since you have already generated a mapping file during the "consume" process and the WSDL is publically available, you should specify to reuse the created mapping file and uncheck the option to import the WSDL into the JBossWS Project:
If you have the WSDL locally, you can select to use it instead and must also specify the wsdl port to use.