0
votes

I am getting the following error when trying to create a new SoapClient.

Fatal error: Uncaught SoapFault exception: [HTTP] Error Fetching http headers in C:\Program Files (x86)\EasyPHP-5.3.9\www\protocolo\index2.php:61 Stack trace: #0 [internal function]: SoapClient->__doRequest('http://localhos...', '', 1, 0) #1 C:\Program Files (x86)\EasyPHP-5.3.9\www\protocolo\index2.php(61): SoapClient->__call('solicitarProtoc...', Array) #2 C:\Program Files (x86)\EasyPHP-5.3.9\www\protocolo\index2.php(61): SoapClient->solicitarProtocoloOperation(Array) #3 {main} thrown in C:\Program Files (x86)\EasyPHP-5.3.9\www\protocolo\index2.php on line 61

That is the wsdl file i am using:

<definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns="http://schemas.xmlsoap.org/soap/encoding/" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://gp.unimed.coop.br/solicitarProtocolo/webservices/V1_00_00" xmlns:gp="http://gp.unimed.coop.br/schemas/V1_00_00" name="solicitarProtocolo" targetNamespace="http://gp.unimed.coop.br/solicitarProtocolo/webservices/V1_00_00">
<wsdl:types>
    <xsi:schema xmlns:tns="http://gp.unimed.coop.br/solicitarProtocolo/webservices/V1_00_00" xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:gp="http://gp.unimed.coop.br/schemas/V1_00_00" targetNamespace="http://gp.unimed.coop.br/solicitarProtocolo/webservices/V1_00_00">
        <xsi:import namespace="http://gp.unimed.coop.br/schemas/V1_00_00" schemaLocation="gp_Transacoes-V1_00_00.xsd" />
    </xsi:schema>
</wsdl:types>
<message name="solicitarProtocoloRequest">
    <part name="solicitarProtocoloRequest" element="gp:solicitarProtocoloWS" />
</message>
<message name="solicitarProtocoloResponse">
    <part name="solicitarProtocoloResponse" element="gp:respostasolicitarProtocoloWS" />
</message>
<message name="ErroInesperadoFault">
    <part name="ErroInesperadoFault" element="gp:erroInesperadoWS" />
</message>
<portType name="solicitarProtocoloPortType">
    <operation name="solicitarProtocoloOperation">
        <input message="tns:solicitarProtocoloRequest" />
        <output message="tns:solicitarProtocoloResponse" />
        <fault name="ErroInesperadoFault" message="tns:ErroInesperadoFault" />
    </operation>
</portType>
<binding name="solicitarProtocoloBinding" type="tns:solicitarProtocoloPortType">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
    <operation name="solicitarProtocoloOperation">
        <soap:operation soapAction="" />
        <input>
            <soap:body use="literal" />
        </input>
        <output>
            <soap:body use="literal" />
        </output>
        <fault name="ErroInesperadoFault">
            <soap:fault name="ErroInesperadoFault" use="literal" />
        </fault>
    </operation>
</binding>
<service name="solicitarProtocolo">
    <port name="solicitarProtocoloPort" binding="tns:solicitarProtocoloBinding">
        <soap:address location='http://localhost/protocolo/index2.php' />
    </port>
</service>

And here my php file:

<?php
set_time_limit(0);

$conf=array(
    'trace' =>true,
);

$client = new SoapClient('solicitarProtocolo_V1_00_00.wsdl',$conf);
$client->__setLocation('http://localhost/protocolo/index2.php');


$result = $client->solicitarProtocoloOperation(
                                array(
                                    'cabecalhoTransacao'    => array(   
                                                                        'codigoTransacao'               => '001',
                                                                        'tipoCliente'                   => 'UNIMED',
                                                                        'codigoUnimedOrigemMensagem'    => '1234',
                                                                        'codigoUnimedDestinoMensagem'   => '1234',
                                                                        'numeroRegistroANS'             => '348406'
                                                                    ),
                                    'solicitarProtocolo'    => array(   
                                                                        'numeroTransacaoPrestadora'     => '0000000001',
                                                                        'dataGeracao'                   => date("Y-m-d"),
                                                                        'idUsuario'                     => 'User',
                                                                        'identificacaoBeneficiario'     => array(
                                                                                                                    'codigoUnimed'          => '1234',
                                                                                                                    'codigoIdentificacao'   => '123123123123'
                                                                                                                ),
                                                                        'dadosBeneficiario'             => array(
                                                                                                                    'nomeBenef'     => 'Beneficiario Teste',
                                                                                                                    'cdCPF'         => '12312312312',
                                                                                                                    'ddd'           => '84',
                                                                                                                    'telefone'      => '988888888',
                                                                                                                    'email'         => '[email protected]'
                                                                                                                ),
                                                                        'identificacaoManifestacao'     => array(
                                                                                                                    'tipoManifestacao'      => '1', 
                                                                                                                    'tipoCategoria'         => '1',
                                                                                                                    'tipoSentimento'        => '1'
                                                                                                                ),
                                                                        'idresposta'                    => '',
                                                                        'numeroTransacaoIntercambio'    => '',
                                                                        'numeroProtocoloAnterior'       => '',
                                                                        'mensagemLivre'                 => $texto,
                                                                        'numeroVersaoProtocolo'         => '001'
                                                                    ),
                                    'hash'                  => 'arquivo.xml'
                                ));

echo 'Response: ';
print_r($result);
?>
1

1 Answers

0
votes

In the constructor for the SoapClient you are supposed to provide a URL not a file on the disk.