将Unicode值从Android发送到C#WebService



我正在尝试将Unicode值从Android应用发送到WCF Web服务,但我一直将字符串值作为????在WCF Web服务中。以下是Web服务的Android代码和C#代码。

                GTPostData gtPostData = new GTPostData(); //DTO Object
                Gson gson = new Gson();
                String post = "イメージお願いし";
                gtPostData.setPortalId(portalId);
                gtPostData.setPost(post);
                gtPostData.setProjectId(data.getProjectId());
                gtPostData.setQuestionId(data.getQuestionId());
                gtPostData.setUserId(panelistId);
                GTPostDataRequest request = new GTPostDataRequest();
                request.setGtPostData(gtPostData);//creating the request object
                JSONObject jsonObject = new JSONObject(gson.toJson(request)); 
                String webServiceUrl= ResourcePicker.getServiceURL(session.getPortal(),session.getPortalId(),true);
                String addGtPostMethod = ResourcePicker.getString(portal, "add_gt_post");
                AsyncPostRequest asyncRequest = new AsyncPostRequest();
                asyncRequest.setServiceMethod(addGtPostMethod);
                asyncRequest.setServiceUrl(webServiceUrl);
                asyncRequest.setPostObject(jsonObject);//set object for post call
                SendGtPostAsyncService asyncService = new SendGtPostAsyncService(asyncRequest, context, session, db, data.getPostId());
                asyncService.execute();//call the async task

WCF Web服务呼叫(C#(

public bool AddGTPost(GTPostData GtPostData)
        {
            bool isAdded = false;
            try
            {
                sci.Debug(frendlyName, screenName, "", "Enter AddGTPost ->> " + GtPostData);//These are trace methods which will print the results in txt file.

                sci.Debug(frendlyName, screenName, "", "Enter AddGTPost - Unicode Post ->> " + GtPostData.post);//These are trace methods which will print the results in txt file. Here I'm getting results as "??????"

所以请有人帮助我在这里我的错误是什么?

对于您的网络服务,我希望您不会缺少UTF-16格式还在您使用的配置中:

    Configuration config = WebConfigurationManager.OpenWebConfiguration(configPath);
    GlobalizationSection configSection = (GlobalizationSection)config.GetSection("system.web/globalization");            
    configSection.RequestEncoding = Encoding.Unicode;
    configSection.ResponseEncoding = Encoding.Unicode;

相关内容

  • 没有找到相关文章

最新更新