0

I am using Webservice to do currency conversion. I have used already available WSDL "http://www.webservicex.net/CurrencyConvertor.asmx?WSDL". Using the above WSDL i have generated web service client. Using that webservice client i am doing currencyconversion. But when i am running my webservice, it is giving me InvocationTargetException. Below is the exception stack trace i am getting.

Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:56)
Caused by: (404)Not Found
at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:744)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at NET.webserviceX.www.CurrencyConvertorSoapStub.conversionRate(CurrencyConvertorSoapStub.java:13)
at CurrenyConversionRateValue.main(CurrenyConversionRateValue.java:19)
... 5 more 

Can anyone please help me to resolve this issue.

Below is the code snippet of CurrencyConvertorSoapStub where i am getting exception.

    public double conversionRate(NET.webserviceX.www.Currency fromCurrency, NET.webserviceX.www.Currency toCurrency) throws java.rmi.RemoteException
     {
            if (super.cachedEndpoint == null)
            {
                throw new org.apache.axis.NoEndPointException();
            }
            org.apache.axis.client.Call _call = createCall();
            _call.setOperation(_operations[0]);
            _call.setUseSOAPAction(true);
            _call.setSOAPActionURI("http://www.webserviceX.NET/ConversionRate");
            _call.setEncodingStyle(null);
            _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);
            _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
            _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
            _call.setOperationName(new javax.xml.namespace.QName("http://www.webserviceX.NET/", "ConversionRate"));

            setRequestHeaders(_call);
            setAttachments(_call);
     try {       
     java.lang.Object _resp = _call.invoke(new java.lang.Object[] {fromCurrency, toCurrency});

            if (_resp instanceof java.rmi.RemoteException) {
                throw (java.rmi.RemoteException)_resp;
            }
            else {
                extractAttachments(_call);
                try {
                    return ((java.lang.Double) _resp).doubleValue();
                } catch (java.lang.Exception _exception) {
                    return ((java.lang.Double) org.apache.axis.utils.JavaUtils.convert(_resp, double.class)).doubleValue();
                }
            }
      } catch (org.apache.axis.AxisFault axisFaultException) {
      throw axisFaultException;
    }
        }

    }

Can anyone please help me to resolve this exception and to get my webservice work.
1
  • InvocationTargetException ususally comes when client cannot reach server .Network related issue. Commented Sep 19, 2013 at 5:36

4 Answers 4

1

The above exception got solved.It occured as there is a firewall configuration blocking of CurrencyConversion webservice client. It worked fine after removing the firewall configuration. Thanks for your answers.

Sign up to request clarification or add additional context in comments.

Comments

0

i am new to webservice but isee when you configure your client you specify a service name defferent from your wsdl name

_call.setOperationName(new javax.xml.namespace.QName("http://www.webserviceX.NET/","ConversionRate")); 

i think i should be like what you mapped in your wsdl file

2 Comments

Thanks for reply user2269148.I am also new to webservice. I didnt specify service name manually.I just generated java webservice client from above mentioned WSDL and i used it for currencyconversion. It worked fine in my local. But when i hit the same webservice in another system which has tomcat server it giving me above error. I need to make it work. Can anyone please help me to resolve this issue. Do i need to do any configuration changes like any ports got blocked to hit my webservice?please help me.
Can anyone Please help me.It is important.
0

i also got this same exception that is invocation target exception,this exception will come when more time taking process is there in your application,why because webservices are implemented by threads,to solve this on start up only you have to load all the files,means on start up of tomcat we can load all the files.

Comments

0

This exception occurs when you can not access the WebServices ie the URL is not available (blocking FW, misconfiguration, etc.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.