EodData wsdl java连接

时间:2010-07-19 17:04:44

标签: java wsdl cxf

我一直试图弄清楚如何使用EodData.com启动WSDL连接

wsdl地址是

http://ws.eoddata.com/data.asmx?wsdl

我使用CXF创建客户端连接:

 QName qname = new QName("http://ws.eoddata.com/Data", "Data");
 Data data = new Data(new URL("http://ws.eoddata.com/data.asmx?wsdl"), qname);
 DataHttpGet dataGet =  data.getDataHttpGet();
 dataGet.login("xxx", "ppp");

我得到了

Caused by: org.apache.cxf.interceptor.Fault: Unmarshalling Error: unexpected element (uri:"http://schemas.xmlsoap.org/soap/envelope/", local:"Header"). Expected elements are <{http://ws.eoddata.com/Data}LoginResult> 

不确定我应该如何启动连接?

1 个答案:

答案 0 :(得分:1)

使用以下代码进行快速测试对我有用。

使用WSDL2Java:

wsdl2java -autoNameResolution http://ws.eoddata.com/data.asmx?wsdl

然后使用您提供的代码进行一些更改:

QName qname = new QName("http://ws.eoddata.com/Data", "Data"); 
Data data = new Data(new URL("http://ws.eoddata.com/data.asmx?wsdl"), qname); 
DataSoap dataSoap = data.getDataSoap();
LOGINRESPONSE response = dataSoap.login("xxx", "ppp");

System.out.println(response.getMessage());

回应是:

Invalid Username or Password