Foros del Web » Programación para mayores de 30 ;) » Java »

Cliente WebService / apache AXIS

Estas en el tema de Cliente WebService / apache AXIS en el foro de Java en Foros del Web. Hola a todos... Tengo inconvenientes para consumir un WebService, actualmente estoy usando AXIS y no logro generar el XML que necesita el WebService... Así deberia ...
  #1 (permalink)  
Antiguo 31/05/2010, 14:56
Avatar de dackiller  
Fecha de Ingreso: septiembre-2003
Ubicación: The Matrix
Mensajes: 341
Antigüedad: 20 años, 7 meses
Puntos: 4
Cliente WebService / apache AXIS

Hola a todos...

Tengo inconvenientes para consumir un WebService, actualmente estoy usando AXIS y no logro generar el XML que necesita el WebService...

Así deberia quedar el XML listo para ser enviado al WebService:

Código XML:
Ver original
  1. <soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
  2. <soapenv:Body>
  3. <doPayment xmlns='Direccion del WebService/'>
  4.  <paymentRequest xmlns=''>
  5.   <arg1>10</arg1>
  6.   <arg2>1</arg2>
  7.   <arg3>true</arg3>
  8.   <arg4>1111</arg4>
  9.  </paymentRequest>
  10. </doPayment>
  11. </soapenv:Body>
  12. </soapenv:Envelope>

Así me esta quedando el XML generado por el Cliente AXIS

Código XML:
Ver original
  1. <?xml version="1.0" encoding="UTF-8"?>
  2.    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  3.       <soapenv:Body>
  4.          <doPayment soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
  5. // AQUI DEBO GENERAR OTRO NODO llamado <paymentRequest> y no se como generarlo
  6.             <arg1>10</arg1>
  7.             <arg2>1</arg2>
  8.             <arg3>true</arg3>
  9.             <arg4>1111</arg4>
  10. // AQUI DEBERIA TERMINAR EL NODO </paymentRequest>
  11.          </doPayment>
  12.       </soapenv:Body>
  13.    </soapenv:Envelope>

Código Java:
Ver original
  1. try {
  2.     String endpoint = "http://127.0.0.1/"; // WebService
  3.     Service serv = new Service();
  4.     Call  req = (Call) serv.createCall();
  5.    
  6.     req.setProperty(req.SEND_TYPE_ATTR,false);
  7.     req.setTargetEndpointAddress(new java.net.URL(endpoint));  
  8.     req.setOperationName("doPayment");
  9.     req.addParameter("arg1",XMLType.XSD_STRING, ParameterMode.IN);
  10.     req.addParameter("arg2",XMLType.XSD_STRING, ParameterMode.IN);
  11.     req.addParameter("arg3",XMLType.XSD_STRING, ParameterMode.IN);
  12.     req.addParameter("arg4",XMLType.XSD_STRING, ParameterMode.IN);
  13.     req.setReturnType(org.apache.axis.Constants.XSD_STRING);
  14.  
  15.     /* LLAMADA */
  16.     String ret = (String) req.invoke(new Object[]{"amm","5000",String.format("%06d",56),"1"});
  17.     System.out.println("DEMONIOS ME ESTOY VOLVIENDO LOCO");
  18. } catch (Exception e) {
  19.     System.err.println(e.toString());
  20. }

En AXIS realmente hay tanta info pero en ninguna he visto que dentro de una Operacion alla otro nodo y que contengan parametros, realmente no se si soy yo que tome una mala decision en usar AXIS ó los que desarrollaron el WebService no lo hicieron siguiendo los Estandares...

PD: Realmente desconozco el tema, si me pueden orientar les estaria agradecido, pero realmente lo que necesito es agregar el NODO <paymentRequest> y terminar con este proyecto que me tiene |@#~€|#~¬~€€¬

Gracias
Saludos...
__________________
--
NOTA: Si haz conseguido la solución a tu problema, por favor edita el titulo del tema colocando el prefijo [SOLUCIONADO], para que otros usuarios puedan encontrar soluciones más rápido.
  #2 (permalink)  
Antiguo 31/05/2010, 16:37
 
Fecha de Ingreso: marzo-2010
Mensajes: 18
Antigüedad: 14 años, 1 mes
Puntos: 3
Respuesta: Cliente WebService / apache AXIS

