
01/09/2010, 09:12
|
| | Fecha de Ingreso: agosto-2010
Mensajes: 7
Antigüedad: 14 años, 6 meses Puntos: 0 | |
Respuesta: consumir Web Services desde Java con SOAP 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; |