Hi All,
I am trying to access data on
http://www.webserviceX.NET/stockquote.asmx?WSDL using an Axis client.
the proble is that the message/xml/rpc(?) my requests send to the network is not what the webservice expects.
The website wants (discovered with StrikeIron Analyzer and WireShark)
***********************
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:enc="http://schemas.xmlsoap.org/soap/encoding">
<soap:Body>
<tns:GetQuote
xmlns:tns="http://www.webserviceX.NET/">
<tns:symbol>
GOOG
</tns:symbol>
</tns:GetQuote>
</soap:Body>
</soap:Envelope>
***********************
and my Axis Client sends
***********************
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<GetQuote
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<symbol
xsi:type="xsd:string">
GOOG
</symbol>
</GetQuote>
</soapenv:Body>
</soapenv:Envelope>
***********************
I cannot figure out what parameter I should change in my code so that my request is sent properly.
Here is the code:
##################code start####################
logDebug("Debut Fonction");
String wsdlLoc ="http://www.webservicex.net/stockquote.asmx?WSDL";
String endpoint="http://www.webservicex.net/stockquote.asmx";
String namespace="http://www.webserviceX.NET/";//dontchange
String serviceName="StockQuote";
String symbol2="GOOG";
logDebug("Param Fonction OK");
QName serviceQName= new QName(namespace,serviceName);
QName portQName= new QName(namespace,"StockQuote");
QName operationQName= new QName(namespace,"http://www.webserviceX.NET/GetQuote");
logDebug("Before Try : ");
try {
logDebug("B4 Service ");
// Service service = new Service(wsdlLoc, serviceQName);
//****************
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress( new java.net.URL(endpoint) );
call.setEncodingStyle("http://schemas.xmlsoap.org/soap/encoding/");
call.setTimeout(30000);
call.setSOAPActionURI("http://www.webserviceX.NET/GetQuote");
call.setUseSOAPAction(true);
call.setOperationUse("literal");
call.setOperationName("GetQuote");
call.setOperationStyle("rpc");
//call.addParameter(new javax.xml.namespace.QName("http://tempuri.org/upload/", "symbol"), new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, javax.xml.rpc.ParameterMode.IN);
call.addParameter("symbol",XMLType.XSD_STRING,Para meterMode.IN);
call.addParameter("GetQuoteResult", XMLType.XSD_STRING,ParameterMode.OUT);
String quote = (String) call.invoke("GetQuote",new Object[] {symbol2});
// String quote = (String) call.invoke("getVersion", new Object[] {new String("IBM")});
//String quote= (String) call.invoke(symbol);
logDebug("Call QuoteOK ");
logDebug("Quote==>>"+ quote.substring(0,5));
/*
logDebug("B4 Call ");
Call call = (Call) service.createCall();
call.setPortTypeName(portQName);
call.setTargetEndpointAddress(endpoint);
logDebug("B4 setOperation ");
call.setOperationName(operationQName);
logDebug("B4 quote=call.invoke ");
String quote= (String) call.invoke(new Object[] {symbol});*/
return quote;
} catch(Exception ex) {
logError("Error getting quote",ex);
}
return "error";
################################################## #
This code connects to the remote web server, send the request, but because of the wrong markups, thinks the input stock symbol (GOOG) is null and return a value = "exception" instead of xml answer.
If somebody has some tips on what parameter to change in my code, that would be fabulous !!
Cheers
Seb