Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Otros entornos y lenguajes > JAVA
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

 
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 23-01-2009
Avatar de foetus
foetus foetus is offline
Miembro
 
Registrado: mar 2007
Ubicación: Santo Domingo, Rep. Dom.
Posts: 77
Poder: 18
foetus Va por buen camino
Arrow SOAP Web Service

Saludos,

Estoy tratando de consumir un web service que esta hecho en SOAP.

Necesito usar solo J2SE, estube probando con el paquete javax.xml.soap de la versión 1.6. Estube buscando ejemplos y eso, hasta ahora eh logrado que se conecte al web service, ejecute un metodo y me devuelva los datos de retorno en xml como era de esperarce.

El problema es que necesito manipular estos datos lo mas que se pueda, necesito saber si ahi alguna clase que me permita manipular el xml que me retorna el web service.

Aqui posteo el codigo de ejemplo que estoy usando:
Código PHP:
import javax.xml.soap.*;
import java.util.*;

import javax.xml.transform.TransformerFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.Source;

import javax.xml.transform.stream.StreamResult;

import javax.imageio.metadata.*;



public class 
Connection
{
    
// instance variables - replace the example below with your own
    
   
    

    
private int x;

    
/**
     * Constructor for objects of class Connection
     */
    
public Connection()
    {

    }

   
    public static 
void main(String[] args)
    {
        
String url "http://spirittechnologies.net/carlos/web_service/3rd/cbf_camps.php";
        
        try{
             
// Create Conextion
            
SOAPConnectionFactory factory SOAPConnectionFactory.newInstance();
            
SOAPConnection conn factory.createConnection();
            
            
// Create message
            
MessageFactory mf MessageFactory.newInstance();
            
SOAPMessage msg mf.createMessage();
            
          
             
                
// Object for message parts
             
SOAPPart sp msg.getSOAPPart();

             
SOAPEnvelope env sp.getEnvelope();
             
env.addNamespaceDeclaration("xsd","http://www.w3.org/2001/XMLSchema");
             
env.addNamespaceDeclaration("xsi","http://www.w3.org/2001/XMLSchema-instance");
             
env.addNamespaceDeclaration("enc","http://schemas.xmlsoap.org/soap/encoding/");
             
env.addNamespaceDeclaration("env","http://schemas.xmlsoap.org/soap/envelop/");
             
env.setEncodingStyle("http://schemas.xmlsoap.org/soap/encoding/");

             
SOAPBody bd env.getBody();

             
// Populate body
             // Main element and namespace
             
SOAPElement be bd.addChildElement(env.createName("campList",
                                                                
"urn",
                                                                
"http://spirittechnologies.net/carlos/web_service/3rd/cbf_camps.php")); 
                                                                
// namespace to use for my rpc/encoded wsdl version is:
                                                                // http://phonedirlux.homeip.net/wsdl
                                                                // note, in this case the endpoint address is /rcx-ws-rpc/rcx

             // Add content
             
be.addChildElement("partnerId").addTextNode("85").setAttribute("xsi:type","xsd:string");
             
be.addChildElement("partnerKey").addTextNode("tjbestty").setAttribute("xsi:type","xsd:string");
             
be.addChildElement("action").addTextNode("showCamps").setAttribute("xsi:type","xsd:string");


             
// Save message
             
msg.saveChanges();

             
// View input
             
System.out.println("\n Soap request:\n");
             
msg.writeTo(System.out);
             
System.out.println();

             
// Send
             
String urlval url;//"http://www.pascalbotte.be/rcx-ws/rcx";
             // or /rcx-ws-rpc/rcx for my rpc/encoded web service

             
SOAPMessage rp conn.call(msgurlval);

             
// View the output
             
System.out.println("\nXML response\n");

             
// Create transformer
             
TransformerFactory tff TransformerFactory.newInstance();
             
Transformer tf tff.newTransformer();

             
// Get reply content
             
SOAPPart soapPart rp.getSOAPPart();

             
Source sc soapPart.getContent();

      
             
// Set output transformation
             
StreamResult result = new StreamResult(System.out);
             
tf.transform(scresult);
             
System.out.println();
            
             
// Close connection
             
conn.close();

    


             
        }catch(
Exception e){
            
e.printStackTrace();
            
System.out.println(e.getMessage());
        }
        
       
    
    }

Responder Con Cita
 


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Problemas con SOAP y ssl xrubio Internet 1 22-05-2007 15:23:53
Version SOAP en Web Service D7 Luis Heriberto Internet 0 06-09-2006 01:07:16
Xml - Soap ku9 JAVA 0 16-06-2006 11:52:17
Delphi 7 SOAP y SSL iuqrul Internet 0 02-02-2006 01:09:33
Service y Application Service Ezecool Varios 0 30-09-2003 19:48:30


La franja horaria es GMT +2. Ahora son las 16:17:07.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi