1

我正在尝试从公共 Web 服务创建一个测试客户端: http ://www.webservicex.com/currencyconvertor.asmx?WSDL

使用 Eclipse 和 CXF 2.x 来自动生成 WS 客户端。到目前为止看起来不错,但在执行时我只收到以下错误。我发生了我调用 webservice 方法conversionRate,它也是自动生成的,如下所示:

@WebService(targetNamespace = "http://www.webserviceX.NET/", name = "CurrencyConvertorSoap")
@XmlSeeAlso({ObjectFactory.class})
public interface CurrencyConvertorSoap {

    @WebResult(name = "ConversionRateResult", targetNamespace = "http://www.webserviceX.NET/")
    @RequestWrapper(localName = "ConversionRate", targetNamespace = "http://www.webserviceX.NET/", className = "ConversionRate")
    @WebMethod(operationName = "ConversionRate", action = "http://www.webserviceX.NET/ConversionRate")
    @ResponseWrapper(localName = "ConversionRateResponse", targetNamespace = "http://www.webserviceX.NET/", className = "ConversionRateResponse")
    public double conversionRate(
        @WebParam(name = "FromCurrency", targetNamespace = "http://www.webserviceX.NET/")
        Currency fromCurrency,
        @WebParam(name = "ToCurrency", targetNamespace = "http://www.webserviceX.NET/")
        Currency toCurrency
    );
}

我怎样才能找出错误来自哪里?这里可能有什么问题?

错误:

Warnung: Interceptor for {http://www.webserviceX.NET/}CurrencyConvertor#{http://www.webserviceX.NET/}ConversionRate has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Unmarshalling Error: unerwartetes Element (URI:"http://www.webserviceX.NET/", lokal:"ConversionRateResult"). Erwartete Elemente sind <{}ConversionRateResult> 
    at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:808)
    at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:629)
    at org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:157)
    at org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:103)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
    at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:800)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1592)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1490)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1309)
    at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
    at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:622)
    at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
    at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:530)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:463)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:366)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:319)
    at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
    at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:133)
    at $Proxy35.conversionRate(Unknown Source)
    at CurrencyConvertorSoap_CurrencyConvertorSoap_Client.main(CurrencyConvertorSoap_CurrencyConvertorSoap_Client.java:50)
4

1 回答 1

1

解决方案是不要删除自动生成的package-info.java. 通常,在创建普通 Java 项目时,可以节省地删除此工件。但在 web 服务的情况下,它包含强制性定义。

于 2013-07-11T12:37:51.610 回答