Ver Mensaje Individual
  #10 (permalink)  
Antiguo 11/01/2011, 10:54
dventura
 
Fecha de Ingreso: noviembre-2008
Mensajes: 2
Antigüedad: 15 años, 5 meses
Puntos: 0
Respuesta: consumir Web Services desde Java con SOAP

Cita:
Iniciado por eseluisete Ver Mensaje
Una posible solución para tu cliente:



/*
* URL of the web service
*/
String address = "http://localhost:7001/wsPrueba1/AuthenticationService.jws";
String namespaceURI = "http://www.openuri.org/";
String serviceName = "AuthenticationService";
String portName = "AuthenticationServiceSoap";

ServiceFactory factory = ServiceFactory.newInstance();

/*
* Create an instance of the Service with the given service QName
*/
Service service = factory.createService(new QName(serviceName));

Call call = service.createCall(new QName(portName));

call.setTargetEndpointAddress(address);

QName intQName = new QName("http://www.w3.org/2001/XMLSchema", "string");
/*
* Set operation name to invoke.
*/
call.setOperationName(new QName(namespaceURI,"holaMundo"));
/*
* Add parameters definitions in the call object.
*/

call.addParameter("nombre", intQName, ParameterMode.IN);

/*
* Set definition of the return type.
*/
call.setReturnType(intQName);

Object[] inParams = new Object[1];
inParams[0] = nombre;

String value= (String)call.invoke(inParams);
System.out.println("Result: " + value);
return value;
Hola, me podrias decir por favor cuales son los paquetes que importas en este ejemplo?

por favor y gracias.