WSDL WITHOUT passing parameters

Asked

Viewed 178 times

0

Good morning,

I have an XML script to consume data from a webservice, but it comes all ready, no need to pass parameters like user and password. Can someone help me? one of the examples of Webservice would be:

https://servicos.saude.gov.br/cnes/EstabelecimentoSaudeService/v1r0?wsdl

in XML example would be:

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:est="http://servicos.saude.gov.br/cnes/v1r0/estabelecimentosaudeservice" xmlns:fil="http://servicos.saude.gov.br/wsdl/mensageria/v1r0/filtropesquisaestabelecimentosaude" xmlns:cod="http://servicos.saude.gov.br/schema/cnes/v1r0/codigocnes" xmlns:cnpj="http://servicos.saude.gov.br/schema/corporativo/pessoajuridica/v1r0/cnpj">
<soap:Header>
  <wsse:Security soap:mustUnderstand="true" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
     <wsse:UsernameToken wsu:Id="UsernameToken-5FCA58BED9F27C406E14576381084652">
        <wsse:Username>CNES.PUBLICO</wsse:Username>
        <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">cnes#2015public</wsse:Password>
     </wsse:UsernameToken>
  </wsse:Security>
</soap:Header>

   <soap:Body>
  <est:requestConsultarEstabelecimentoSaude>
     <fil:FiltroPesquisaEstabelecimentoSaude>
        <cod:CodigoCNES>
           <cod:codigo>2530031</cod:codigo>
        </cod:CodigoCNES>
     </fil:FiltroPesquisaEstabelecimentoSaude>
  </est:requestConsultarEstabelecimentoSaude>
   </soap:Body>
</soap:Envelope>

---------------------------Code---------------------------

<?php 
$XML_REQUEST = "
<soap:Envelope xmlns:soap='http://www.w3.org/2003/05/soap-envelope' xmlns:est='http://servicos.saude.gov.br/cnes/v1r0/estabelecimentosaudeservice' xmlns:fil='http://servicos.saude.gov.br/wsdl/mensageria/v1r0/filtropesquisaestabelecimentosaude' xmlns:cod='http://servicos.saude.gov.br/schema/cnes/v1r0/codigocnes' xmlns:cnpj='http://servicos.saude.gov.br/schema/corporativo/pessoajuridica/v1r0/cnpj'>
<soap:Header>
      <wsse:Security soap:mustUnderstand='true' xmlns:wsse='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd' xmlns:wsu='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd'>
         <wsse:UsernameToken wsu:Id='UsernameToken-5FCA58BED9F27C406E14576381084652'>
            <wsse:Username>CNES.PUBLICO</wsse:Username>
            <wsse:Password Type='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText'>cnes#2015public</wsse:Password>
         </wsse:UsernameToken>
      </wsse:Security>
</soap:Header>
   <soap:Body>
      <est:requestConsultarEstabelecimentoSaude>
         <fil:FiltroPesquisaEstabelecimentoSaude>
            <cod:CodigoCNES>
               <cod:codigo>2576759</cod:codigo>
            </cod:CodigoCNES>
         </fil:FiltroPesquisaEstabelecimentoSaude>
      </est:requestConsultarEstabelecimentoSaude>
   </soap:Body>
</soap:Envelope>";
$URL = "https://servicos.saude.gov.br/cnes/EstabelecimentoSaudeService/v1r0";
$CH = curl_init($URL);
    curl_setopt($CH, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($CH, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($CH, CURLOPT_POST, 1);
    curl_setopt($CH, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
    curl_setopt($CH, CURLOPT_POSTFIELDS, "$XML_REQUEST");
    curl_setopt($CH, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($CH, CURLOPT_VERBOSE, true);
    $OUTPUT = curl_exec($CH);
    curl_close($CH);
echo $XML = $OUTPUT;
exit();
  • And what is the doubt/problem/difficulty?

  • I tried to ride using Curl, but he rejects the request, but in soapUI he responds normally...

  • Put Curl in question, then.

  • ready put there

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.