Php nussoap使用拉丁字符失败


Php Nusoap fails with latin characters

我正在使用nussoap开发一个web服务来发送xml数据,这次我必须发送带有拉丁字符的数据,如'ó'。但是,当我把它放在soap客户机中时,它就停止工作了。下面是测试用拉丁字符发送xml的代码摘要。

这是正在开发的服务器代码的总结:

include_once("nusoap/nusoap.php");
$server = new soap_server();
$server->configureWSDL("PersonImport","urn:PersonImport");
$server->register("PersonImport",array("login" => "xsd:string", 'senha' => 'xsd:string', 'fornecedor' => 'xsd:string'),array("return" => "xsd:string"),"urn:PersonImport","urn:PersonImport#PersonImport");

function PersonImport($login,$senha,$fornecedor) {
    //Just for debug purposes
    $return = "My login Is <b>".$login . "</b> And My senha Is <b>".$senha."</b> And My fornecedor Is <b>".$fornecedor."</b>.";
    (...)(ommited code, xml parsing and response xml generation)
    return $return;
}

这是客户端代码的总结:

<?php
require_once("nusoap/nusoap.php");
$client = new soapclient("example.com?wsdl");

$xml = "<?xml version='"1.0'" encoding='"ISO-8859-1'" ?>";
$xml .= "<fornecedor>";
$xml .= "<NAME1>Gian</NAME1>";
$xml .= "<MCOD1>Giancarlo SA</MCOD1>";
$xml .= "<STCD1>80048303000113</STCD1>";
$xml .= "<STCD2>55670185501</STCD2>";
$xml .= "<STCD3>5508150087</STCD3>";
$xml .= "<RG>359730553</RG>";
$xml .= "<STRAS>rua itororó</STRAS>";
$xml .= "<HOUSE_NUM1>81</HOUSE_NUM1>";
$xml .= "<HOUSE_NUM2>301</HOUSE_NUM2>";
$xml .= "<ORT02>Menino Deus</ORT02>";
$xml .= "<PSTLZ>90110290</PSTLZ>";
$xml .= "<REGIO>RS</REGIO>";
$xml .= "<ORT01>Porto Alegre</ORT01>";
$xml .= "<TELF1>32335675</TELF1>";
$xml .= "<TELFX>32335675</TELFX>";
$xml .= "<SMTP_ADDR>teste@teste.com</SMTP_ADDR>";
$xml .= "<ERDAT>2016-10-04</ERDAT>";
$xml .= "<ChangeData>2016-10-04</ChangeData>";
$xml .= "<StartData>2016-10-04</StartData>";
$xml .= "<OffData>2016-10-04</OffData>";
$xml .= "</fornecedor>";
$result = $client->PersonImport("login","password", $xml);

echo $result;

$xml .= "<STRAS>rua itororó</STRAS>";

有一个特殊字符。如果我删除'ó'字符,它可以工作。

我尝试在xml上设置编码:

$xml = "<?xml version='"1.0'" encoding='"ISO-8859-1'" ?>";

当我必须用SimpleXML Parser解析xml时,这对我有用,但它在soap上不起作用。

我尝试像这样设置页眉为utf8或ISO-8859-1:

header("Content-type:text/html; charset=UTF-8");

或:

header ('Content-type: text/html; charset=ISO-8859-1');

我尝试使用htmlentities,但是'ó'的实体是'&如果有特殊字符'&',就会出现同样的问题。

函数序列化没有解决问题。

我在google上一直找不到答案。

是否可以使用nussoap传递拉丁特殊字符?一定有办法的

看来我找到办法了。使用CDATA我可以转义'&',所以我可以在字符串上使用htmlentities,如下所示:

$xml .= "<STRAS><![CDATA[".htmlentities("Rua Itororó")."]]></STRAS>";