Re: remove namespace from xml

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2 dec 2009 kl. 19.12 skrev Augusto Flavio:

Hi all,


i'm trying to connect to a SOAP Server but i'm having a problem. Look
the xml that i need send to the server:

// THIS IS THE XML CORRECT THAT NEED BE SENT TO THE SERVER

<?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>XXXXX</nCdEmpresa>
	<sDsSenha>XXXXXX</sDsSenha>
	<nCdServico>40010</nCdServico>
	<sCepOrigem>30840300</sCepOrigem>
	<sCepDestino>30840280</sCepDestino>
	<nVlPeso>10</nVlPeso>
	<nCdFormato>1</nCdFormato>
	<nVlComprimento>20</nVlComprimento>
	<nVlAltura>5</nVlAltura>
	<nVlLargura>10</nVlLargura
	><nVlDiametro>0</nVlDiametro>
	<sCdMaoPropria>S</sCdMaoPropria>
	<nVlValorDeclarado>300</nVlValorDeclarado>
	<sCdAvisoRecebimento>S</sCdAvisoRecebimento>
</CalcPrecoPrazo>
</soap:Body>
</soap:Envelope>


And now the xml that i'm sending to the SOAP Server.


//THIS IS THE XML THAT THE PHP IS SENDING
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/";
xmlns:ns1="http://tempuri.org/";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/";
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";>
<SOAP-ENV:Body>
<ns1:CalcPrecoPrazo> // HOW CAN I REMOVE THIS NAMESPACE? ns1:
	<nCdEmpresa xsi:type="xsd:int">XXXXX</nCdEmpresa>
	<sDsSenha xsi:type="xsd:string">XXXXXX</sDsSenha>
	<nCdServico xsi:type="xsd:string">40096</nCdServico>
	<sCepOrigem xsi:type="xsd:string">30840280</sCepOrigem>
	<sCepDestino xsi:type="xsd:string">30840300</sCepDestino>
	<nVlPeso xsi:type="xsd:string">10</nVlPeso>
	<nCdFormato xsi:type="xsd:string">1</nCdFormato>
	<nVlComprimento xsi:type="xsd:string">5</nVlComprimento>
	<nVlAltura xsi:type="xsd:string">10</nVlAltura>
	<nVlLargura xsi:type="xsd:string">0</nVlLargura>
	<nVlDiametro xsi:type="xsd:string">300</nVlDiametro>
	<sCdMaoPropria xsi:type="xsd:string">N</sCdMaoPropria>
	<nVlValorDeclarado xsi:type="xsd:string">300</nVlValorDeclarado>
	<sCdAvisoRecebimento xsi:type="xsd:string">N</sCdAvisoRecebimento>
	</ns1:CalcPrecoPrazo>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


How can i remove the ns1 from the Child CalcPrecoPrazo?

Some idea?



//here is the php code:

$client = new SoapClient(null, array('location' => $url,
                                    'uri'      =>
"http://tempuri.org/CalcPrecoPrazo";,
  				     'trace'    => 1 ));

$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

Although I never worked with SOAP so far, at least when it comes to XML namespaces, you need to explicitly set those somewhere in your code before use (which you haven't). Have you asked Google or even looked at the MAN pages? After two minutes of googling, I found this.

From the SOAP man page:

[...]
nico
25-Aug-2006 01:20
If you want to build a Soap Server for Microsoft Office's client (like Microsoft Office Research Service) you need to rewrite SOAP's namespaces :

<?php
// (...)

$server = new SoapServer($wsdl, array('uri' => $uri, 'classmap' => $classmap));
$server->setClass($class);
function callback($buffer)
{
$s = array('<ns1:RegistrationResponse>', 'ns1:', 'xmlns:ns1="urn:Microsoft.Search "'); $r = array('<RegistrationResponse xmlns="urn:Microsoft.Search">', '', '');
   return (str_replace($s, $r, $buffer));
}
ob_start('callback');
$server->handle();
ob_end_flush();

// (...)
?>

There are a complete example at this URL : http://touv.ouvaton.org/article.php3?id_article=104
[...]

I am sure there are other examples too.

/frank


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux