调用.Net WebSerivce 回传中文报invalid UniCode character
设置
rio->HTTPWebNode->UseUTF8InHeader = true;
InvRegistry()->RegisterInvokeOptions(__interfaceTypeinfo(PowerSvrSoap), ioDocument);
web Service
[WebMethod]
public RetData TestData()
{
RetData td = new RetData();
RetData.Result = "0000";
RetData.ErrMsg="测试";
return td;
}
[WebMethod]
public RetData GetData()
{
string strData = "78321测试090"; //是从socket获取到的 GB2312编码
RetData td = new RetData();
RetData.Result = "0000";
RetData.ErrMsg=strData; //导致BCB报invalid UniCode character错误,
//去掉这一句或 RetData.ErrMsg="78321测试090"正常
return td;
}
这是什么原因,谢谢!
[解决办法]