I'm working with an old-fashioned designed WebService using RPC encoded.
My problem seems to be linked to XML types.
A method in WSDL :
<message name="WsPublic_DHT_GetData1Request">
<part name="ALogin" type="xs:string" />
<part name="Aid" type="xs:int" />
<part name="ARow" type="xs:int" />
<part name="ADt" type="xs:dateTime" />
<part name="ADt2" type="xs:dateTime" />
<part name="Afilter" type="xs:string" />
</message>
As you can see, it's using xs:types.
Now let's take a look at how I invoke it on my Java client :
Object[] argmts = {"USER=PASSWORD", 15089, 10, "2012-02-16 00:00", "2012-02-16 20:01", ""};
Object lsVal = call.invoke(argmts);
Alogin consist on Login + password separated by a '='. I already tested this Webservice with a vbs Script and it works.
The problem is that on execution, the webservice keeps returning me : lsVal = Error_login
The credential I use are fine so I bet it is a bad conversion beetween java's String to xs:string. I tried to define call's parameters manually but I only found XSD type, and it returned the same Error_login answer. I'm wondering if I didn't miss something. Can someone explain me ?
Here is the full .java
package com.verallia.testapp;
import javax.xml.namespace.QName;
import javax.xml.rpc.Call;
import javax.xml.rpc.Service;
import javax.xml.rpc.ServiceFactory;
import javax.xml.rpc.encoding.XMLType;
public class JavaApplication1 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
try {
// create the Service client object
// using the wsdl and his service name
QName serviceName = new QName(
"IWS_VMS_PUBLIC_DHTservice",
"VisualManagerWS");
ServiceFactory factory = ServiceFactory.newInstance();
Service service = factory.createService(serviceName);
// Call object
Call call = service.createCall();
// operation name
QName operationName = new QName(
"http://10.153.14.29:1024/wsdl/IWS_VMS_PUBLIC_DHT", "WsPublic_DHT_GetData");
call.setOperationName(operationName);
QName portName = new QName(
"IWS_VMS_PUBLIC_DHTPort","IWS_VMS_PUBLIC_DHTPort");
call.setPortTypeName(portName);
// setting return type
call.setReturnType(XMLType.XSD_STRING, String.class);
// specify the RPC-style operation.
call.setProperty(Call.OPERATION_STYLE_PROPERTY,
"rpc");
// and the encoding style
call.setProperty(
Call.ENCODINGSTYLE_URI_PROPERTY,
"http://schemas.xmlsoap.org/soap/encoding/");
// the target endpoint
call.setTargetEndpointAddress(
"http://10.153.14.29:1024/soap/IWS_VMS_PUBLIC_DHT");
//call.
// Invoke the method
Object[] myArgs = {"WS_TALEND=TALEND", 15089, 10, "2012-02-16 00:00", "2012-02-16 20:01", ""};
for (Object o : myArgs)
{
System.out.println(o.toString());
}
Object lsVal = call.invoke(myArgs);
System.out.println("Returned XML String : " + lsVal.toString());
} catch (Throwable th) {
th.printStackTrace();
}
}
}
Are u tokennizing the Alogin value in the server side to get the username and password? If it so,then it is fine. One more thing you can specify the input parameter types in the following manner in ur client code.
call.addParameter("arg0",XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter("arg1",XMLType.XSD_INT, ParameterMode.IN);
call.addParameter("arg1",XMLType.XSD_INT, ParameterMode.IN);
call.addParameter("arg0",XMLType.XSD_DATETIME, ParameterMode.IN);
call.addParameter("arg0",XMLType.XSD_DATETIME, ParameterMode.IN);
call.addParameter("arg1",XMLType.XSD_INT, ParameterMode.IN);
call.setReturnType(XMLType.XSD_STRING,String.class);
Then u can try to invoke the service by giving all the values in object array as you did.Try this