1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Error al enviar petición a un web service vía SOAP en PHP

Discussion in 'Programming/Internet' started by David Espinal, Oct 8, 2018.

  1. Este es mi código php para llamar a la función del web service:

    require_once 'nuSoap/nusoap.php';

    $client = new nusoap_client('https://facturaelectronica.dian.gov.co/habilitacion/B2BIntegrationEngine/FacturaElectronica/facturaElectronica.wsdl',true);

    $username = 'xxxxx';
    $password = hash('sha256','xxxx');
    $nonce = base64_encode(rand(10000000000,99999999999));
    date_default_timezone_set("America/Bogota");
    $created = date('Y-m-d\TH:i:s\Z');


    $header = '<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401wss-wssecurity-secext-1.0.xsd">
    <wsse:UsernameToken>
    <wsse:Username>'.$username.'</wsse:Username>
    <wsse:password>'.$password.'</wsse:password>
    <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis200401-wss-soap-message-security1.0#Base64Binary">'.$nonce.'</wsse:Nonce>
    <wsu:Created>'.$created.'</wsu:Created>
    </wsse:UsernameToken>
    </wsse:Security>';

    $client->setHeaders($header);
    $client->soap_defencoding = 'UTF-8';
    $client->namespaces = array(
    'soapenv'=>"http://schemas.xmlsoap.org/soap/envelope/",
    'rep'=>"http://www.dian.gov.co/servicios/facturaelectronica/ReportarFactura"
    );

    $date = date('Y-m-d\TH:i:s');
    $content = file_get_contents('ws_f0900467785000000000f.zip');
    $base = base64_encode($content);

    $body = '<rep:EnvioFacturaElectronicaPeticion>
    <rep:NIT>900467785</rep:NIT>
    <rep:InvoiceNumber>990000001</rep:InvoiceNumber>
    <rep:IssueDate>'.$date.'</rep:IssueDate>
    <rep:Document>'.$base.'</rep:Document>
    </rep:EnvioFacturaElectronicaPeticion>';

    $result = $client->call('EnvioFacturaElectronica',$body);

    echo '<h2>Request</h2><pre>'. htmlspecialchars($client->request, ENT_QUOTES) .'</pre>';
    echo '<h2>Response</h2><pre>'. htmlspecialchars($client->response, ENT_QUOTES) .'</pre>';


    ?>


    Estoy intentando usar un web service, enviando la siguiente petición:

    POST /habilitacion/B2BIntegrationEngine/FacturaElectronica HTTP/1.0
    Host: facturaelectronica.dian.gov.co
    User-Agent: NuSOAP/0.9.5 (1.123)
    Content-Type: text/xml; charset=UTF-8
    SOAPAction: ""
    Content-Length: 7017

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:rep="http://www.dian.gov.co/servicios/facturaelectronica/ReportarFactura">
    <soapenv:Header>
    <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401wss-wssecurity-secext-1.0.xsd">
    <wsse:UsernameToken>
    <wsse:Username>69d4f0b6-4924-4479-bdc6-26ef726eaee3</wsse:Username>
    <wsse:password>6f9e2d69d7a806041b66c5af8c29b0d77c50ed02b17ae3b7002bb81f4c073e53</wsse:password>
    <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis200401-wss-soap-message-security1.0#Base64Binary">MTI2NTU1ODAwMA==</wsse:Nonce>
    <wsu:Created>2017-08-17T14:24:14Z</wsu:Created>
    </wsse:UsernameToken>
    </wsse:Security>
    </soapenv:Header>
    <soapenv:Body>
    <rep:EnvioFacturaElectronicaPeticion>
    <rep:NIT>900467785</rep:NIT>
    <rep:InvoiceNumber>990000001</rep:InvoiceNumber>
    <rep:IssueDate>2017-08-17T14:24:14</rep:IssueDate>
    <rep:Document>UEsDBBQAAAAIAIRCEUvcUzwbfBAAAG07AAAeAAAAZmFjZV9mMDkwMDQ2Nzc4NTAwM2IwMjMzODEueG1s7TtZc6rKuu/+Csr9cm5lGQHBqVZyLgIqKk7g+LKLoUUUARlE/Zf3H90GHHCKSfZa5+w7pFIp7W8e+2ua/PzndmUgG+C4umW+pbFXNI0AU7FU3dTe0gOxmimmEdeTTFUyLBO8pU0r/c/31M8ZKHPmxtIVgEAGplueQdjc8+xyNhsEwauqS+arZm1eFSurWKbnSJ7lZmeS4vmOBAygeI5l6oq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n/kjh73s/ufKe+m9QSwECFAMUAAAACACEQhFL3FM8G3wQAABtOwAAHgAAAAAAAAAAAAAAtoEAAAAAZmFjZV9mMDkwMDQ2Nzc4NTAwM2IwMjMzODEueG1sUEsFBgAAAAABAAEATAAAALgQAAAAAA==</rep:Document>
    </rep:EnvioFacturaElectronicaPeticion>
    </soapenv:Body>
    </soapenv:Envelope>


    Pero recibo la siguiente respuesta del web service:

    HTTP/1.1 100 Continue
    HTTP/1.1 400 Bad Request
    Date: Thu, 17 Aug 2017 19:24:07 GMT
    Server: Apache-Coyote/1.1
    Content-Type: text/html;charset=utf-8
    Content-Length: 1079
    Connection: close

    <html>
    <head>
    <title>JBoss Web/7.4.8.Final-redhat-4 - JBWEB000064: Error report</title>
    <style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style>
    </head>
    <body>
    <h1>JBWEB000065: HTTP Status 400 - </h1>
    <HR size="1" noshade="noshade">
    <p><b>JBWEB000309: type</b> JBWEB000067: Status report</p>
    <p><b>JBWEB000068: message</b> <u></u></p>
    <p><b>JBWEB000069: description</b> <u>JBWEB000120: The request sent by the client was syntactically incorrect.</u></p>
    <HR size="1" noshade="noshade">
    <h3>JBoss Web/7.4.8.Final-redhat-4</h3>
    </body>
    </html>

    Login To add answer/comment
     

Share This Page