Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Otros entornos y lenguajes > PHP
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 06-01-2009
consultasmq consultasmq is offline
Registrado
 
Registrado: feb 2008
Posts: 8
Poder: 0
consultasmq Va por buen camino
fsockopen

Estimados, tengo un tema al usar el fsockopen con el siguiente código:
Código PHP:
<?PHP

$data='<DATAPACKET Version="2.0">'
             
'<METADATA>'
              
'<FIELDS>'
              
'<FIELD attrname="COD_CADENA" fieldtype="i4"/>'
          
'<FIELD attrname="COD_FARMACIA" fieldtype="i4"/>'
          
'<FIELD attrname="COD_RUBRO" fieldtype="i4"/>'
          
'<FIELD attrname="COD_PRODUCTO" fieldtype="i4"/>'
          
'<FIELD attrname="COD_PRESENTACION" fieldtype="i4"/>'
          
'<FIELD attrname="STOCK_ACTUAL" fieldtype="i4"/>'
          
'<FIELD attrname="FECHA_STOCK" fieldtype="dateTime"/>'
          
'<FIELD attrname="BAJA" fieldtype="i2"/>'
        
'</FIELDS>'
        
'<PARAMS LCID="1033"/>'
       
'</METADATA>'
    
'<ROWDATA>'
 
'<ROW COD_CADENA="1" COD_FARMACIA="168" COD_RUBRO="2" COD_PRODUCTO="427" COD_PRESENTACION="98" STOCK_ACTUAL="1" FECHA_STOCK="20080903T10:03:08440" BAJA="0"/>' 
        '</ROWDATA>'

  
'</DATAPACKET>'

$resultado =sendToHost('localhost',80,'post','/servicio.php',$data); 

function 
sendToHost($host,$port,$method,$path,$data,$useragent=0
    { 
    
// Supply a default method of GET if the one passed was empty 
    
if (empty($method)) { 
        
$method 'GET'
    } 
    
$method strtoupper($method); 
    
$fp fsockopen($host$port$errno$errstr30); 
        if (!
$fp){ 
            return 
"$errstr ($errno)<br /> "
            exit; 
        } 
    if (
$method == 'GET') { 
        
$path .= '?' $data
    } 
        
$file ="$method $path HTTP/1.1 "
        
$file.="Host: $host "
        
$file.="Content-type: text/html "
        
//$file.="Content-type: application/x-www-form-urlencoded "; 
        
$file.="Content-length: " strlen($data) . " "
        
$file.="Connection: close  "
         
    if (
$useragent) { 
        
$file.="User-Agent: MSIE "
    } 
     
        if (
$method == 'POST') { 
            
$file.=$data;         
          
//echo $file; 
    

        
fwrite($fp$file); 
         
    while (!
feof($fp)) { 
            
$buf .= fgets($fp); 
    } 
    
fclose($fp); 
    return 
$buf

?>


ok, espero lo puedan leer bien, te tema es que cuando llega el mensaje que es el xml que preparo en $data, si el Content-type que utilizo es text/html o text/xml, el servidor al que le envió esta info no recibe nada :S, increible pero verdadero, si por el contrario el content-type es application/x-www-form-urlencode entonces el servidor si recibe los datos pero todo lo que va con comillas (") lo substituye por (") jajaj..., ahora bien, trate de mandarle " en vez de las comillas, pero entonces el XML le llega incompleto

Alguna idea???

muchas gracias.

Mau
Responder Con Cita
Respuesta



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


La franja horaria es GMT +2. Ahora son las 03:08:29.


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