Posted By

alejandrosuch on 04/09/10


Tagged

java webservices axis


Versions (?)

Call webservice without creating wsdl2java axis classes


 / Published in: Java
 

  1. import java.io.IOException;
  2. import java.net.MalformedURLException;
  3. import java.rmi.RemoteException;
  4.  
  5. import javax.xml.rpc.ParameterMode;
  6. import javax.xml.rpc.ServiceException;
  7.  
  8. import org.apache.axis.client.Call;
  9. import org.apache.axis.client.Service;
  10. import org.apache.axis.encoding.XMLType;
  11.  
  12.  
  13. private static String webServiceCall(String in0, String in1) throws ServiceException, MalformedURLException, RemoteException {
  14. //---------- IF SECURITY NEEDED
  15. System.setProperty("javax.net.debug", "ssl");
  16. System.setProperty("javax.net.ssl.trustStore", "/path/to/truststore");
  17. System.setProperty("javax.net.ssl.trustStorePassword", "password");
  18. System.setProperty("javax.net.ssl.keyStoreType", "JKS");
  19. //----------
  20.  
  21. Service service = new Service();
  22. Call call = (Call) service.createCall();
  23. call.setTargetEndpointAddress(new java.net.URL("https://webserv.pki.gva.es:8443/axis/services/serviciospki"));
  24. call.setOperationName("getToken");
  25. call.addParameter("in0", XMLType.XSD_STRING, ParameterMode.IN);
  26. call.addParameter("in1", XMLType.XSD_STRING, ParameterMode.IN);
  27.  
  28. return (String) call.invoke(new Object[] { in0, in1});
  29. }

Report this snippet  

You need to login to post a comment.