4

I'm new to Web Services, but I made one like this:

require_once "lib/nusoap.php";

function welcome($name)
{
   return $name . "خوش آمدید";
}

$server = new soap_server();

$server->configureWSDL("testWebService", "urn:testWebService");

$server->register("welcome",
 array("name" => "xsd:string"),
 array("return" => "xsd:string"),
 "urn:testWebService",
 "urn:testWebService#welcome",
 "rpc",
 "encoded",
 "for user login check");

the "welcome" function returns a string that is partially in the Persian language. I want to use this web service function in my C# application. I've successfully added the web service to my solution in VS and i tried to use it like this:

MessageBox.Show(myWebsrvice.welcome("Mansoor"));

It runs fine but doesn't show the Persian part of the text correctly. What should I do to fix this?

mc110
  • 2,825
  • 5
  • 20
  • 21
  • you should use unicode encoding from assembly `System.Text.Encoding.Unicode.GetString()` – saeed Jul 01 '14 at 13:46
  • `Encoding.Unicode.GetString() ` gets byte[] as input how should i use this ? – Mansoor Safary Jul 01 '14 at 14:11
  • Please release out code that you have tried to check – saeed Jul 01 '14 at 17:51
  • I thought that I should change it to byte[] and change it back to String so i tried this: `Encoding.Unicode.GetString(Encoding.ASCII.GetBytes(myWebsrvice.welcome("Mansoor")))` and all the combinations between `Unicode`,`ASCII` and `UTF8` – Mansoor Safary Jul 01 '14 at 18:57
  • Edit your question post and write your c# code. That could be useful – saeed Jul 02 '14 at 04:28

1 Answers1

3

First add this to your php code and check your client side

$server->soap_defencoding = 'UTF-8';
$server->decode_utf8 = false; 
Majid
  • 1,673
  • 18
  • 27