我将datatype
文件中返回值的wsdl
设置为xsd:anyType
:
<message name="getEtapeProspResponse">
<part name="return" type="xsd:anyType"/>
</message>
PHP
调用的函数返回一个字符串,该字符串是从MySQL表的选定列构造的。其中一列有webservice
的datatype
:function getEtapeProsp($user,$motpasse)
{
$user_code = verifyUser($user, $motpasse) ;
$resultat="";
if ( $user_code != null)
{
$datejour = date("Y-m-d");
$connec = mysql_connect("192.168.1.123:3306", "root", "mysqlroot");
mysql_select_db("finance",$connec);
$query = mysql_query("SELECT * FROM etape_prospection INNER JOIN type_prospection ON etape_prospection.type_prosp_id = type_prospection.type_prosp_id WHERE prosp_id IN (SELECT prosp_id FROM transfert WHERE user_code ='".$user_code ."' AND date_transfert='".$datejour."') order by etape_prospection.prosp_id");
while($ligne = mysql_fetch_array($query))
{
$resultat .= $ligne['etape_prosp_id'].';';
$resultat .= $ligne['type_prosp_lib'].';';
$resultat .= convertDateFormatHH($ligne['etape_prosp_date']).';';
$resultat .= $ligne['etape_prosp_comment'].';'; // this is the text column
$resultat .= $ligne['prosp_id'].';';
$resultat .= "\r\n";
}
}
else
{
$resultat = "Login ou mot de passe incorrect" ;
}
return $resultat;
}
在数据库中,“etape_prosp_comment”的值有一个突出的字母,é。
问题是,当我从
text
应用程序调用webservice时,会抛出异常。但是如果我没有在J2ME
中插入任何突出的字母,那么webservice就可以了。那么,如何解决这个突出的字母问题呢?
最佳答案
文本包含a、b、c、d、e或é(在您的例子中)等字符。系统支持的所有字符组成一个字符集。然后,字符编码定义如何将字符序列化为字节表示(值是什么,值将存储在etc中的字节数)。
这就是你在编码中遇到的问题。你的字符被转换成字节,然后从字节中你必须找回字符。如果web服务和客户端不使用相同的字符编码,则web服务无法将客户端的字节转换为字符,反之亦然;您将得到错误或格式错误的字符串。
我不是一个PHP开发人员,但是下面的文章包含了一些关于解决这个问题的相关信息:Character Sets / Character Encoding Issues。
那篇文章引用了另一篇关于字符集的好文章(虽然有点老,从2003年开始):The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!),所以一定要先阅读这篇文章。
您应该使用的编码是UTF-8,主要是因为这是《web服务互操作性指南》以及UTF-16;see rule R1012 of the Basic Profile强制要求的编码。