Hola, para evitarte tanto dolor de cabeza, instala el Eclipse y después el plugin de AXIS, en la página viene como se instala, es bastante sencillo, ahora para generar el cliente, deberás seleccionar la parte de AXIS y decirle de donde tomará la definición para el cliente, con unos cuantos Clicks tendrás tu cliente generado.

Saludos!!!


Cita:
Iniciado por dackiller Ver Mensaje
Hola a todos...

Tengo inconvenientes para consumir un WebService, actualmente estoy usando AXIS y no logro generar el XML que necesita el WebService...

Así deberia quedar el XML listo para ser enviado al WebService:

Código XML:
Ver original
  1. <soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
  2. <soapenv:Body>
  3. <doPayment xmlns='Direccion del WebService/'>
  4.  <paymentRequest xmlns=''>
  5.   <arg1>10</arg1>
  6.   <arg2>1</arg2>
  7.   <arg3>true</arg3>
  8.   <arg4>1111</arg4>
  9.  </paymentRequest>
  10. </doPayment>
  11. </soapenv:Body>
  12. </soapenv:Envelope>

Así me esta quedando el XML generado por el Cliente AXIS

Código XML:
Ver original
  1. <?xml version="1.0" encoding="UTF-8"?>
  2.    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  3.       <soapenv:Body>
  4.          <doPayment soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
  5. // AQUI DEBO GENERAR OTRO NODO llamado <paymentRequest> y no se como generarlo
  6.             <arg1>10</arg1>
  7.             <arg2>1</arg2>
  8.             <arg3>true</arg3>
  9.             <arg4>1111</arg4>
  10. // AQUI DEBERIA TERMINAR EL NODO </paymentRequest>
  11.          </doPayment>
  12.       </soapenv:Body>
  13.    </soapenv:Envelope>

Código Java:
Ver original
  1. try {
  2.     String endpoint = "http://127.0.0.1/"; // WebService
  3.     Service serv = new Service();
  4.     Call  req = (Call) serv.createCall();
  5.    
  6.     req.setProperty(req.SEND_TYPE_ATTR,false);
  7.     req.setTargetEndpointAddress(new java.net.URL(endpoint));  
  8.     req.setOperationName("doPayment");
  9.     req.addParameter("arg1",XMLType.XSD_STRING, ParameterMode.IN);
  10.     req.addParameter("arg2",XMLType.XSD_STRING, ParameterMode.IN);
  11.     req.addParameter("arg3",XMLType.XSD_STRING, ParameterMode.IN);
  12.     req.addParameter("arg4",XMLType.XSD_STRING, ParameterMode.IN);
  13.     req.setReturnType(org.apache.axis.Constants.XSD_STRING);
  14.  
  15.     /* LLAMADA */
  16.     String ret = (String) req.invoke(new Object[]{"amm","5000",String.format("%06d",56),"1"});
  17.     System.out.println("DEMONIOS ME ESTOY VOLVIENDO LOCO");
  18. } catch (Exception e) {
  19.     System.err.println(e.toString());
  20. }

En AXIS realmente hay tanta info pero en ninguna he visto que dentro de una Operacion alla otro nodo y que contengan parametros, realmente no se si soy yo que tome una mala decision en usar AXIS ó los que desarrollaron el WebService no lo hicieron siguiendo los Estandares...

PD: Realmente desconozco el tema, si me pueden orientar les estaria agradecido, pero realmente lo que necesito es agregar el NODO <paymentRequest> y terminar con este proyecto que me tiene |@#~€|#~¬~€€¬

Gracias
Saludos...
  #3 (permalink)  
Antiguo 31/05/2010, 18:24
Avatar de dackiller  
Fecha de Ingreso: septiembre-2003
Ubicación: The Matrix
Mensajes: 341
Antigüedad: 20 años, 7 meses
Puntos: 4
[SOLUCIONADO] Cliente WebService / apache AXIS

sonicJava

MIL GRACIAS, ya solvente el problema exactamente como habias recetado la solución...

PD: No sabia que existia el Plugin para WebService (Realmente AYUDA)

GRACIAS
__________________
--
NOTA: Si haz conseguido la solución a tu problema, por favor edita el titulo del tema colocando el prefijo [SOLUCIONADO], para que otros usuarios puedan encontrar soluciones más rápido.

Etiquetas: apache, axis, cliente, webservice
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 12:57.