Thanks Deepal - that helped to some extent. But after adding the operation qname in sendreceive call, I got "Server did not recognize the value of HTTP Header SOAPAction: .". So I had to set the options object into the ServiceClient - which was strange since from your doc at http://today.java.net/pub/a/today/2006/12/13/invoking-web-services-using-apache-axis2.html it seemed to me that if I call ServiceClient as new ServiceClient(null, new URL(wsdlURL),serviceName,portName) then I do not need to set the options.
I am attaching the code with the options setting logic commented - why does it not work? Thanks, Vish. >-----Original Message----- >From: Deepal jayasinghe [mailto:[EMAIL PROTECTED] >Sent: Sunday, January 20, 2008 11:58 PM >To: [email protected] >Subject: Re: [Axis2] Axis2 client code with ServiceClient created as >dynamic client gives AxisFault: The anonOutInOp operation cannot be found > >Hi , >If you create serviceClient as dynamic client then you need to give the >correct operation name (qualified operation name). I hope following link >will helpful for you to solve your problem > >http://people.apache.org/~deepal/colorado/quick- >start/src/DynamicClientSample.java > >-Deepal > > >> Using Axis2 1.3, I have written the following sample client code that >> calls a remote webservice for currency conversion - it throws the >> exception: >> >> >> >> AxisFault: The anonOutInOp operation cannot be found. >> >> at >> >org.apache.axis2.client.ServiceClient.createClient(ServiceClient.java:642) >> >> at >> org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:526) >> >> at >> org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:508) >> >> >> >> /* 1 */ ServiceClient svcClient = new ServiceClient(null, new >> URL("http://www.webserviceX.net/CurrencyConvertor.asmx?wsdl"), >> >> new QName("http://www.webserviceX.NET/","CurrencyConvertor"), >> "CurrencyConvertorSoap";); >> >> >> >> OMFactory fac = OMAbstractFactory.getOMFactory(); >> >> OMNamespace ns = fac.createOMNamespace("http://www.webserviceX.NET/", >> "ns1"); >> >> OMElement payload = fac.createOMElement("ConversionRate", ns); >> >> >> >> OMElement fromValue = fac.createOMElement("FromCurrency", ns); >> >> fromValue.setText("USD"); >> >> payload.addChild(fromValue); >> >> >> >> OMElement toValue = fac.createOMElement("ToCurrency", ns); >> >> toValue.setText("INR"); >> >> payload.addChild(toValue); >> >> >> >> OMElement responseElem=svcClient.sendReceive(payload); >> >> >> >> The client works when I replace the dynamic service client creation by >> a normal creation (new ServiceClient()) without any args and set >> Options object into it i.e. replacing line marked /* 1 */ above with >> the following works: >> >> >> >> svcClient = new ServiceClient(); >> >> Options opts = new Options(); >> >> opts.setTo(new >> EndpointReference("http://www.webserviceX.net/CurrencyConvertor.asmx")); >> >> opts.setAction("http://www.webserviceX.NET/ConversionRate"); >> >> svcClient.setOptions(opts); >> >> >> >> The first code worked in Axis1. Is something wrong in it or will it >> not work due to changes in Axis2? >> >> >> > > >--------------------------------------------------------------------- >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]
