Subject:
Hi
I have a web service which generate the SSL keys for the given user
I have written the client code to access service but it fails..
Can any body help me..
CLIENT CODE
*********************
import java.io.FileReader;
import java.io.IOException;
import javax.xml.namespace.QName;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.rpc.client.RPCServiceClient;
public class RPCClass {
static private String readInput(String filename)
throws java.io.IOException
{
StringBuffer sbuf = new StringBuffer();
FileReader in = new FileReader( filename );
int len;
char cbuf[] = new char[512];
while ((len = in.read( cbuf, 0, cbuf.length)) != -1) {
sbuf.append( cbuf, 0, len );
}
in.close();
return sbuf.toString();
}
public static void main(String[] args1) throws AxisFault {
RPCServiceClient serviceClient = new
RPCServiceClient();
Options options = serviceClient.getOptions();
EndpointReference targetEPR =
new
EndpointReference("http://127.0.0.1:8080/axis2/services/Keygen");
options.setTo(targetEPR);
QName opgenerateKey= new
QName("http://keygen.symantec.com/xsd","generateKey");
String method="SIG";
String xmlfile="E:/WorkSpace/key/sig.xml";
Object[] opgenerateKeyArgs=null;
try {
opgenerateKeyArgs = new
Object[] {method,readInput(xmlfile)};
System.out.println(readInput(xmlfile));
} catch (IOException e) {
// TODO Auto-generated
catch block
e.printStackTrace();
}
Class[] returnTypes = new Class[] { String.class };
Object[] response = serviceClient.
invokeBlocking(opgenerateKey,opgenerateKeyArgs,returnTypes);
String r = (String) response[0];
System.out.println("THe return value is :" + r);
}
}
Exception in thread "main" org.apache.axis2.AxisFault:
java.lang.RuntimeException: Unexpected subelement arg0
at
org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOper
ation.java:271)
at
org.apache.axis2.description.OutInAxisOperationClient.execute(OutInAxisO
peration.java:202)
at
org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:579
)
at
org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:508
)
at
org.apache.axis2.rpc.client.RPCServiceClient.invokeBlocking(RPCServiceCl
ient.java:95)
at RPCClass.main(RPCClass.java:53)
--Abhishek