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.
4

4 回答 4

1

上述异常得到解决。它发生是因为 CurrencyConversion Web 服务客户端的防火墙配置阻止。删除防火墙配置后它工作正常。感谢您的回答。

于 2013-12-13T13:53:41.050 回答
0

我是 webservice 的新手,但是 isee 在您配置客户端时指定了一个与您的 wsdl 名称不同的服务名称

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

我想我应该像你在 wsdl 文件中映射的那样

于 2013-09-19T06:28:50.097 回答
0

我也遇到了同样的异常,即调用目标异常,当您的应用程序中有更多时间占用进程时,此异常会出现,为什么因为 web 服务是由线程实现的,要在启动时解决这个问题,只需加载所有文件,意味着在启动tomcat时我们可以加载所有文件。

于 2013-11-20T14:14:31.680 回答
0

当您无法访问 WebServices 即 URL 不可用(阻止 FW、错误配置等)时会发生此异常。

于 2014-02-26T13:51:02.607 回答