Bom amigos estou tb tentando fazer um cliente java chamar um WEB SERVICE C# que autentica Tokens do tipo USERNAMETOKEN, vcs sabem como posso fazer este cliente? tentei o código abaixo mas estou obtendo erro no eclipse na linha em negrito.
import java.net.URL;
import javax.xml.namespace.QName;
//import javax.xml.rpc.Call;
//import javax.xml.rpc.Service;
import javax.xml.rpc.ServiceException;
import javax.xml.rpc.ServiceFactory;
import javax.xml.rpc.handler.*;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.client.Stub;
import org.apache.ws.security.WSConstants;
import org.apache.ws.security.handler.WSHandlerConstants;
import org.apache.ws.security.message.token.UsernameToken;
import java.util.*;
public class ClientSEI {
public static void main(String[] args) throws Exception
{
try {
String UrlString = "http://autserver/WSPA/Service.asmx?WSDL";
String nameSpaceUri = "http://tempuri.org/";
String serviceName = "Service";
String portName = "ServiceSoap";
String xml = "<?xml version='1.0'?><XSPA><Operador>195</Operador><Acao>22</Acao></XSPA>";
QName QNserviceName = new QName(nameSpaceUri, serviceName);
QName QNportName = new QName(nameSpaceUri, portName);
URL wsdlLocation = new URL(UrlString);
// Service
ServiceFactory factory = ServiceFactory.newInstance();
Service service;
service = factory.createService(wsdlLocation,QNserviceName);
HandlerRegistry hr = service.getHandlerRegistry();
List handlerChain = hr.getHandlerChain(QNportName);
HandlerInfo hi = new HandlerInfo();
hi.setHandlerClass(SimpleHandler.class);
handlerChain.add(hi);
// Service Endpoint Interface class generated by WSDL2Java
RcxReadLS objRcx = (RcxReadLS) service.getPort(QNportName, RcxReadLS.class);
Stub axisPort = (Stub)objRcx;
axisPort._setProperty(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
axisPort._setProperty(UsernameToken.PASSWORD_TYPE, WSConstants.PASSWORD_TEXT);
axisPort._setProperty(WSHandlerConstants.USER, "useradmin");
axisPort._setProperty(WSHandlerConstants.PW_CALLBACK_CLASS, "ClienteCallback");
String val = objRcx.processarTransacaoSPA(xml);
// System.out.println("Rcx web service message: " + val);
}
catch (ServiceException ex) {
ex.printStackTrace();
}
}
}
No Eclipse ocorrer um erro nesta linha em negrito ao tentar factory.createService(wsdlLocation,QNserviceName); . O erro é o seguinte:
Exception in thread “main” java.lang.NoClassDefFoundError: org.apache.commons.logging.LogFactory
at org.apache.axis.components.logger.LogFactory.class$(LogFactory.java:45)
at org.apache.axis.components.logger.LogFactory$1.run(LogFactory.java:45)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.axis.components.logger.LogFactory.getLogFactory(LogFactory.java:41)
at org.apache.axis.components.logger.LogFactory.(LogFactory.java:33)
at org.apache.axis.handlers.BasicHandler.(BasicHandler.java:43)
at org.apache.axis.client.Service.getAxisClient(Service.java:104)
at org.apache.axis.client.Service.(Service.java:113)
at ClientSEI.main(ClientSEI.java:36)
ME AJUDEM POR FAVOR.