java - 在 webservice 中获取 java.lang.reflect.InitationTargetException

标签 java web-services wsdl

我正在使用 Webservice 进行货币转换。我已经使用了已经可用的 WSDL“http://www.webservicex.net/CurrencyConvertor.asmx?WSDL”。使用上面的 WSDL 我生成了 Web 服务客户端。我正在使用该网络服务客户端进行货币转换。但是当我运行我的网络服务时,它给了我 InvocabularyTargetException 。下面是我得到的异常堆栈跟踪。

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.

最佳答案

上述异常已解决。出现此问题是因为防火墙配置阻止了CurrencyConversion Web服务客户端。删除防火墙配置后,它工作正常。感谢您的回答。

关于java - 在 webservice 中获取 java.lang.reflect.InitationTargetException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18886822/

相关文章:

java - Java 中的 Nasa 二进制文件

java - 在 Struts2 操作中通过 @OneToMany 关系映射两个实体失败

jquery - 防止直接访问 JSON Web 服务

java - 是否可以调用服务而不将其包装在转换中?有人用Java成功实现过吗?

delphi - THttprio onBeforeExecute 更改soapRequest

c# - C# 中 ClientCredentials 的 Java 对应项?

Java所有确定元素在列表中都相同

java - 主工具栏未显示在 Eclipse RCP 应用程序中

java - 使用 AXIS1 的自上而下的 Web 服务生成将我的 complexType 分开

asp.net - 如何在工作流程的不同 git 分支中保留不同版本的 WSDL