Hi Rajesh, There are three ways to invoke a web service. Using a static client, using a proxy or complete dynamic invocation.
It's not really clear to me whether you want to generate the SOAP message given "the wsdl" or "the uri of the wsdl." Of course if you have the wsdl beforehand you can run it through wsdl2java and generate stubs and skeletons. If you only have "uri of the wsdl", you can use either "a proxy" or "complete dynamic invocation." Sample code for proxy is as below. What proxy does is given the uri of the wsdl it fetches the wsdl and create the service for you. I just cut and copied the sample from a mail sent to me by Anne Thomas Manes. Code for complete dynamic invocation is at samples.client.DynamicInvoker.java package test.axis.wrapped.client; > > > >>>>>> > > > >>>>>>import javax.xml.namespace.QName; > > > >>>>>>import javax.xml.rpc.Service; > > > >>>>>>import javax.xml.rpc.ServiceFactory; > > > >>>>>>import java.net.URL; > > > >>>>>>import test.axis.wrapped.iface; > > > >>>>>> > > > >>>>>>public class AxisWrappedClient > > > >>>>>>{ > > > >>>>>> public static void main(String[]args) throws Exception { > > > >>>>>> String UrlString = "wsdl-url"; > > > >>>>>> String nameSpaceUri = "urn:axis.wrapped" > > > >>>>>> String serviceName = "WrappedService"; > > > >>>>>> String portName = "WrappedServicePort"; > > > >>>>>> > > > >>>>>> URL currWsdlUrl = new URL(UrlString); > > > >>>>>> ServiceFactory serviceFactory = > > > >> > > > >>ServiceFactory.newInstance(); > > > >> > > > >>>>>> Service currService = > > > >>> > > > >>>serviceFactory.createService(currWsdlUrl, > > > >>> > > > >>> > > > >>>>>> new QName(nameSpaceUri, serviceName)); > > > >>>>>> > > > >>>>>> Curr myProxy = (Curr) currService.getPort( > > > >>>>>> new QName(nameSpaceUri, portName), > > > >>>>>> test.axis.wrapped.iface.class); > > > >>>>>> > > > >>>>>> string return = myProxy.methodName( arg[0], arg[1] ); > > > >>>>>> > > > >>>>>> } > > > >>>>>>} Good luck. Regards, Dimuthu. -- Lanka Software Foundation http://www.opensource.lk > Hi folks, > > I'd like to be able to get a sample of what > should be provided to a document/literal > web service that I want Apache Axis to invoke > as a client. > > For example, given the WSDL located at: > http://www.webservicex.net/stockquote.asmx?WSDL, > I'd like to be able to generate the following: > > POST /stockquote.asmx HTTP/1.1 > Host: www.webservicex.net > Content-Type: text/xml; charset=utf-8 > Content-Length: length > SOAPAction: "http://www.webserviceX.NET/GetQuote" > > <?xml version="1.0" encoding="utf-8"?> > <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xmlns:xsd="http://www.w3.org/2001/XMLSchema" > xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> > <soap:Body> > <GetQuote xmlns="http://www.webserviceX.NET/"> > <symbol>string</symbol> > </GetQuote> > </soap:Body> > > Regards, > Rajesh > > > Regards, > Rajesh