tags:

views:

89

answers:

1

I am stuck trying to figure out how to initiate a WSDL connection with EodData.com

the wsdl address is

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

I am using CXF to create a client connection:

 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");

and I got

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&gt; 

Not sure how I should initiate the connection?

A: 

A quick test using the following code worked for me.

Using WSDL2Java:

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

Then using the code you provided with a few changes:

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());

The response was:

Invalid Username or Password
Garett
@Garett Did you modify the generated java class at all? I didn't know about the -autoNameResolution. My code to connect to eoddata is now in http://github.com/lydonchandra/EodData.git
portoalet
I did not modify the generated class. I used autoNameResolution to resolve naming conflicts then I changed the code you provided to use the soap transport as opposed to REST/HTTP. It seems for REST to work you would have needed to make modifications to the generated class.
Garett