2012-01-13 41 views
2

予設定的返回值的datatypewsdl文件是xsd:anyType爲什麼webservice不支持突出顯示的字母?

<message name="getEtapeProspResponse"> 
    <part name="return" type="xsd:anyType"/> 
</message> 

PHP函數其中webservice呼叫返回其是從MySQL表選中的列構成的字符串。和一個列有textdatatype:中

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」有一個突出的信,é。 問題是,當我從我的J2ME應用程序調用webservice時,會引發異常。但是,如果我在column中沒有插入任何突出顯示的字母,那麼web服務就沒問題。

那麼如何解決這個突出的字母問題呢?

+0

我不是PHP的專家,但也許你可以編碼的信息。處理web服務時,特殊字符可能一直是個問題。 – Ernesto 2012-01-13 14:27:37

+1

拋出哪個異常?從服務器收到的XML消息是什麼樣的? – DRH 2012-01-13 14:30:13

+1

你的意思是'重音字符'。重點將更加沿着「大膽」,「斜體」等行......你是否檢查過整個HTTP管道(客戶端 - > php->數據庫 - > php->客戶端)匹配的字符集?該鏈中任何地方字符集的單一改變將破壞數據。 – 2012-01-13 14:38:55

回答

3

文本包含字符像,B,C,d,e或E(你的情況)等,其一個系統支持一起形成所有字符的字符集。 A 字符編碼然後定義字符如何被序列化爲字節表示(值是什麼值,該值將被存儲在多少字節等)。

這是你在編碼中遇到問題的地方。你的角色被轉換成字節,然後從字節中得到字符。如果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

相關問題