SOAP CLIENT and HEADER
| From: | Augusto Flavio | Date: | Wed, 02 Dec 2009 01:08:42 +0000 |
| Subject: | SOAP CLIENT and HEADER | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-300194@lists.php.net to get a copy of this message | ||
hi All,
I'm trying to access a SOAP service but i have one doubt. I paste a
sample SOAP request for you know the problem:
//---------------- START SOAP REQUEST
POST /wbm/shopping/script/CalcPrecoPrazo.asmx HTTP/1.1
Host: shopping.correios.com.br
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/CalcPrecoPrazo"
//NOTE THIS LINE
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<CalcPrecoPrazo xmlns="http://tempuri.org/">
<nCdEmpresa>string</nCdEmpresa>
<sDsSenha>string</sDsSenha>
<nCdServico>string</nCdServico>
<sCepOrigem>string</sCepOrigem>
<sCepDestino>string</sCepDestino>
<nVlPeso>string</nVlPeso>
<nCdFormato>int</nCdFormato>
<nVlComprimento>decimal</nVlComprimento>
<nVlAltura>decimal</nVlAltura>
<nVlLargura>decimal</nVlLargura>
<nVlDiametro>decimal</nVlDiametro>
<sCdMaoPropria>string</sCdMaoPropria>
<nVlValorDeclarado>decimal</nVlValorDeclarado>
<sCdAvisoRecebimento>string</sCdAvisoRecebimento>
</CalcPrecoPrazo>
</soap:Body>
</soap:Envelope>
//---------------- END SOAP REQUEST
Ok. Now i'm creating the soap client:
$client = new SoapClient(null, array('location' =>
"http://shopping.correios.com.br/wbm/shopping/script/CalcPrecoPrazo.asmx",
'uri' => "http://localhost/"));
//I need set the a header for this request: SOAPAction:
"http://tempuri.org/CalcPrecoPrazo", right?
How can i do it ?
I tried something like this but not worked.
$header = new SoapHeader('http://tempuri.org/CalcPrecoPrazo',
'SOAPAction',
null);
$client->__setSoapHeaders($header);
Someidea?
$results = $client->CalcPrecoPrazo($empresaCod, $empresaSenha,
$codigoFrete, $cepOrigem, $cepDestino, $peso,
(int)$formatoCd,
(int)$comprimento, (int)$altura, (int)$largura, (int)$VlDiametro,
$codMaoPropria,
(float)$valor, $codAvisoRecebimento);
thanks
Augusto Morais